From ba0ab5fd4328a0aa0afaeef0cd9b0b475177fc23 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 06:13:22 +0000 Subject: [PATCH 1/5] docs(adr): ADR-0157 working calendars as organization-editable runtime data Records the seven ruled design points for platform working calendars: two sys_* objects, resolution by code then org default then refuse, organization-entered holidays with a maintained-through date, formula functions and the approval clock in one release, escalation.clock with a wall_clock default, in-memory-only evaluation, and no midnight-crossing periods. Lists the six choices the ruling does not make as open questions. Regenerates the ADR index. Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb Co-authored-by: Claude --- ...untime-data-resolved-by-code-or-refused.md | 208 ++++++++++++++++++ docs/adr/README.md | 9 +- 2 files changed, 213 insertions(+), 4 deletions(-) create mode 100644 docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md diff --git a/docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md b/docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md new file mode 100644 index 00000000000..faaa82bf70e --- /dev/null +++ b/docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md @@ -0,0 +1,208 @@ +# ADR-0157: Working calendars are organization-editable runtime data — a consumer names a calendar by code or takes the organization default, otherwise it refuses; formulas and the approval clock read it in the same release + +**Status**: Proposed (2026-11-19). **This record declares; it implements nothing** — no schema, no object, no code, no changeset. Three cards implement it: [#35355](https://github.com/objectstack-ai/objectstack/issues/35355), [#35356](https://github.com/objectstack-ai/objectstack/issues/35356) and [#35357](https://github.com/objectstack-ai/objectstack/issues/35357). `docs/adr/**` is a Tier H governed surface (Prime Directive #14): the maintainer's merge adopts this record, and until then every decision below is a proposal. + +- **Date**: 2026-11-19 +- **Card**: [#35354](https://github.com/objectstack-ai/objectstack/issues/35354) (p1), the first slice of the epic [#35340](https://github.com/objectstack-ai/objectstack/issues/35340). +- **Decided by**: the maintainer, 2026-11-19 05:47Z, on #35340, verbatim 「同意 p1」, recorded in ruling comment [`7000950747`](https://github.com/objectstack-ai/objectstack/issues/35340#issuecomment-7000950747). The sub-cards were approved at 06:03Z with 「同意」 and 「都是 p1」. The ruling's own text is the authority this record executes; where the two differ in words, the ruling wins and this record is corrected. +- **Unfreezes**: the business-hours half of #13655 (ruling record 5478756633, cited from [#13801](https://github.com/objectstack-ai/objectstack/issues/13801); #13655 itself answers 404 to this session). That half was frozen until a named external user asked. The ruling counts the pull from the platform's own suites (the hotcrm case SLA matrix, hotsrm delivery dates, the production suite) as meeting that condition. The freeze's second constraint stands and is D4 here. +- **Reverses**: the in-seat finding on #13801 (comment [`5506987580`](https://github.com/objectstack-ai/objectstack/issues/13801#issuecomment-5506987580)) that a clock marker on `timeoutHours` would be inert. That finding held only while one clock existed; with two clocks the marker has a reader (D5). +- **Builds on**: [ADR-0144](./0144-multi-currency-record-currency-dated-rates-write-time-home-projection.md) (`sys_exchange_rate`: organization-scoped runtime data that an administrator writes and that every change audits — the precedent for D1, and `ERR_HOME_CURRENCY_UNSET`, the precedent for refusing rather than guessing in D2). [ADR-0049](./0049-no-unenforced-security-properties.md) (enforce-or-remove: a calendar nobody reads, an inherited column nobody reads and a clock key with one value are all inert — D2, D4, D5). [ADR-0029](./0029-kernel-object-ownership-and-platform-objects-decomposition.md) D1, D3 and D6 (a first-party capability owns its `sys_*` objects; which package owns the two objects here is #35355's to settle against it). [ADR-0053](./0053-date-and-datetime-semantics.md) (an exception's date is a calendar day, never an instant; time-zone arithmetic goes through the shared DST-safe primitive). [ADR-0112](./0112-error-code-vocabulary-and-ledger.md) (every refusal below answers with a ledger code that the implementing card registers). +- **Amends**: no decision. The `timeoutHours` describe text, which says the platform ships no business-hours calendar, is rewritten by #35357, not here. + +--- + +## Provenance + +Three kinds of text feed this record, and each section says which kind it carries. + +1. **Ruled.** The seven design points of ruling `7000950747`, restated as seven items in the Scope of #35354. [Decision](#decision) carries only these, one D-item per Scope item, in the ruling's own terms. +2. **Analysis the ruling read.** The design analysis for #35340 (project file `card-35340/design-analysis.md`, outside this repository). It supplies the context and the alternatives. A detail that appears only there is not ruled: this record lists such details under [Open questions](#open-questions), never as a decision. +3. **Readings.** Current behaviour, read on `objectstack-ai/objectstack` at `3819afec` (2026-11-19) and cited by symbol anchor (`path#symbol`). Nothing below was run. + +## Context + +### What the platform has today + +- **No working calendar.** No object, service, formula function or spec key counts working time. The only `workingDaysBetween` in the tree is a private QA helper that rebases scenario dates (`packages/qa/scenarios/src/runner/run-date.ts#workingDaysBetween`); it skips Saturdays and Sundays and nothing else, and no runtime reads it. +- **Approval escalation counts wall-clock hours.** `timeoutHours` on `packages/spec/src/automation/approval.zod.ts#ApprovalEscalationSchema` says so in its describe text: nights, weekends and holidays count, and "the platform ships no business-hours calendar". The sweep adds the hours to the request's `created_at` as elapsed milliseconds (`packages/plugins/plugin-approvals/src/approval-service.ts#slaDueAt`). It reads the escalation from the `node_config_json` snapshot stored on each request, so a snapshot written before a new key exists can only mean what the old schema meant. The last change of a default on this block left a cutoff window behind it (`packages/plugins/plugin-approvals/src/approval-service.ts#ESCALATION_ENABLED_FLIP_CUTOFF_MS`). +- **Formulas evaluate synchronously, over pinned data.** The stdlib header (`packages/formula/src/stdlib.ts`) forbids handing a function a resolver or any callback into the host; each evaluation binds `now` and a time zone (`packages/formula/src/cel-engine.ts`). A function that needs a calendar must therefore receive it as data loaded before evaluation. +- **Pushdown refuses every function call.** The CEL-to-filter compiler lowers comparisons and a few string methods and answers `unsupported` for arithmetic and function calls (`packages/formula/src/cel-to-filter.ts#CelFilterFailReason`). +- **The precedent object.** `sys_exchange_rate` (`packages/platform-objects/src/system/sys-exchange-rate.object.ts#SysExchangeRate`) is organization-scoped, written by organization administrators, audited, and filled by hand, by import or by an app flow. The platform ships no rate feed. +- **The business unit's time zone has no reader.** `sys_business_unit.timezone` (`packages/platform-objects/src/identity/sys-business-unit.object.ts#SysBusinessUnit`) states in its own help text that it changes no date calculation today. +- **A second source of truth already exists in the UI.** The gantt view declares its own `skipWeekends` and `holidays` (`ui/packages/types/src/zod/objectql.zod.ts#ObjectGanttSchema`). + +### The pull + +The hotcrm case SLA matrix counts wall-clock hours and warns about it in prose (the outcome of #13801). hotsrm computes delivery dates and deadlines in hooks and formulas. The production suite schedules against working days. In China, a fixed weekly pattern cannot express 调休: make-up working Saturdays and Sundays around public holidays. Without a platform calendar each suite computes due dates its own way, and the same request shows different due times in different apps. + +## Decision + +Each D-item records one item of the ruling, in the ruling's own terms. Where writing the item down met a choice the ruling does not make, the item says so and points to an [open question](#open-questions); it does not pick. + +### D1 — Calendars are organization-editable runtime data + +Calendars are org-editable runtime data, not package metadata. Two objects: + +- **`sys_work_calendar`**: the weekly pattern, its working periods per weekday written as local `HH:mm`, a required `timezone` in the `iana_time_zone` value domain, and `is_default`. +- **`sys_work_calendar_exception`**: dated `off` and `on` overrides of a calendar. One table holds public holidays, 调休 make-up workdays and plant shutdowns. + +Packages reference a calendar by code and may ship seed rows. One calendar service resolves a calendar and computes with it. The precedent is `sys_exchange_rate` (ADR-0144): organization-scoped rows, written by administrators, audited. + +A calendar is never package metadata: holidays change every year, and a metadata change travels through a publish. The weekly pattern sits on the calendar row and the exceptions in their own table, so a holiday is a row an administrator adds, not a release. + +Not ruled, and listed: how an exception's own periods combine with the weekly pattern on its date, and whether a date may carry two exceptions ([Q3](#q3--the-shape-of-an-exception-and-of-a-period)); and whether a package's seed rows may overwrite an organization's edits on a later install ([Q6](#q6--may-a-package-seed-overwrite-an-organizations-edit)). + +### D2 — Resolution: explicit code, then the organization default, then refuse + +A consumer resolves its calendar in this order, and in no other: + +1. the calendar code the consumer names explicitly (a formula argument, the escalation's `calendar` key); +2. the organization's default calendar (`is_default`); +3. otherwise, **refuse**. + +**There is no silent fallback to wall-clock time.** A deadline computed on the wrong clock looks exactly like a right one, so an unresolved calendar is an error with a stable code, as an unset home currency is (`ERR_HOME_CURRENCY_UNSET`, ADR-0144). The implementing card registers the code in the ADR-0112 ledger. + +**Business-unit inheritance is deferred.** `sys_business_unit.timezone` has no reader today; another inherited column nobody reads would be inert under ADR-0049. Regions and plants are not platform objects: a suite maps them to calendar codes and passes the code. + +Not ruled, and listed: what a refusal does inside the approval sweep, which has no caller to answer ([Q2](#q2--what-a-refusal-does-in-the-approval-sweep)). + +### D3 — Holiday data: entered or imported by the organization; a calendar says how far it is maintained + +In the first cut, holiday and make-up-day rows are entered by the organization or imported. **A calendar records the date it is "maintained through"**, and computing past that date warns or refuses: a calendar with no exceptions entered for next year must not read as "next year has no holidays". + +A CN holidays and 调休 data set comes later, as a marketplace data package. **It is never in platform core**, and the platform ships no per-country holiday data. + +Not ruled, and listed: whether crossing the maintained-through date warns or refuses, and whether the answer differs by consumer ([Q1](#q1--past-the-maintained-through-date-warn-or-refuse)). + +### D4 — First consumers: three formula functions and the approval clock, in the same release as the objects + +The first readers are the formula functions `addWorkingDays`, `workingDaysBetween` and `addWorkingHours`, and the approval escalation's working-time clock (D5). Each is its own card. **They ship in the same release as the objects**: the #13655 constraint stands, and the calendar never ships without its formula surface. A calendar object released alone would be the inert shape ADR-0049 forbids. + +How the pairing is held at release time follows the ADR-0144 D9 precedent (the epic PM's placement there, not that ruling's): each implementing pull request says it is not released alone and names its pair, and the maintainer merges Version Packages only when the set is complete (Prime Directive #15). + +Not decided here: the argument semantics of the three functions (whether an interval's ends count, what a start on a non-working day means). They are public formula contract, settled by #35356 under its own contract review and pinned by its tests. + +### D5 — The clock key: `escalation.clock`, default `wall_clock`, on `timeoutHours` only + +The approval escalation gains `clock: 'wall_clock' | 'working_time'` and an optional `calendar` code. + +- **The default stays `wall_clock`.** The sweep reads stored snapshots, and a stored snapshot carries no `clock`. Flipping the default would move the deadline of every request already open. +- **The value names avoid "calendar hours".** The current describe text uses "calendar hours" to mean wall-clock hours, and that phrase would read the other way once a working calendar exists. +- **Only `timeoutHours` gets the key now.** Every other duration key gets one only when a consumer reads it, one card each. No clock key is added to every duration key. +- **The describe text and code comment on `timeoutHours`** that say the platform ships no business-hours calendar are rewritten by #35357, with the generated schema, the reference docs and the skills teaching text. + +`working_time` resolves its calendar through D2: the `calendar` code if written, otherwise the organization default, otherwise refuse. + +Not ruled, and listed: whether a `working_time` deadline is computed once or recomputed on every sweep, so that a holiday entered later moves it ([Q5](#q5--is-a-working-time-deadline-fixed-or-recomputed)). + +### D6 — Pushdown: working-day functions evaluate in memory only + +Working-day functions evaluate in memory. **Pushdown refuses them**, as it refuses every function call today, and a lint tells the author so at authoring time. To filter on a due time, compute it at write time into a `datetime` column and compare that column with `{now}`. **No calendar math runs in SQL.** + +A refused filter fails loudly, at run time. The lint exists so an author learns this when writing the expression (a list filter, a row-level-security predicate), not when it is refused. + +### D7 — Time zone and periods + +- **`timezone` is required** on every calendar. Setup prefills it from the organization's effective time zone; the stored value is the calendar's own, and the computation reads only that value. One organization may run plants in different zones. +- **A period that crosses midnight is refused** in the first cut. A period's end is later than its start, on the same local day. Which day a night shift belongs to is rostering, and rostering is out of scope. + +Not ruled, and listed: whether a period may end at `24:00` ([Q3](#q3--the-shape-of-an-exception-and-of-a-period)), and how `addWorkingHours` counts a period on a daylight-saving transition day ([Q4](#q4--daylight-saving-days-in-addworkinghours)). + +## Enforcement + +| Decision | Enforced by | +|:--|:--| +| D1 objects, seed by code; D2 resolver and its refusal code; D3 maintained-through and import; D7 required time zone and the midnight refusal | [#35355](https://github.com/objectstack-ai/objectstack/issues/35355) — the two objects, the calendar service, the Setup page and the exception import | +| D4 formula functions; D6 pushdown refusal and lint | [#35356](https://github.com/objectstack-ai/objectstack/issues/35356) — `addWorkingDays`, `workingDaysBetween`, `addWorkingHours` | +| D4 approval clock; D5 the key, its default and the rewritten describe text | [#35357](https://github.com/objectstack-ai/objectstack/issues/35357) — `escalation.clock` and `escalation.calendar` | +| D4 the release pairing | all three, held as ADR-0144 D9 holds its pairs | + +Each implementing change leaves this record's id in its code at the load-bearing spots (Prime Directive #13). The acceptance slice after the three is the hotcrm case SLA matrix counting against a calendar. + +## Follow-ups + +- **The gantt view's own calendar.** The gantt view declares `skipWeekends` and `holidays` of its own (`ui/packages/types/src/zod/objectql.zod.ts#ObjectGanttSchema`), a second source of truth beside this record's calendar. Follow-up: switch the gantt view to the platform calendar. This record changes nothing there. +- **Later slices named by the ruling**: the CN holidays and 调休 data package (marketplace, D3); business-unit inheritance (D2, once a second consumer reads a business unit's calendar); date macros in filters. + +## Non-goals + +Shift rostering, finite-capacity scheduling, payroll calendars and fiscal periods. Per-country holiday data in platform core. Calendar arithmetic in SQL. A clock key on every duration key. Flipping the default clock. + +## Open questions + +The ruling does not answer these. Each is put to the maintainer through the owning seat; the implementing card that meets one does not pick an answer on its own. Each option says what it costs; the seat's recommendation follows. + +### Q1 — Past the maintained-through date: warn or refuse? + +The ruling says computing past the date "warns or refuses". + +- **A — refuse everywhere.** The calendar service answers a stable code for any computation whose result or range crosses the date. A formula evaluation fails; the approval sweep meets Q2. Strictest; a forgotten year-end import stops deadlines being computed at all. +- **B — warn everywhere.** The service computes with the weekly pattern alone past the date and logs a warning. Nothing stops; a deadline that crossed an unentered holiday is wrong and looks right. +- **C — refuse in formulas, warn in Setup ahead of time.** The service refuses as in A, and Setup shows a calendar whose date is near as needing maintenance, so an administrator sees it before the refusals start. + +Recommendation: **C**. It keeps D2's rule that no deadline is silently computed on the wrong clock, and turns the refusal into a notice an administrator meets first. + +### Q2 — What a refusal does in the approval sweep + +A formula can answer an error to its caller. The escalation sweep has no caller: when a `working_time` request's calendar does not resolve (D2) or the computation is refused (Q1), the sweep must still do something with the request. + +- **A — skip and report.** The sweep does not escalate the request, logs at error level with the code, and tries again on the next sweep. A request can sit past its true deadline until an administrator fixes the calendar. +- **B — also refuse at publish.** As A, and a flow whose escalation names a `calendar` code that does not resolve in the publishing organization is refused at publish. Catches the misspelled code early; cannot catch a calendar deleted after publish, so A is still needed. + +Recommendation: **B**. Wall-clock escalation is not an option under D2. + +### Q3 — The shape of an exception and of a period + +The ruling says "dated off/on overrides" with optional periods, and refuses periods crossing midnight. It does not say: + +- whether an `on` exception without periods is allowed, and whose hours it takes (a 调休 Saturday works a normal day, but the weekly pattern has no "normal day" field); +- whether an `off` exception may carry periods (a half-day holiday); +- whether one date may carry two exceptions; +- whether `24:00` is a legal period end. + +- **A — an exception's periods are the date's complete working periods.** `off` never carries periods and means the whole date is off. `on` must carry its periods. A half-day holiday is an `on` row with the shortened periods. One exception per calendar and date. `24:00` is legal as an end. Every stored row says exactly what its date works; a data package's make-up days get their hours from the import, which asks the administrator which weekday to copy. +- **B — `on` without periods copies a weekday.** As A, but an `on` row may name a weekday whose periods it takes. Shorter rows; one more column, and an edit to that weekday silently changes past make-up days. + +Recommendation: **A**. One rule a reader can check against the row alone. + +### Q4 — Daylight-saving days in `addWorkingHours` + +Periods are local `HH:mm`. On a transition day a local period can be an hour shorter or longer than its clock-face length. + +- **A — count elapsed time.** Map each local period to instants with the shared DST-safe primitive (ADR-0053) and count real elapsed time; a local time that does not exist moves forward. Matches how `wall_clock` already counts elapsed milliseconds. +- **B — count clock-face time.** A 09:00–17:00 period is always eight working hours. Simpler to explain; the result instant can land an hour away from the elapsed answer. + +Recommendation: **A**, with a pinned test on a spring-forward and a fall-back day. China has no daylight saving; the question matters for calendars elsewhere. + +### Q5 — Is a working-time deadline fixed or recomputed? + +#35357's Scope says the sweep recomputes the deadline from `created_at` on every sweep. The ruling does not say. + +- **A — recompute on every sweep.** A holiday entered after a request opened moves that request's deadline. Display and sweep call one function. The escalation's audit row records the deadline as computed when it fired. +- **B — fix at creation.** Store the deadline on the request when it opens. A later holiday does not move it; the stored value can be wrong for the rest of the request's life. + +Recommendation: **A**, as #35357 states. The same staleness question applies to the write-time `datetime` columns of D6: a column computed before a holiday was entered keeps its old value until the record is written again. That is the author's column, and teaching it belongs with #35356. + +### Q6 — May a package seed overwrite an organization's edit? + +Packages may seed calendar rows (D1), and the rows are organization-editable. The seed contract (`packages/spec/src/data/seed.zod.ts`) defaults to `mode: 'ignore'`, which inserts a missing row and leaves an existing one as it is; `upsert` overwrites on every replay. + +- **A — `ignore` only for calendar rows.** A package seeds a starting calendar; after the first load the organization owns it. +- **B — the package's choice.** A package may declare `upsert` to keep its rows current, and every replay then undoes the organization's edits to them. + +Recommendation: **A**. "Org-editable" means an install never takes an edit back. + +## Consequences + +- **Additive.** Two new objects and one optional key with an unchanged default. Every escalation stored today keeps its deadline. +- **A missing calendar is an error, not a wall-clock answer.** An organization that uses a working-time consumer must keep a default calendar, or name one at every consumer. +- **The calendar must be maintained.** The maintained-through date makes a stale calendar visible instead of quietly wrong; somebody enters next year's holidays every year until the data package exists. +- **A working-day deadline is not filterable unless stored.** Authors who need to filter or aggregate on a working-day due time compute it at write time into a `datetime` column. +- **Two calendars in the product until the gantt follow-up lands.** + +## References + +- Ruling [`7000950747`](https://github.com/objectstack-ai/objectstack/issues/35340#issuecomment-7000950747) on #35340; card #35354; implementing cards #35355, #35356, #35357. +- #13801 and its in-seat ruling `5506987580`; the #13655 freeze (ruling record 5478756633). +- ADR-0029, ADR-0049, ADR-0053, ADR-0112, ADR-0144. diff --git a/docs/adr/README.md b/docs/adr/README.md index cdbf9f4adc1..bc4689e567b 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -13,12 +13,12 @@ ## Summary -157 records under `docs/adr/` (152 numbers), 11 under `ui/docs/adr/` (listed separately below). +158 records under `docs/adr/` (153 numbers), 11 under `ui/docs/adr/` (listed separately below). | Status | Records | |---|---| | Accepted | 136 | -| Proposed | 7 | +| Proposed | 8 | | Superseded | 4 | | Draft | 3 | | Deferred | 2 | @@ -26,7 +26,7 @@ | Amended | 1 | | Partially implemented | 1 | | Revised | 1 | -| **Total** | **157** | +| **Total** | **158** | ## Shared numbers @@ -205,7 +205,7 @@ A bare `ADR-0006` names the decision; its current text is [0006-project-environm | [ADR-0133](./0133-org-management-open-basics.md) | Organization management — the open basics; a mirror of cloud ADR-0081 D1/D3/D4 in the repository whose code e… | Accepted — 2026-09-07 — accepted by the merge that landed it on `main` (#1… | 2026-09-07 | — | — | | [ADR-0134](./0134-env-side-scim-provisioning.md) | Env-side SCIM provisioning — `@better-auth/scim` is the mechanism, and this platform writes the deactivation | Proposed — 2026-09-07. This file is a MIRROR of the open, mechanism half of | 2026-09-07 | — | — | | [ADR-0135](./0135-identity-and-access-architecture.md) | Identity and access architecture — the open half, mirrored from cloud ADR-0024 | Accepted — The DECISION is — it is `objectstack-ai/cloud` ADR-0024, accept… | 2026-06-25 | — | — | -| [ADR-0137](./0137-predicate-fault-semantics-are-contract.md) | A predicate's FAULT semantics are part of the protocol — loud at submit, fail-open at render, and a blank pre… | Accepted — 2026-09-18 — this record declares; it implements nothing. D1's… | 2026-09-18 | — | — | +| [ADR-0137](./0137-predicate-fault-semantics-are-contract.md) | A predicate's FAULT semantics are part of the protocol — loud at submit, fail-open at render, and a blank pre… | Accepted — 2026-09-18; amended 2026-11-17 (a server row for a `required` f… | 2026-09-18 | — | — | | [ADR-0138](./0138-guest-model-anonymous-principal-doors-grants-and-organization.md) | The guest model — one anonymous principal, a closed list of doors, one grants channel, one organization rule,… | Accepted — 2026-10-13, accepted by the maintainer's approval of the pull r… | 2026-10-13 | — | — | | [ADR-0139](./0139-engine-internal-semi-join-leaf-readable-parent-ids.md) | One engine-internal semi-join leaf — "the ids of object X this caller may read" — pushed down by ObjectQL, ne… | Accepted — 2026-10-11, accepted by the merge that landed it on `main` | 2026-10-11 | — | — | | [ADR-0141](./0141-inter-app-dependency-declared-checked-before-install.md) | An app may depend on another installed app — declared in `manifest.dependencies`, checked once before install… | Proposed — 2026-10-25; first draft 2026-10-24. `docs/adr/` is Tier H (Prim… | 2026-10-25 | — | ADR-0146 | @@ -224,6 +224,7 @@ A bare `ADR-0006` names the decision; its current text is [0006-project-environm | [ADR-0154](./0154-audit-ledger-tamper-evidence-sealer-signed-checkpoints-amendments-verify.md) | The audit ledger is tamper-evident — an asynchronous sealer signs per-organization checkpoints, redaction and… | Proposed — 2026-11-10 — draft. This record declares; it implements nothing… | 2026-11-10 | — | — | | [ADR-0155](./0155-sharing-scope-share-grants-lower-to-an-engine-internal-semi-join-leaf.md) | The sharing scope's share-grant arm lowers to an engine-internal semi-join leaf over the record-share table,… | Accepted — 2026-11-17, recording the maintainer's answers to questions ①–③… | 2026-11-15 | — | — | | [ADR-0156](./0156-compiled-metadata-answer-cache-every-source-counts-its-own-changes.md) | A compiled metadata answer is cached only when every source it reads counts its own changes, and a bound cove… | Accepted — 2026-11-16 — maintainer ruling on #34206, comment 6920925378, v… | 2026-11-16 | — | — | +| [ADR-0157](./0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md) | Working calendars are organization-editable runtime data — a consumer names a calendar by code or takes the o… | Proposed — 2026-11-19. This record declares; it implements nothing — no sc… | 2026-11-19 | — | — | ## ObjectUI registry — `ui/docs/adr/` (`ui-` prefix) From 4479ee7086fd37957d3fae42eaccc87792459123 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 08:18:57 +0000 Subject: [PATCH 2/5] docs(adr): ADR-0157 records the rulings on its six open questions The maintainer ruled the six questions the first draft left open (records 7003541720 and 7003566086 on #35354). They become D8-D13: refuse past maintained-through with a Setup notice, the approval sweep skips and retries and shows why with a static-only publish lint, an exception row carries its full periods, elapsed-time counting on DST days through the shared primitive, recompute on every sweep, and the existing seed contract for calendar seeds. Two implementation points are left to the implementing cards' contract reviews. Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb Co-authored-by: Claude --- ...untime-data-resolved-by-code-or-refused.md | 126 +++++++++--------- docs/adr/README.md | 2 +- 2 files changed, 62 insertions(+), 66 deletions(-) diff --git a/docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md b/docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md index faaa82bf70e..d51aa75d7d8 100644 --- a/docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md +++ b/docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md @@ -1,10 +1,11 @@ # ADR-0157: Working calendars are organization-editable runtime data — a consumer names a calendar by code or takes the organization default, otherwise it refuses; formulas and the approval clock read it in the same release -**Status**: Proposed (2026-11-19). **This record declares; it implements nothing** — no schema, no object, no code, no changeset. Three cards implement it: [#35355](https://github.com/objectstack-ai/objectstack/issues/35355), [#35356](https://github.com/objectstack-ai/objectstack/issues/35356) and [#35357](https://github.com/objectstack-ai/objectstack/issues/35357). `docs/adr/**` is a Tier H governed surface (Prime Directive #14): the maintainer's merge adopts this record, and until then every decision below is a proposal. +**Status**: Proposed (2026-11-19; revised the same day to record the maintainer's rulings on the six questions the first draft left open, now D8–D13). **This record declares; it implements nothing** — no schema, no object, no code, no changeset. Three cards implement it: [#35355](https://github.com/objectstack-ai/objectstack/issues/35355), [#35356](https://github.com/objectstack-ai/objectstack/issues/35356) and [#35357](https://github.com/objectstack-ai/objectstack/issues/35357). `docs/adr/**` is a Tier H governed surface (Prime Directive #14): the maintainer's merge adopts this record, and until then every decision below is a proposal. - **Date**: 2026-11-19 - **Card**: [#35354](https://github.com/objectstack-ai/objectstack/issues/35354) (p1), the first slice of the epic [#35340](https://github.com/objectstack-ai/objectstack/issues/35340). - **Decided by**: the maintainer, 2026-11-19 05:47Z, on #35340, verbatim 「同意 p1」, recorded in ruling comment [`7000950747`](https://github.com/objectstack-ai/objectstack/issues/35340#issuecomment-7000950747). The sub-cards were approved at 06:03Z with 「同意」 and 「都是 p1」. The ruling's own text is the authority this record executes; where the two differ in words, the ruling wins and this record is corrected. +- **Open questions ruled**: the maintainer, 2026-11-19 08:11–08:13Z, on the seat's decision cards. Q1 and Q2 are recorded in ruling record [`7003541720`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003541720) (pick 「不算,并提前提醒」); Q3 to Q6 in ruling record [`7003566086`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003566086) (picks 「每条写全时段」 and 「全按推荐」). They are D8 to D13. - **Unfreezes**: the business-hours half of #13655 (ruling record 5478756633, cited from [#13801](https://github.com/objectstack-ai/objectstack/issues/13801); #13655 itself answers 404 to this session). That half was frozen until a named external user asked. The ruling counts the pull from the platform's own suites (the hotcrm case SLA matrix, hotsrm delivery dates, the production suite) as meeting that condition. The freeze's second constraint stands and is D4 here. - **Reverses**: the in-seat finding on #13801 (comment [`5506987580`](https://github.com/objectstack-ai/objectstack/issues/13801#issuecomment-5506987580)) that a clock marker on `timeoutHours` would be inert. That finding held only while one clock existed; with two clocks the marker has a reader (D5). - **Builds on**: [ADR-0144](./0144-multi-currency-record-currency-dated-rates-write-time-home-projection.md) (`sys_exchange_rate`: organization-scoped runtime data that an administrator writes and that every change audits — the precedent for D1, and `ERR_HOME_CURRENCY_UNSET`, the precedent for refusing rather than guessing in D2). [ADR-0049](./0049-no-unenforced-security-properties.md) (enforce-or-remove: a calendar nobody reads, an inherited column nobody reads and a clock key with one value are all inert — D2, D4, D5). [ADR-0029](./0029-kernel-object-ownership-and-platform-objects-decomposition.md) D1, D3 and D6 (a first-party capability owns its `sys_*` objects; which package owns the two objects here is #35355's to settle against it). [ADR-0053](./0053-date-and-datetime-semantics.md) (an exception's date is a calendar day, never an instant; time-zone arithmetic goes through the shared DST-safe primitive). [ADR-0112](./0112-error-code-vocabulary-and-ledger.md) (every refusal below answers with a ledger code that the implementing card registers). @@ -16,8 +17,8 @@ Three kinds of text feed this record, and each section says which kind it carries. -1. **Ruled.** The seven design points of ruling `7000950747`, restated as seven items in the Scope of #35354. [Decision](#decision) carries only these, one D-item per Scope item, in the ruling's own terms. -2. **Analysis the ruling read.** The design analysis for #35340 (project file `card-35340/design-analysis.md`, outside this repository). It supplies the context and the alternatives. A detail that appears only there is not ruled: this record lists such details under [Open questions](#open-questions), never as a decision. +1. **Ruled.** The seven design points of ruling `7000950747`, restated as seven items in the Scope of #35354. [Decision](#decision) carries only these, one D-item per Scope item (D1–D7), in the ruling's own terms, and the maintainer's rulings on the six questions the first draft left open (D8–D13), records `7003541720` and `7003566086` on #35354. +2. **Analysis the ruling read.** The design analysis for #35340 (project file `card-35340/design-analysis.md`, outside this repository). It supplies the context and the alternatives. A detail that appears only there is not ruled: this record lists such details as [open implementation points](#open-implementation-points), never as a decision. The seat's decision analysis of the six questions (project file `objectstack-seat5/area-ux/data-1/decision-adr0157-q1-q6.md`) is text of this kind too: D8–D13 carry only what the two ruling records say. 3. **Readings.** Current behaviour, read on `objectstack-ai/objectstack` at `3819afec` (2026-11-19) and cited by symbol anchor (`path#symbol`). Nothing below was run. ## Context @@ -38,7 +39,7 @@ The hotcrm case SLA matrix counts wall-clock hours and warns about it in prose ( ## Decision -Each D-item records one item of the ruling, in the ruling's own terms. Where writing the item down met a choice the ruling does not make, the item says so and points to an [open question](#open-questions); it does not pick. +Each D-item records one item of the ruling, in the ruling's own terms. Where writing an item down met a choice the first ruling did not make, the choice went to the maintainer as an open question; D8–D13 record those rulings, and each of D1–D7 names the D-item that completes it. ### D1 — Calendars are organization-editable runtime data @@ -51,7 +52,7 @@ Packages reference a calendar by code and may ship seed rows. One calendar servi A calendar is never package metadata: holidays change every year, and a metadata change travels through a publish. The weekly pattern sits on the calendar row and the exceptions in their own table, so a holiday is a row an administrator adds, not a release. -Not ruled, and listed: how an exception's own periods combine with the weekly pattern on its date, and whether a date may carry two exceptions ([Q3](#q3--the-shape-of-an-exception-and-of-a-period)); and whether a package's seed rows may overwrite an organization's edits on a later install ([Q6](#q6--may-a-package-seed-overwrite-an-organizations-edit)). +Completed by D10 (an exception row carries its date's full working periods, one row per date) and D13 (package seed rows follow the existing seed contract). ### D2 — Resolution: explicit code, then the organization default, then refuse @@ -65,7 +66,7 @@ A consumer resolves its calendar in this order, and in no other: **Business-unit inheritance is deferred.** `sys_business_unit.timezone` has no reader today; another inherited column nobody reads would be inert under ADR-0049. Regions and plants are not platform objects: a suite maps them to calendar codes and passes the code. -Not ruled, and listed: what a refusal does inside the approval sweep, which has no caller to answer ([Q2](#q2--what-a-refusal-does-in-the-approval-sweep)). +Completed by D9 (what a refusal does inside the approval sweep, which has no caller to answer). ### D3 — Holiday data: entered or imported by the organization; a calendar says how far it is maintained @@ -73,7 +74,7 @@ In the first cut, holiday and make-up-day rows are entered by the organization o A CN holidays and 调休 data set comes later, as a marketplace data package. **It is never in platform core**, and the platform ships no per-country holiday data. -Not ruled, and listed: whether crossing the maintained-through date warns or refuses, and whether the answer differs by consumer ([Q1](#q1--past-the-maintained-through-date-warn-or-refuse)). +Completed by D8 (crossing the maintained-through date refuses, and Setup gives notice ahead of time). ### D4 — First consumers: three formula functions and the approval clock, in the same release as the objects @@ -94,7 +95,7 @@ The approval escalation gains `clock: 'wall_clock' | 'working_time'` and an opti `working_time` resolves its calendar through D2: the `calendar` code if written, otherwise the organization default, otherwise refuse. -Not ruled, and listed: whether a `working_time` deadline is computed once or recomputed on every sweep, so that a holiday entered later moves it ([Q5](#q5--is-a-working-time-deadline-fixed-or-recomputed)). +Completed by D9 (the sweep when the due time cannot be computed) and D12 (the `working_time` deadline is recomputed on every sweep). ### D6 — Pushdown: working-day functions evaluate in memory only @@ -107,91 +108,83 @@ A refused filter fails loudly, at run time. The lint exists so an author learns - **`timezone` is required** on every calendar. Setup prefills it from the organization's effective time zone; the stored value is the calendar's own, and the computation reads only that value. One organization may run plants in different zones. - **A period that crosses midnight is refused** in the first cut. A period's end is later than its start, on the same local day. Which day a night shift belongs to is rostering, and rostering is out of scope. -Not ruled, and listed: whether a period may end at `24:00` ([Q3](#q3--the-shape-of-an-exception-and-of-a-period)), and how `addWorkingHours` counts a period on a daylight-saving transition day ([Q4](#q4--daylight-saving-days-in-addworkinghours)). +Completed by D10 (`24:00` is a legal period end) and D11 (a daylight-saving transition day counts elapsed time). -## Enforcement - -| Decision | Enforced by | -|:--|:--| -| D1 objects, seed by code; D2 resolver and its refusal code; D3 maintained-through and import; D7 required time zone and the midnight refusal | [#35355](https://github.com/objectstack-ai/objectstack/issues/35355) — the two objects, the calendar service, the Setup page and the exception import | -| D4 formula functions; D6 pushdown refusal and lint | [#35356](https://github.com/objectstack-ai/objectstack/issues/35356) — `addWorkingDays`, `workingDaysBetween`, `addWorkingHours` | -| D4 approval clock; D5 the key, its default and the rewritten describe text | [#35357](https://github.com/objectstack-ai/objectstack/issues/35357) — `escalation.clock` and `escalation.calendar` | -| D4 the release pairing | all three, held as ADR-0144 D9 holds its pairs | - -Each implementing change leaves this record's id in its code at the load-bearing spots (Prime Directive #13). The acceptance slice after the three is the hotcrm case SLA matrix counting against a calendar. - -## Follow-ups - -- **The gantt view's own calendar.** The gantt view declares `skipWeekends` and `holidays` of its own (`ui/packages/types/src/zod/objectql.zod.ts#ObjectGanttSchema`), a second source of truth beside this record's calendar. Follow-up: switch the gantt view to the platform calendar. This record changes nothing there. -- **Later slices named by the ruling**: the CN holidays and 调休 data package (marketplace, D3); business-unit inheritance (D2, once a second consumer reads a business unit's calendar); date macros in filters. - -## Non-goals - -Shift rostering, finite-capacity scheduling, payroll calendars and fiscal periods. Per-country holiday data in platform core. Calendar arithmetic in SQL. A clock key on every duration key. Flipping the default clock. +### D8 — Past the maintained-through date: refuse, and give notice ahead of time (Q1 = C) -## Open questions +Ruled in record [`7003541720`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003541720), Q1 letter C. -The ruling does not answer these. Each is put to the maintainer through the owning seat; the implementing card that meets one does not pick an answer on its own. Each option says what it costs; the seat's recommendation follows. +- **A computation whose result or span crosses a calendar's maintained-through date is refused**, with a stable code. There is no fallback to the weekly pattern alone, and none to wall-clock time (D2). +- **Setup gives notice ahead of time**: it marks a calendar whose maintained-through date is near as needing maintenance, before refusals start. How far ahead is #35355's default. +- **A formula due date that meets the refusal is blank**, never a guess from the weekly pattern. On a read this is what a failed formula evaluation already looks like: the field reads blank and the engine logs one line naming the object, the field and the error (`packages/objectql/src/engine-formula-fault-log.test.ts`). The customer sees a blank cell, not an error page. Precedent: a missing exchange rate refuses and stores no fallback value (ADR-0144 D5). +- **A write-time computed due-date column (D6) that meets the refusal** is not settled here; see [Open implementation points](#open-implementation-points). -### Q1 — Past the maintained-through date: warn or refuse? +### D9 — The approval sweep skips, retries and shows why; the publish-time lint checks static errors only (Q2 = C) -The ruling says computing past the date "warns or refuses". +Ruled in record [`7003541720`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003541720), Q2 letter C. -- **A — refuse everywhere.** The calendar service answers a stable code for any computation whose result or range crosses the date. A formula evaluation fails; the approval sweep meets Q2. Strictest; a forgotten year-end import stops deadlines being computed at all. -- **B — warn everywhere.** The service computes with the weekly pattern alone past the date and logs a warning. Nothing stops; a deadline that crossed an unentered holiday is wrong and looks right. -- **C — refuse in formulas, warn in Setup ahead of time.** The service refuses as in A, and Setup shows a calendar whose date is near as needing maintenance, so an administrator sees it before the refusals start. +- **When the sweep cannot compute a `working_time` due time** (no calendar resolves under D2, or D8 refuses the computation), it does not escalate the request and tries again on the next sweep. Once an administrator fixes the calendar, the next sweep recovers with no other step. +- **Where the due time is displayed, it shows 「日历算不出」 with the reason**: the calendar was not found, or it is not maintained to that date. +- **The publish-time check covers static authoring errors only**, such as a `calendar` code written without `clock: 'working_time'`. It does not check whether the named calendar exists: calendars are per-organization runtime data, and the approval lint is a pure function of the stack (`packages/lint/src/validate-approval-approvers.ts`). #35357's Scope sentence that a `working_time` escalation with no resolvable calendar "is a lint/validation error" is read under this decision. +- Not chosen: skip and log only (A); a publish-time check that the calendar exists (B). Refusing at submit time was not offered: together with D8 it would block every approval whose deadline crosses the year end until the next year's holidays are entered. -Recommendation: **C**. It keeps D2's rule that no deadline is silently computed on the wrong clock, and turns the refusal into a notice an administrator meets first. +### D10 — An exception row carries its date's full working periods (Q3 = A) -### Q2 — What a refusal does in the approval sweep +Ruled in record [`7003566086`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003566086), pick 「每条写全时段」, Q3 letter A. -A formula can answer an error to its caller. The escalation sweep has no caller: when a `working_time` request's calendar does not resolve (D2) or the computation is refused (Q1), the sweep must still do something with the request. +- **An `off` row has no periods** and means the whole date is off. +- **An `on` row must carry that date's full working periods.** A half day is an `on` row with shortened periods. An `on` row never borrows a weekday's periods: with borrowing, a later edit to that weekday would silently rewrite past make-up days. +- **One row per calendar and date.** +- **`24:00` is a legal period end**, validated by the calendar itself, because the platform's time parser refuses a zone-naive `24:00` (`packages/core/src/utils/import-coerce.ts`). A period's end is later than its start (D7). -- **A — skip and report.** The sweep does not escalate the request, logs at error level with the code, and tries again on the next sweep. A request can sit past its true deadline until an administrator fixes the calendar. -- **B — also refuse at publish.** As A, and a flow whose escalation names a `calendar` code that does not resolve in the publishing organization is refused at publish. Catches the misspelled code early; cannot catch a calendar deleted after publish, so A is still needed. +### D11 — A daylight-saving transition day counts elapsed time (Q4 = A) -Recommendation: **B**. Wall-clock escalation is not an option under D2. +Ruled in record [`7003566086`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003566086), pick 「全按推荐」, Q4 letter A. -### Q3 — The shape of an exception and of a period +- **Working hours are counted as elapsed time.** Each local period is mapped to instants and its real duration counted, as `wall_clock` counts elapsed milliseconds. On a transition day a period can be an hour shorter or longer than its clock-face length. +- **Local times convert to instants only through the shared DST-safe primitive** (ADR-0053). A local time the zone skips, or one it passes twice, resolves the way that primitive already does and pins in its tests, to the earlier candidate instant (`packages/core/src/utils/datetime.ts#zonedWallClockToUtcMs`). Working calendars add no rule of their own. +- China has no daylight saving; only calendars whose periods cover a transition hour see a difference. -The ruling says "dated off/on overrides" with optional periods, and refuses periods crossing midnight. It does not say: +### D12 — A working-time deadline is recomputed on every sweep (Q5 = A) -- whether an `on` exception without periods is allowed, and whose hours it takes (a 调休 Saturday works a normal day, but the weekly pattern has no "normal day" field); -- whether an `off` exception may carry periods (a half-day holiday); -- whether one date may carry two exceptions; -- whether `24:00` is a legal period end. +Ruled in record [`7003566086`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003566086), Q5 letter A. It is the approved Scope of #35357: "recompute each sweep rather than storing it". -- **A — an exception's periods are the date's complete working periods.** `off` never carries periods and means the whole date is off. `on` must carry its periods. A half-day holiday is an `on` row with the shortened periods. One exception per calendar and date. `24:00` is legal as an end. Every stored row says exactly what its date works; a data package's make-up days get their hours from the import, which asks the administrator which weekday to copy. -- **B — `on` without periods copies a weekday.** As A, but an `on` row may name a weekday whose periods it takes. Shorter rows; one more column, and an edit to that weekday silently changes past make-up days. +- **The `working_time` due time is recomputed from `created_at` on every sweep and never stored.** A holiday entered after a request opened moves that request's deadline. The displayed due time and the sweep use one function, as the wall-clock due time does today (`packages/plugins/plugin-approvals/src/approval-service.ts#slaDueAt`). +- Escalation stays single-shot: a request already escalated is not escalated again, or recalled, when its calendar changes. -Recommendation: **A**. One rule a reader can check against the row alone. +### D13 — Calendar seed rows follow the existing seed contract (Q6) -### Q4 — Daylight-saving days in `addWorkingHours` +Ruled in record [`7003566086`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003566086), pick 「全按推荐」: no new rule. -Periods are local `HH:mm`. On a transition day a local period can be an hour shorter or longer than its clock-face length. +- **No calendar-specific seeding rule.** The seed contract stands as ruled in record `6631016988` on #30081 (`packages/spec/src/data/seed.zod.ts`): a seed is create-only by default, so an organization's edits survive a replay, and a row is overwritten only when the package declares `mode: 'upsert'`. +- Whether the later CN holidays data package declares `upsert`, to correct rows it has already landed, is that package's card to decide with its real data. -- **A — count elapsed time.** Map each local period to instants with the shared DST-safe primitive (ADR-0053) and count real elapsed time; a local time that does not exist moves forward. Matches how `wall_clock` already counts elapsed milliseconds. -- **B — count clock-face time.** A 09:00–17:00 period is always eight working hours. Simpler to explain; the result instant can land an hour away from the elapsed answer. +## Enforcement -Recommendation: **A**, with a pinned test on a spring-forward and a fall-back day. China has no daylight saving; the question matters for calendars elsewhere. +| Decision | Enforced by | +|:--|:--| +| D1 objects, seed by code; D2 resolver and its refusal code; D3 maintained-through and import; D7 required time zone and the midnight refusal; D8 the refusal past maintained-through and the Setup notice; D10 the exception row shape and period validation; D13 seeding under the existing seed contract | [#35355](https://github.com/objectstack-ai/objectstack/issues/35355) — the two objects, the calendar service, the Setup page and the exception import | +| D4 formula functions; D6 pushdown refusal and lint; D8 a refused formula due date reads blank; D11 elapsed counting, with pinned spring-forward and fall-back tests; open implementation point 1 | [#35356](https://github.com/objectstack-ai/objectstack/issues/35356) — `addWorkingDays`, `workingDaysBetween`, `addWorkingHours` | +| D4 approval clock; D5 the key, its default and the rewritten describe text; D9 skip, retry, the displayed reason and the static-only lint; D11 elapsed counting; D12 recompute on every sweep | [#35357](https://github.com/objectstack-ai/objectstack/issues/35357) — `escalation.clock` and `escalation.calendar` | +| D4 the release pairing | all three, held as ADR-0144 D9 holds its pairs | -### Q5 — Is a working-time deadline fixed or recomputed? +Each implementing change leaves this record's id in its code at the load-bearing spots (Prime Directive #13). The acceptance slice after the three is the hotcrm case SLA matrix counting against a calendar. -#35357's Scope says the sweep recomputes the deadline from `created_at` on every sweep. The ruling does not say. +## Follow-ups -- **A — recompute on every sweep.** A holiday entered after a request opened moves that request's deadline. Display and sweep call one function. The escalation's audit row records the deadline as computed when it fired. -- **B — fix at creation.** Store the deadline on the request when it opens. A later holiday does not move it; the stored value can be wrong for the rest of the request's life. +- **The gantt view's own calendar.** The gantt view declares `skipWeekends` and `holidays` of its own (`ui/packages/types/src/zod/objectql.zod.ts#ObjectGanttSchema`), a second source of truth beside this record's calendar. Follow-up: switch the gantt view to the platform calendar. This record changes nothing there. +- **Later slices named by the ruling**: the CN holidays and 调休 data package (marketplace, D3); business-unit inheritance (D2, once a second consumer reads a business unit's calendar); date macros in filters. -Recommendation: **A**, as #35357 states. The same staleness question applies to the write-time `datetime` columns of D6: a column computed before a holiday was entered keeps its old value until the record is written again. That is the author's column, and teaching it belongs with #35356. +## Non-goals -### Q6 — May a package seed overwrite an organization's edit? +Shift rostering, finite-capacity scheduling, payroll calendars and fiscal periods. Per-country holiday data in platform core. Calendar arithmetic in SQL. A clock key on every duration key. Flipping the default clock. -Packages may seed calendar rows (D1), and the rows are organization-editable. The seed contract (`packages/spec/src/data/seed.zod.ts`) defaults to `mode: 'ignore'`, which inserts a missing row and leaves an existing one as it is; `upsert` overwrites on every replay. +## Open implementation points -- **A — `ignore` only for calendar rows.** A package seeds a starting calendar; after the first load the organization owns it. -- **B — the package's choice.** A package may declare `upsert` to keep its rows current, and every replay then undoes the organization's edits to them. +The maintainer ruled every open question of the first draft (D8–D13). Two implementation points remain. Neither is a maintainer question: the card named settles each under its own contract review, and this record does not decide them. -Recommendation: **A**. "Org-editable" means an install never takes an edit back. +1. **A write-time computed due-date column that meets a D8 refusal** (#35356's contract review): the write fails, or the column is stored blank. A formula read is already settled by D8: blank, plus one log line, not an error. +2. **A blank maintained-through date** (#35355): whether the field is required, and what a blank means. Under D3 a blank must not read as "no holidays from here on". ## Consequences @@ -199,10 +192,13 @@ Recommendation: **A**. "Org-editable" means an install never takes an edit back. - **A missing calendar is an error, not a wall-clock answer.** An organization that uses a working-time consumer must keep a default calendar, or name one at every consumer. - **The calendar must be maintained.** The maintained-through date makes a stale calendar visible instead of quietly wrong; somebody enters next year's holidays every year until the data package exists. - **A working-day deadline is not filterable unless stored.** Authors who need to filter or aggregate on a working-day due time compute it at write time into a `datetime` column. +- **An unmaintained calendar blanks deadlines.** From the day a deadline's span crosses the maintained-through date, formula due dates read blank and working-time escalations wait with 「日历算不出」 until an administrator extends the calendar (D8, D9). The longer a suite's typical span, the earlier in the year this starts; the Setup notice exists for it. +- **Calendar edits move open deadlines.** Under D12 a holiday added later pushes an open request's deadline out, and a holiday removed or a period lengthened brings it in, so the next sweep may escalate several requests at once. - **Two calendars in the product until the gantt follow-up lands.** ## References - Ruling [`7000950747`](https://github.com/objectstack-ai/objectstack/issues/35340#issuecomment-7000950747) on #35340; card #35354; implementing cards #35355, #35356, #35357. +- Ruling records [`7003541720`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003541720) (Q1, Q2) and [`7003566086`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003566086) (Q3–Q6) on #35354; the seed contract ruling `6631016988` on #30081. - #13801 and its in-seat ruling `5506987580`; the #13655 freeze (ruling record 5478756633). - ADR-0029, ADR-0049, ADR-0053, ADR-0112, ADR-0144. diff --git a/docs/adr/README.md b/docs/adr/README.md index bc4689e567b..1e8139f77b8 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -224,7 +224,7 @@ A bare `ADR-0006` names the decision; its current text is [0006-project-environm | [ADR-0154](./0154-audit-ledger-tamper-evidence-sealer-signed-checkpoints-amendments-verify.md) | The audit ledger is tamper-evident — an asynchronous sealer signs per-organization checkpoints, redaction and… | Proposed — 2026-11-10 — draft. This record declares; it implements nothing… | 2026-11-10 | — | — | | [ADR-0155](./0155-sharing-scope-share-grants-lower-to-an-engine-internal-semi-join-leaf.md) | The sharing scope's share-grant arm lowers to an engine-internal semi-join leaf over the record-share table,… | Accepted — 2026-11-17, recording the maintainer's answers to questions ①–③… | 2026-11-15 | — | — | | [ADR-0156](./0156-compiled-metadata-answer-cache-every-source-counts-its-own-changes.md) | A compiled metadata answer is cached only when every source it reads counts its own changes, and a bound cove… | Accepted — 2026-11-16 — maintainer ruling on #34206, comment 6920925378, v… | 2026-11-16 | — | — | -| [ADR-0157](./0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md) | Working calendars are organization-editable runtime data — a consumer names a calendar by code or takes the o… | Proposed — 2026-11-19. This record declares; it implements nothing — no sc… | 2026-11-19 | — | — | +| [ADR-0157](./0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md) | Working calendars are organization-editable runtime data — a consumer names a calendar by code or takes the o… | Proposed — 2026-11-19; revised the same day to record the maintainer's rul… | 2026-11-19 | — | — | ## ObjectUI registry — `ui/docs/adr/` (`ui-` prefix) From d49d37da8ea962e9679d43fe0c8fe2ea068b8735 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 08:38:48 +0000 Subject: [PATCH 3/5] docs(adr): ADR-0157 D12 marks single-shot escalation as current behaviour The single-shot bullet is today's behaviour, not a ruling; it now says so and anchors the sweep's guard by symbol. Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb Co-authored-by: Claude --- ...are-org-editable-runtime-data-resolved-by-code-or-refused.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md b/docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md index d51aa75d7d8..68acc1cb6f0 100644 --- a/docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md +++ b/docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md @@ -150,7 +150,7 @@ Ruled in record [`7003566086`](https://github.com/objectstack-ai/objectstack/iss Ruled in record [`7003566086`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003566086), Q5 letter A. It is the approved Scope of #35357: "recompute each sweep rather than storing it". - **The `working_time` due time is recomputed from `created_at` on every sweep and never stored.** A holiday entered after a request opened moves that request's deadline. The displayed due time and the sweep use one function, as the wall-clock due time does today (`packages/plugins/plugin-approvals/src/approval-service.ts#slaDueAt`). -- Escalation stays single-shot: a request already escalated is not escalated again, or recalled, when its calendar changes. +- Current behaviour, not a ruling: escalation stays single-shot, as today. A request already escalated is not escalated again, or recalled, when its calendar changes: the sweep skips any request that already carries an `escalate` action (`packages/plugins/plugin-approvals/src/approval-service.ts#ApprovalService.runEscalations`). ### D13 — Calendar seed rows follow the existing seed contract (Q6) From 80b83422b6dcf9f9954721191ed4faaccd4105da Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 08:44:55 +0000 Subject: [PATCH 4/5] docs(adr): ADR-0157 status Accepted on the maintainer's rulings The Status line now reads Accepted (2026-11-19), citing ruling 7000950747 on #35340 and ruling records 7003541720 and 7003566086 on #35354, in the shape of ADR-0156. The ADR index is regenerated. Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb Co-authored-by: Claude --- ...org-editable-runtime-data-resolved-by-code-or-refused.md | 2 +- docs/adr/README.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md b/docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md index 68acc1cb6f0..306b75da298 100644 --- a/docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md +++ b/docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md @@ -1,6 +1,6 @@ # ADR-0157: Working calendars are organization-editable runtime data — a consumer names a calendar by code or takes the organization default, otherwise it refuses; formulas and the approval clock read it in the same release -**Status**: Proposed (2026-11-19; revised the same day to record the maintainer's rulings on the six questions the first draft left open, now D8–D13). **This record declares; it implements nothing** — no schema, no object, no code, no changeset. Three cards implement it: [#35355](https://github.com/objectstack-ai/objectstack/issues/35355), [#35356](https://github.com/objectstack-ai/objectstack/issues/35356) and [#35357](https://github.com/objectstack-ai/objectstack/issues/35357). `docs/adr/**` is a Tier H governed surface (Prime Directive #14): the maintainer's merge adopts this record, and until then every decision below is a proposal. +**Status**: Accepted (2026-11-19) — maintainer ruling on [#35340](https://github.com/objectstack-ai/objectstack/issues/35340), comment [`7000950747`](https://github.com/objectstack-ai/objectstack/issues/35340#issuecomment-7000950747), verbatim 「同意 p1」 (D1–D7), and the maintainer's rulings on the six questions the first draft left open (D8–D13): ruling record [`7003541720`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003541720) on [#35354](https://github.com/objectstack-ai/objectstack/issues/35354) for Q1 and Q2, 「不算,并提前提醒」, and ruling record [`7003566086`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003566086) on #35354 for Q3 to Q6, 「每条写全时段」 and 「全按推荐」. `docs/adr/**` is Tier H (Prime Directive #14): this record lands by an authorised approval and the maintainer's merge. **This record declares; it implements nothing** — no schema, no object, no code, no changeset. Three cards implement it: [#35355](https://github.com/objectstack-ai/objectstack/issues/35355), [#35356](https://github.com/objectstack-ai/objectstack/issues/35356) and [#35357](https://github.com/objectstack-ai/objectstack/issues/35357). - **Date**: 2026-11-19 - **Card**: [#35354](https://github.com/objectstack-ai/objectstack/issues/35354) (p1), the first slice of the epic [#35340](https://github.com/objectstack-ai/objectstack/issues/35340). diff --git a/docs/adr/README.md b/docs/adr/README.md index 1e8139f77b8..482f3afd8b8 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -17,8 +17,8 @@ | Status | Records | |---|---| -| Accepted | 136 | -| Proposed | 8 | +| Accepted | 137 | +| Proposed | 7 | | Superseded | 4 | | Draft | 3 | | Deferred | 2 | @@ -224,7 +224,7 @@ A bare `ADR-0006` names the decision; its current text is [0006-project-environm | [ADR-0154](./0154-audit-ledger-tamper-evidence-sealer-signed-checkpoints-amendments-verify.md) | The audit ledger is tamper-evident — an asynchronous sealer signs per-organization checkpoints, redaction and… | Proposed — 2026-11-10 — draft. This record declares; it implements nothing… | 2026-11-10 | — | — | | [ADR-0155](./0155-sharing-scope-share-grants-lower-to-an-engine-internal-semi-join-leaf.md) | The sharing scope's share-grant arm lowers to an engine-internal semi-join leaf over the record-share table,… | Accepted — 2026-11-17, recording the maintainer's answers to questions ①–③… | 2026-11-15 | — | — | | [ADR-0156](./0156-compiled-metadata-answer-cache-every-source-counts-its-own-changes.md) | A compiled metadata answer is cached only when every source it reads counts its own changes, and a bound cove… | Accepted — 2026-11-16 — maintainer ruling on #34206, comment 6920925378, v… | 2026-11-16 | — | — | -| [ADR-0157](./0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md) | Working calendars are organization-editable runtime data — a consumer names a calendar by code or takes the o… | Proposed — 2026-11-19; revised the same day to record the maintainer's rul… | 2026-11-19 | — | — | +| [ADR-0157](./0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md) | Working calendars are organization-editable runtime data — a consumer names a calendar by code or takes the o… | Accepted — 2026-11-19 — maintainer ruling on #35340, comment `7000950747`,… | 2026-11-19 | — | — | ## ObjectUI registry — `ui/docs/adr/` (`ui-` prefix) From aeac9a1280e28eead8cc1ccbd523d8fd78c8376f Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 09:33:51 +0000 Subject: [PATCH 5/5] docs(adr): ADR-0157 names ADR-0042, lists the DST-primitive placement, prose nits S1: cite ADR-0042 in Builds on and References, say what stands of its section 3 under working_time, call D12's single-shot bullet ADR-0042 section 1, and add a dated pointer note on ADR-0042. S2: open implementation point 3, where the working-time arithmetic and zone conversion live so formula keeps one DST rule. Prose nits N1-N8 from the contract review. Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb Co-authored-by: Claude --- docs/adr/0042-approval-sla-escalation.md | 2 ++ ...untime-data-resolved-by-code-or-refused.md | 34 +++++++++++-------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/docs/adr/0042-approval-sla-escalation.md b/docs/adr/0042-approval-sla-escalation.md index 1afa238c0e1..691ea9d7d5f 100644 --- a/docs/adr/0042-approval-sla-escalation.md +++ b/docs/adr/0042-approval-sla-escalation.md @@ -100,6 +100,8 @@ would require per-request clock bookkeeping (schema change) and is exactly the kind of speculative state this ADR avoids; it gets built when a real tenant asks. +> **Note (2026-11-19) — a second clock.** [ADR-0157](./0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md) D5 adds `escalation.clock: 'working_time'` beside the default `wall_clock`: the deadline still runs from `created_at` and does not pause, and only how the hours are counted changes; its D9 says what the sweep does when a working-time deadline cannot be computed, and its D12 recomputes that deadline on every sweep while §1's single-shot rule stands. + ## Mechanics - **Wiring**: `ApprovalsServicePlugin.start()` resolves the `job` service diff --git a/docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md b/docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md index 306b75da298..59fddbb8460 100644 --- a/docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md +++ b/docs/adr/0157-working-calendars-are-org-editable-runtime-data-resolved-by-code-or-refused.md @@ -1,15 +1,15 @@ # ADR-0157: Working calendars are organization-editable runtime data — a consumer names a calendar by code or takes the organization default, otherwise it refuses; formulas and the approval clock read it in the same release -**Status**: Accepted (2026-11-19) — maintainer ruling on [#35340](https://github.com/objectstack-ai/objectstack/issues/35340), comment [`7000950747`](https://github.com/objectstack-ai/objectstack/issues/35340#issuecomment-7000950747), verbatim 「同意 p1」 (D1–D7), and the maintainer's rulings on the six questions the first draft left open (D8–D13): ruling record [`7003541720`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003541720) on [#35354](https://github.com/objectstack-ai/objectstack/issues/35354) for Q1 and Q2, 「不算,并提前提醒」, and ruling record [`7003566086`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003566086) on #35354 for Q3 to Q6, 「每条写全时段」 and 「全按推荐」. `docs/adr/**` is Tier H (Prime Directive #14): this record lands by an authorised approval and the maintainer's merge. **This record declares; it implements nothing** — no schema, no object, no code, no changeset. Three cards implement it: [#35355](https://github.com/objectstack-ai/objectstack/issues/35355), [#35356](https://github.com/objectstack-ai/objectstack/issues/35356) and [#35357](https://github.com/objectstack-ai/objectstack/issues/35357). +**Status**: Accepted (2026-11-19) — maintainer ruling on [#35340](https://github.com/objectstack-ai/objectstack/issues/35340), comment [`7000950747`](https://github.com/objectstack-ai/objectstack/issues/35340#issuecomment-7000950747), verbatim 「同意 p1」 (D1–D7), and the maintainer's rulings on the six questions the first draft left open (D8–D13): ruling record [`7003541720`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003541720) on [#35354](https://github.com/objectstack-ai/objectstack/issues/35354) for Q1 and Q2, 「不算,并提前提醒」, and ruling record [`7003566086`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003566086) on #35354 for Q3 to Q6, 「每条写全时段」 and 「全按推荐」. `docs/adr/**` is Tier H (Prime Directive #14): this record lands by the maintainer's merge or enqueue, or by an authorised approval. **This record declares; it implements nothing** — no schema, no object, no code, no changeset. Three cards implement it: [#35355](https://github.com/objectstack-ai/objectstack/issues/35355), [#35356](https://github.com/objectstack-ai/objectstack/issues/35356) and [#35357](https://github.com/objectstack-ai/objectstack/issues/35357). - **Date**: 2026-11-19 - **Card**: [#35354](https://github.com/objectstack-ai/objectstack/issues/35354) (p1), the first slice of the epic [#35340](https://github.com/objectstack-ai/objectstack/issues/35340). - **Decided by**: the maintainer, 2026-11-19 05:47Z, on #35340, verbatim 「同意 p1」, recorded in ruling comment [`7000950747`](https://github.com/objectstack-ai/objectstack/issues/35340#issuecomment-7000950747). The sub-cards were approved at 06:03Z with 「同意」 and 「都是 p1」. The ruling's own text is the authority this record executes; where the two differ in words, the ruling wins and this record is corrected. -- **Open questions ruled**: the maintainer, 2026-11-19 08:11–08:13Z, on the seat's decision cards. Q1 and Q2 are recorded in ruling record [`7003541720`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003541720) (pick 「不算,并提前提醒」); Q3 to Q6 in ruling record [`7003566086`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003566086) (picks 「每条写全时段」 and 「全按推荐」). They are D8 to D13. -- **Unfreezes**: the business-hours half of #13655 (ruling record 5478756633, cited from [#13801](https://github.com/objectstack-ai/objectstack/issues/13801); #13655 itself answers 404 to this session). That half was frozen until a named external user asked. The ruling counts the pull from the platform's own suites (the hotcrm case SLA matrix, hotsrm delivery dates, the production suite) as meeting that condition. The freeze's second constraint stands and is D4 here. +- **Open questions ruled**: the maintainer, 2026-11-19 08:11–08:12Z, on the seat's decision cards. Q1 and Q2 are recorded in ruling record [`7003541720`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003541720) (pick 「不算,并提前提醒」); Q3 to Q6 in ruling record [`7003566086`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003566086) (picks 「每条写全时段」 and 「全按推荐」). They are D8 to D13. +- **Unfreezes**: the business-hours half of #13655 (ruling record 5478756633, cited from [#13801](https://github.com/objectstack-ai/objectstack/issues/13801); #13655 itself was not readable, HTTP 404, when this record was written). That half was frozen until a named external user asked. The ruling counts the pull from the platform's own suites (the hotcrm case SLA matrix, hotsrm delivery dates, the production suite) as meeting that condition. The freeze's second constraint stands and is D4 here. - **Reverses**: the in-seat finding on #13801 (comment [`5506987580`](https://github.com/objectstack-ai/objectstack/issues/13801#issuecomment-5506987580)) that a clock marker on `timeoutHours` would be inert. That finding held only while one clock existed; with two clocks the marker has a reader (D5). -- **Builds on**: [ADR-0144](./0144-multi-currency-record-currency-dated-rates-write-time-home-projection.md) (`sys_exchange_rate`: organization-scoped runtime data that an administrator writes and that every change audits — the precedent for D1, and `ERR_HOME_CURRENCY_UNSET`, the precedent for refusing rather than guessing in D2). [ADR-0049](./0049-no-unenforced-security-properties.md) (enforce-or-remove: a calendar nobody reads, an inherited column nobody reads and a clock key with one value are all inert — D2, D4, D5). [ADR-0029](./0029-kernel-object-ownership-and-platform-objects-decomposition.md) D1, D3 and D6 (a first-party capability owns its `sys_*` objects; which package owns the two objects here is #35355's to settle against it). [ADR-0053](./0053-date-and-datetime-semantics.md) (an exception's date is a calendar day, never an instant; time-zone arithmetic goes through the shared DST-safe primitive). [ADR-0112](./0112-error-code-vocabulary-and-ledger.md) (every refusal below answers with a ledger code that the implementing card registers). -- **Amends**: no decision. The `timeoutHours` describe text, which says the platform ships no business-hours calendar, is rewritten by #35357, not here. +- **Builds on**: [ADR-0144](./0144-multi-currency-record-currency-dated-rates-write-time-home-projection.md) (`sys_exchange_rate`: organization-scoped runtime data that an administrator writes and that every change audits — the precedent for D1, and `ERR_HOME_CURRENCY_UNSET`, the precedent for refusing rather than guessing in D2). [ADR-0049](./0049-no-unenforced-security-properties.md) (enforce-or-remove: a calendar nobody reads, an inherited column nobody reads and a clock key with one value are all inert — D2, D4, D5). [ADR-0029](./0029-kernel-object-ownership-and-platform-objects-decomposition.md) D1, D3 and D6 (a first-party capability owns its `sys_*` objects; which package owns the two objects here is #35355's to settle against it). [ADR-0053](./0053-date-and-datetime-semantics.md) (an exception's date is a calendar day, never an instant; time-zone arithmetic goes through the shared DST-safe primitive). [ADR-0112](./0112-error-code-vocabulary-and-ledger.md) (every refusal below answers with a ledger code that the implementing card registers). [ADR-0042](./0042-approval-sla-escalation.md) (the approval SLA sweep that D5, D9 and D12 change: §1 single-shot escalation with the `escalate` audit row as its marker, §3 the deadline runs from `created_at` and does not pause). [ADR-0058](./0058-expression-and-predicate-surface.md) (one expression language, two backends; the pushdown compiler that refuses function calls, D6). [ADR-0137](./0137-predicate-fault-semantics-are-contract.md) D2 (a field-rule predicate that faults refuses the submit, which is what a D8 refusal inside one does). +- **Amends**: no decision. ADR-0042 §3 ("the deadline stays `created_at + timeoutHours`") stands as written under `wall_clock`. Under `working_time` its start at `created_at` and its no-pause rule stand; only how the hours are counted gains a second clock (D5, D12). ADR-0042 §1, single-shot escalation, is unchanged (D12). ADR-0042 carries a dated pointer note to this record. The `timeoutHours` describe text, which says the platform ships no business-hours calendar, is rewritten by #35357, not here. --- @@ -124,7 +124,7 @@ Ruled in record [`7003541720`](https://github.com/objectstack-ai/objectstack/iss Ruled in record [`7003541720`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003541720), Q2 letter C. - **When the sweep cannot compute a `working_time` due time** (no calendar resolves under D2, or D8 refuses the computation), it does not escalate the request and tries again on the next sweep. Once an administrator fixes the calendar, the next sweep recovers with no other step. -- **Where the due time is displayed, it shows 「日历算不出」 with the reason**: the calendar was not found, or it is not maintained to that date. +- **Where the due time is displayed, it shows 「日历算不出」 with the reason**: the calendar was not found, or it is not maintained to that date. 「日历算不出」 is the maintainer's wording; the displayed string is localized. - **The publish-time check covers static authoring errors only**, such as a `calendar` code written without `clock: 'working_time'`. It does not check whether the named calendar exists: calendars are per-organization runtime data, and the approval lint is a pure function of the stack (`packages/lint/src/validate-approval-approvers.ts`). #35357's Scope sentence that a `working_time` escalation with no resolvable calendar "is a lint/validation error" is read under this decision. - Not chosen: skip and log only (A); a publish-time check that the calendar exists (B). Refusing at submit time was not offered: together with D8 it would block every approval whose deadline crosses the year end until the next year's holidays are entered. @@ -135,28 +135,29 @@ Ruled in record [`7003566086`](https://github.com/objectstack-ai/objectstack/iss - **An `off` row has no periods** and means the whole date is off. - **An `on` row must carry that date's full working periods.** A half day is an `on` row with shortened periods. An `on` row never borrows a weekday's periods: with borrowing, a later edit to that weekday would silently rewrite past make-up days. - **One row per calendar and date.** -- **`24:00` is a legal period end**, validated by the calendar itself, because the platform's time parser refuses a zone-naive `24:00` (`packages/core/src/utils/import-coerce.ts`). A period's end is later than its start (D7). +- **`24:00` is a legal period end**, validated by the calendar itself, because the platform's `time` value form and its import parser both refuse `24:00` (`packages/spec/src/data/field-value.zod.ts#ClockTimeValueSchema`, `packages/core/src/utils/import-coerce.ts`). A period's end is later than its start (D7). ### D11 — A daylight-saving transition day counts elapsed time (Q4 = A) Ruled in record [`7003566086`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003566086), pick 「全按推荐」, Q4 letter A. - **Working hours are counted as elapsed time.** Each local period is mapped to instants and its real duration counted, as `wall_clock` counts elapsed milliseconds. On a transition day a period can be an hour shorter or longer than its clock-face length. -- **Local times convert to instants only through the shared DST-safe primitive** (ADR-0053). A local time the zone skips, or one it passes twice, resolves the way that primitive already does and pins in its tests, to the earlier candidate instant (`packages/core/src/utils/datetime.ts#zonedWallClockToUtcMs`). Working calendars add no rule of their own. +- **Local times convert to instants only through the shared DST-safe primitive** (ADR-0053). A local time the zone skips, or one it passes twice, resolves the way that primitive already does and pins in its tests, to the earlier candidate instant (`packages/core/src/utils/datetime.ts#zonedWallClockToUtcMs`). Working calendars add no rule of their own. Where that primitive lives so that the formula functions can reach it is open implementation point 3. - China has no daylight saving; only calendars whose periods cover a transition hour see a difference. ### D12 — A working-time deadline is recomputed on every sweep (Q5 = A) Ruled in record [`7003566086`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003566086), Q5 letter A. It is the approved Scope of #35357: "recompute each sweep rather than storing it". -- **The `working_time` due time is recomputed from `created_at` on every sweep and never stored.** A holiday entered after a request opened moves that request's deadline. The displayed due time and the sweep use one function, as the wall-clock due time does today (`packages/plugins/plugin-approvals/src/approval-service.ts#slaDueAt`). -- Current behaviour, not a ruling: escalation stays single-shot, as today. A request already escalated is not escalated again, or recalled, when its calendar changes: the sweep skips any request that already carries an `escalate` action (`packages/plugins/plugin-approvals/src/approval-service.ts#ApprovalService.runEscalations`). +- **The `working_time` due time is recomputed from `created_at` on every sweep and never stored.** "Never stored" means a stored value is never the source of the deadline; whether the `escalate` audit row may record the due time it fired on is #35357's to settle. A holiday entered after a request opened moves that request's deadline. +- Follows from D9, not a ruling of its own: the displayed due time and the sweep use one function, as the wall-clock due time does today (`packages/plugins/plugin-approvals/src/approval-service.ts#slaDueAt`). +- **Single-shot escalation is [ADR-0042](./0042-approval-sla-escalation.md) §1 and is unchanged.** A request already escalated is not escalated again, or recalled, when its calendar changes: the sweep skips any request that already carries an `escalate` action (`packages/plugins/plugin-approvals/src/approval-service.ts#ApprovalService.runEscalations`). ### D13 — Calendar seed rows follow the existing seed contract (Q6) Ruled in record [`7003566086`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003566086), pick 「全按推荐」: no new rule. -- **No calendar-specific seeding rule.** The seed contract stands as ruled in record `6631016988` on #30081 (`packages/spec/src/data/seed.zod.ts`): a seed is create-only by default, so an organization's edits survive a replay, and a row is overwritten only when the package declares `mode: 'upsert'`. +- **No calendar-specific seeding rule.** The seed contract stands as ruled in record `6631016988` on #30081 (`packages/spec/src/data/seed.zod.ts`): a seed is create-only by default, so an organization's edits survive a replay, and an existing row is written over only when the package declares a mode that does so (`upsert`, or `update`). - Whether the later CN holidays data package declares `upsert`, to correct rows it has already landed, is that package's card to decide with its real data. ## Enforcement @@ -164,7 +165,7 @@ Ruled in record [`7003566086`](https://github.com/objectstack-ai/objectstack/iss | Decision | Enforced by | |:--|:--| | D1 objects, seed by code; D2 resolver and its refusal code; D3 maintained-through and import; D7 required time zone and the midnight refusal; D8 the refusal past maintained-through and the Setup notice; D10 the exception row shape and period validation; D13 seeding under the existing seed contract | [#35355](https://github.com/objectstack-ai/objectstack/issues/35355) — the two objects, the calendar service, the Setup page and the exception import | -| D4 formula functions; D6 pushdown refusal and lint; D8 a refused formula due date reads blank; D11 elapsed counting, with pinned spring-forward and fall-back tests; open implementation point 1 | [#35356](https://github.com/objectstack-ai/objectstack/issues/35356) — `addWorkingDays`, `workingDaysBetween`, `addWorkingHours` | +| D4 formula functions; D6 pushdown refusal and lint; D8 a refused formula due date reads blank; D11 elapsed counting, with pinned spring-forward and fall-back tests; open implementation points 1 and 3 | [#35356](https://github.com/objectstack-ai/objectstack/issues/35356) — `addWorkingDays`, `workingDaysBetween`, `addWorkingHours` | | D4 approval clock; D5 the key, its default and the rewritten describe text; D9 skip, retry, the displayed reason and the static-only lint; D11 elapsed counting; D12 recompute on every sweep | [#35357](https://github.com/objectstack-ai/objectstack/issues/35357) — `escalation.clock` and `escalation.calendar` | | D4 the release pairing | all three, held as ADR-0144 D9 holds its pairs | @@ -181,10 +182,12 @@ Shift rostering, finite-capacity scheduling, payroll calendars and fiscal period ## Open implementation points -The maintainer ruled every open question of the first draft (D8–D13). Two implementation points remain. Neither is a maintainer question: the card named settles each under its own contract review, and this record does not decide them. +The maintainer ruled every open question of the first draft (D8–D13). Four implementation points remain. Neither is a maintainer question: the card named settles each under its own contract review, and this record does not decide them. 1. **A write-time computed due-date column that meets a D8 refusal** (#35356's contract review): the write fails, or the column is stored blank. A formula read is already settled by D8: blank, plus one log line, not an error. 2. **A blank maintained-through date** (#35355): whether the field is required, and what a blank means. Under D3 a blank must not read as "no holidays from here on". +3. **Where the working-time arithmetic and the wall-clock conversion live** (#35355 and #35356), so that there is exactly one DST rule (D11). `@objectstack/formula` depends only on `@objectstack/spec` and the CEL library, cannot depend on `@objectstack/core`, and already keeps a private copy of a calendar-day helper for `today()` (`packages/core/src/utils/datetime.ts`, file header). D1 says one calendar service computes, while the formula functions compute synchronously inside formula. Two routes keep D11: move the primitive below formula, as `nextUtcCalendarDay` moved to `@objectstack/spec/data` (`packages/spec/src/data/calendar-day.ts#nextUtcCalendarDay`); or have the calendar service hand formula periods already converted to instants. A private copy in formula is not a route: it is the second DST rule D11 forbids. +4. **In which organization, and under whose authority, the calendar service reads** (#35355, carried into #35357's review). The precedent's reader takes the row's own organization and reads elevated, because a member cannot read the rate table. The sweep runs in a system context across organizations, and a package-seeded calendar has the same code in every organization. ## Consequences @@ -194,6 +197,9 @@ The maintainer ruled every open question of the first draft (D8–D13). Two impl - **A working-day deadline is not filterable unless stored.** Authors who need to filter or aggregate on a working-day due time compute it at write time into a `datetime` column. - **An unmaintained calendar blanks deadlines.** From the day a deadline's span crosses the maintained-through date, formula due dates read blank and working-time escalations wait with 「日历算不出」 until an administrator extends the calendar (D8, D9). The longer a suite's typical span, the earlier in the year this starts; the Setup notice exists for it. - **Calendar edits move open deadlines.** Under D12 a holiday added later pushes an open request's deadline out, and a holiday removed or a period lengthened brings it in, so the next sweep may escalate several requests at once. +- **A stored due-date column does not follow the calendar.** A D6 write-time `datetime` column keeps the value it was computed with when the calendar is edited, while a formula read and a D12 deadline move. +- **A refusal inside a field-rule predicate refuses the submit.** A D8 refusal in a predicate faults it, and under ADR-0137 D2 a faulting field-rule predicate refuses the submit. +- **The Console form cannot serve the three functions.** The Console evaluates formula fields with the same engine (`ui/packages/core/src/evaluator/formulaRecord.ts`) and holds no calendar, so #35356 puts the three functions on its unservable list. - **Two calendars in the product until the gantt follow-up lands.** ## References @@ -201,4 +207,4 @@ The maintainer ruled every open question of the first draft (D8–D13). Two impl - Ruling [`7000950747`](https://github.com/objectstack-ai/objectstack/issues/35340#issuecomment-7000950747) on #35340; card #35354; implementing cards #35355, #35356, #35357. - Ruling records [`7003541720`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003541720) (Q1, Q2) and [`7003566086`](https://github.com/objectstack-ai/objectstack/issues/35354#issuecomment-7003566086) (Q3–Q6) on #35354; the seed contract ruling `6631016988` on #30081. - #13801 and its in-seat ruling `5506987580`; the #13655 freeze (ruling record 5478756633). -- ADR-0029, ADR-0049, ADR-0053, ADR-0112, ADR-0144. +- ADR-0029, ADR-0042 (§1 and §3), ADR-0049, ADR-0053, ADR-0058, ADR-0112, ADR-0137 (D2), ADR-0144.