Skip to content

feat(spec, objectql): working-calendar service, arithmetic and refusal codes (ADR-0157, part 1 of 2) - #35641

Merged
objectstack-fleet[bot] merged 15 commits into
mainfrom
claude/issue-35355-work-calendar-objects-service
Nov 20, 2026
Merged

objectstack-fleet[bot] merged 15 commits into
mainfrom
claude/issue-35355-work-calendar-objects-service

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb
Part of #35355
Clause-②: yes (widening)
Metadata-protocol: none

维护者速读

用户能看到什么变化:系统管理员和普通用户在界面上都看不到变化(用户无感);之前平台不会按上班日算期限,之后平台内部能算,但要等配套的日历设置页一起上线才用得上。
为什么做:属于「工作日历」,替公式作者和审批流程计算“几个工作日后”“几个工作小时后”,让节假日和调休上班日都算对。
出错会怎样:若算错,按工作日计算的到期日会差一天或落在休息日,审批提醒会提前或推迟;没指明组织的计算会被直接拒绝,不会借用别的组织的日历;这一半只新增、不改旧功能,可以直接撤回。
要你做什么:无。

席位核对

Pair and release (ADR-0157 D4)

Not released alone; pair #35641/#35642. This is the first of two pull requests for #35355, split by layer; its pair is #35642 (the two calendar objects, Setup, import and translations), which lands right after this one. Both ship in the same release as #35356 (the working-day formula functions) and #35357 (the approval escalation's working-time clock), per ADR-0157 D4. On its own this half registers a service that refuses every resolution, because no calendar object exists until #35642 lands.

Fix round 1 (contract review 7023325199, ruling record 7023403692)

  • M1, an absent organization. Outside the single tenancy posture (the engine's own reading, resolveEnginePosture), a computation whose organizationId is absent is refused ERR_WORK_CALENDAR_UNRESOLVED with reason no_organization before any read, the cache's included; single is unchanged. The rule is stated in the WorkCalendarRef jsdoc, the service header and the ADR anchor. The same rule binds the hooks' elevated reads (the one-default check and the time-zone fill), and the hooks take the organization from the session. When no posture is passed, the service and the hooks read the posture of the engine they run on, so SecurityPlugin's injected posture is the one in force.
  • S1, where the arithmetic lives. The period parser, buildWorkCalendar, the four counts, isWorkingDay, workingPeriodsOn, exceptionDayOf, calendarDayOf and the three error classes move to @objectstack/formula (packages/formula/src/work-calendar.ts). The edge already existed: @objectstack/objectql and plugin-approvals depend on formula, and formula depends on spec, so no dependency edge is new. Spec keeps zonedWallClockToUtcMs, the types, the constants and the ledger codes, and its module header now states Prime Directive ✨ Set up Copilot instructions #2 as schemas, types and constants only. The gantt's two ALLOW entries in ui/scripts/check-spec-symbol-derivation.mjs are dropped, since spec no longer exports those names; that file is back to its main bytes.
  • S2, the contract. IWorkCalendarService, WorkCalendarRef and WORK_CALENDAR_SERVICE are in packages/spec/src/contracts/work-calendar-service.ts, beside the other service contracts. The objectql class keeps its name and implements IWorkCalendarService.
  • N1. The 60-day lead's jsdoc says the next year's holidays are usually published around or after November, and makes no claim about the date.
  • N2. feat(platform-objects): working calendars in Setup — sys_work_calendar and sys_work_calendar_exception (ADR-0157, part 2 of 2) #35642 is named by number here and in the changeset, both with "Not released alone; pair feat(spec, objectql): working-calendar service, arithmetic and refusal codes (ADR-0157, part 1 of 2) #35641/feat(platform-objects): working calendars in Setup — sys_work_calendar and sys_work_calendar_exception (ADR-0157, part 2 of 2) #35642".
  • N3. buildWorkCalendar returns a frozen calendar (the calendar, the weekly lists, every period, the exceptions and each day), so a cached calendar answers every caller alike.
  • The ledger entry. It stays under @objectstack/spec. The three code constants stay in spec, and check:error-code-provenance attributes a code to the package whose constant spells it. Formula's error classes stamp it by reference.
  • Semver. Spec stays patch (Metadata-protocol: none); @objectstack/formula is added to the changeset as patch.

Main merge and fix round 2 (contract delta 7026479156, PASS with S3; seat ruling: refuse)

  • 28fca759a9 merges main (03865ae995, K=25); the merge regenerates api-surface/data.json and export-origins/data.json and carries no hand edit (contract delta 7026479156).
  • f502d9238c (S3): the calendar insert hook refuses a create whose row names an organization other than the session's and sets is_default: true, before any read, with 400 VALIDATION_FAILED (is_default, invalid_value) and a reason that says how to proceed. A mismatched create without a default passes as before. The module header says a future seed that sets a default loads pinned to its organization or sets it by an update. Pins: the member and system-writer cases now assert the refusal, with a CONTROL for a plain create and a new pin for the update route; ablation 3 red / 21 green, restored. @objectstack/objectql (--project local) at f502d9238c: 617 files, 13947 tests passed. 2204 lines against main.

Comments read (through 7023325199)

  • 7021287976, the docs drift check. No hand-written page under content/docs, skills or docs (ADRs aside) names the moved names: git grep for the arithmetic, the service, the contract constant and zonedWallClockToUtcMs finds none. The reference pages are generated, and check:docs passes.
  • 7022981176, L1-a.
    • R1, the claim line for the ui script, is moot: that file is back to its main bytes.
    • Observations 1 to 3 were ruled in 7023403692 and are carried out above: semver stays patch, M1, and the pair sentence.
  • 7023325199, the contract review. M1, S1, S2 and N1 to N3 are answered item by item in the fix-round section above.

What changes

  • Arithmetic: packages/formula/src/work-calendar.ts (new). isWorkingTime, addWorkingDays, workingDaysBetween and addWorkingHours are pure functions over a resolved calendar, so Working calendars ③: formula functions addWorkingDays / workingDaysBetween / addWorkingHours #35356 can call them synchronously. parseWorkPeriods enforces D7 and D10: a period crossing midnight is refused, 24:00 is a legal end, and overlapping or malformed text is refused. buildWorkCalendar validates a stored row and its exceptions, and builds frozen.
  • Types, constants and the time-zone rule: packages/spec/src/data/work-calendar.ts and wall-clock.ts. zonedWallClockToUtcMs, wallClockToUtcMs and WallClockParts move from @objectstack/core byte-identical, and core re-exports all three (D11).
  • Ledger codes: ERR_WORK_CALENDAR_UNRESOLVED, ERR_WORK_CALENDAR_NOT_MAINTAINED and ERR_WORK_CALENDAR_INVALID, each a 400.
  • Service: packages/objectql/src/work-calendar-service.ts, registered as work-calendar from the ObjectQL plugin. Under D2 it takes the named code, else the organization default, else refuses, and never falls back to wall-clock time. It reads elevated in the named organization, refuses an absent one outside single, caches with a 60 s TTL, drops the cache on any calendar or exception write, and never caches a refusal.
  • Write door: hooks on both objects, bound by name and inert until feat(platform-objects): working calendars in Setup — sys_work_calendar and sys_work_calendar_exception (ADR-0157, part 2 of 2) #35642 registers the objects. Each of the following is refused 400 VALIDATION_FAILED with an ADR-0114 field code: a period crossing midnight, a malformed or overlapping period, off with periods, on without, maintained_through before maintained_from, and a second default. A create placed in an organization other than the session's that sets Default is refused before any read; set the default by an update, which is judged in the stored row's organization. A create without timezone takes the organization's Localization zone. The hooks take the organization from the session.

Service API for #35356 and #35357

  • Contract, @objectstack/spec/contracts:
    • IWorkCalendarService: resolve(ref), isWorkingTime(ref, at), addWorkingDays(ref, day, days), workingDaysBetween(ref, start, end) (start excluded, end included), addWorkingHours(ref, start, hours) (returns epoch ms) and invalidate().
    • ref is WorkCalendarRef, { organizationId, calendar? }.
    • The service registers under WORK_CALENDAR_SERVICE (work-calendar); the implementation is WorkCalendarService in @objectstack/objectql.
  • Sync, @objectstack/formula: the same four computations taking a resolved WorkCalendar first, plus buildWorkCalendar, parseWorkPeriods, isWorkingDay and workingPeriodsOn. The conversion is zonedWallClockToUtcMs from @objectstack/spec/data.
  • Refusals, @objectstack/formula:
    • WorkCalendarUnresolvedError, with reason not_found, no_default, ambiguous or no_organization.
    • WorkCalendarNotMaintainedError and WorkCalendarInvalidError.
    • isWorkCalendarRefusal.
    • The codes are @objectstack/spec/data constants.

Tests

Head e8af402891. Each run below went through os-verify-lock and read VERDICT command-exit 0. Commands are --maxWorkers=2. --project local is the package's own test script.

  • Builds: @objectstack/objectql plus its dependency closure; spec, formula and core among them.
  • Typecheck, exit 0: spec, formula, objectql and core.
  • @objectstack/formula: 69 test files and 1902 tests passed.
  • @objectstack/objectql (--project local): 617 test files and 13941 tests passed.
  • @objectstack/spec (--project local): 857 test files and 27394 tests passed, with 1 todo. This was after check:generated --fix rewrote and re-checked api-surface/ and export-origins/.
  • pnpm --dir ui run check:spec-symbols: exit 0, with 0 untriaged collisions after the ALLOW entries were dropped.

New pins this round (packages/objectql/src/work-calendar-service.test.ts, 23 tests; packages/formula/src/work-calendar.test.ts, 14 tests):

  • The service, under isolated and under group. A named code held only by another organization is refused no_organization, and so is a default held only by another organization. An empty-string organization is refused the same way, and so is addWorkingDays. Each refusal reaches HTTP as 400 ERR_WORK_CALENDAR_UNRESOLVED, with zero engine reads. CONTROL: naming the holding organization resolves it.
  • The service, under single. A computation without an organization still reads, unscoped.
  • The posture source. When none is passed, the service reads the engine's injected posture.
  • The hooks take the organization from the session. This runs under single and under isolated, with a CONTROL showing the session's own organization is read and judged. A system writer reads in its session's organization too.
  • No organization, outside single. Under isolated, an insert and an update that name no organization read nothing. CONTROL: under single the same writes are judged.
  • The frozen calendar. The built calendar is frozen down to its periods.

The double scopes each read by its context's tenant, as the engine does.

Ablations, one per new mechanism, through scripts/ablation-replace.mjs. Every anchor went from 1 hit to 0 and every blob moved. Each restore is proven by the blob equalling HEAD and by an empty git diff HEAD. Subjects are imported by relative source path, so there is no dist leg.

  • Resolve guard off: 3 red (isolated, group, engine posture).
  • Session rule off: 3 red (the three session pins).
  • Insert hook guard off: 1 red.
  • Update hook guard off: 1 red.
  • Outer freeze off: 1 red.
  • Period freeze off: 1 red.

Gates

  • Derived families. node scripts/pm/dispatch-gates.mjs --commands at tree e8af402891 derives 132 families. Each ran with its exit code captured before any pipe, and all 132 exited 0.
  • Reconciliation (--ran, each family recorded with its exit code): Run reconciliation — 132 derived, 132 run, 0 NOT-MEASURED, 0 UNRUN. The zero is derived, since every family carries an exit code.
  • Among them:
    • Error codes: check:error-code-provenance, check:error-code-casing, check:dispatcher-error-vocabulary.
    • Generated artifacts and docs: check:api-surface, check:export-origins, check:docs, check:generated.
    • check:authorable-surface: no authorable key moved, hence Metadata-protocol: none.
    • Test doubles: check:where-matcher, check:objectql-double-limit, check:engine-double-contract, check:query-options-erasure.
    • check:system-context-census, check:dual-build-cjs-loads, check:adr-anchors, check:nul-bytes.
  • Outside the derived list. node scripts/check-platform-checklist.mjs --changed-from origin/main (exported symbols moved) exits 0, and overlap-check gives VERDICT clean exit 0.
  • Two reds on the first pass at 743be6587f, both fixed in e8af402891:
    • check:system-context-census flagged a new caller-keyed branch in the insert hook. The hooks now take every writer's organization from the session, so no branch is left.
    • check:where-matcher could not lift the test double's matcher once tenant scoping shared its callback. The scoping is now a step of its own.
  • CI at e8af402891, read once: 58 success, 10 skipped and 1 in progress (Test Core 10/10), with no failure. Every Lint and Type Check lane, Type Check UI, Build Core, Check Changeset and the PR-body guards passed.

Acceptance notes

Verification

  • Read first:
    • packages/objectql/src/work-calendar-service.ts: resolve (the no-organization guard) and insertReadOrganization (the hooks' organization).
    • packages/formula/src/work-calendar.ts: addWorkingHours and requireMaintained, the D8 and D11 core.
    • packages/spec/src/contracts/work-calendar-service.ts: the contract.
  • Two-minute check: pnpm --filter @objectstack/objectql exec vitest run src/work-calendar-service.test.ts. Expect 24 passed, including the isolated and group no-organization pins and the session pins.

Generated by Claude Code

…ng-calendar arithmetic

ADR-0157 open point 3: zonedWallClockToUtcMs and wallClockToUtcMs move from
@objectstack/core to @objectstack/spec/data (bodies byte-identical; core
re-exports them), and the pure working-time arithmetic over one resolved
calendar lands beside them, so the calendar service and the working-day
formula functions count with one daylight-saving rule (D11). The three
refusal codes are registered in the ADR-0112 ledger.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb
…oks and Setup entries

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb
…r bundles, and record the baselines they need

The ten translated locales carry hand translations for every new key of
sys_work_calendar and sys_work_calendar_exception; the ownership list,
the organization-ownership inventory, the tenancy census, the ADR anchors,
the spec API surface and the changeset follow the two new objects.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb
…s, and the regenerated references

The calendar write door stamps its ADR-0114 field codes as plain literals, one
per branch. The service test's read double refuses an operator it does not
implement, its memory driver honours the caller's limit, and its engine calls
carry typed options. The spec export origins and the API references now list
the working-calendar exports and the three ledger codes.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb
The admin Setup composition grows from 31 to 33 entries with Working
Calendars and Calendar Exceptions under Configuration; the pin names both.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb
…d Setup move to a sibling branch

This branch now carries the first half of the working-calendar change: the
pure arithmetic and the wall-clock primitive in @objectstack/spec/data, the
three ledger codes, the calendar service and its write hooks in
@objectstack/objectql, and the regenerated references. The two calendar
objects, their translations, the Setup entries, the import door, the tenancy
census, the ownership inventory and the Setup-tree pin return to main here
and land on claude/issue-35355-work-calendar-objects-setup. The spec API
surface and export origins are regenerated from the merged tree.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb
@github-actions github-actions Bot added size/xl documentation Improvements or additions to documentation protocol:data tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 4 package(s): @objectstack/core, @objectstack/formula, @objectstack/objectql, @objectstack/spec, touching 109 documentable anchor(s). ⚠️ 8 changed file(s) yielded no anchor (packages/formula/src/index.ts, packages/objectql/src/index.ts, packages/spec/api-surface/contracts.json, …), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

57 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 238661f47f3937c0cd79cebade410141763775ec.

⛔ 14 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 8 changed file(s) yielded no anchor (packages/formula/src/index.ts, packages/objectql/src/index.ts, packages/spec/api-surface/contracts.json, …) — pages documenting those are invisible to this run
  • 27 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 183 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 238661f47f3937c0cd79cebade410141763775ec → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 27e22dad812b5bb0a193dd844f67302ea0307bc7 — the merge of head f502d9238ccaf3ceee589ee56b4858727a61c807 into base 238661f47f3937c0cd79cebade410141763775ec, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 27e22dad812b5bb0a193dd844f67302ea0307bc7 && git checkout 27e22dad812b5bb0a193dd844f67302ea0307bc7
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 238661f47f3937c0cd79cebade410141763775ec f502d9238ccaf3ceee589ee56b4858727a61c807 && git checkout -B drift-repro 238661f47f3937c0cd79cebade410141763775ec && git merge --no-ff f502d9238ccaf3ceee589ee56b4858727a61c807

node scripts/docs-audit/affected-docs.mjs --json 238661f47f3937c0cd79cebade410141763775ec

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 238661f47f3937c0cd79cebade410141763775ec → pass the list as
args.docs, on the commit named under Which tree this was computed on.

…ays beside the spec's

@objectstack/spec/data now exports isWorkingDay and addWorkingDays, the
platform working-calendar arithmetic. The gantt scheduler's module-local
helpers carry the same two names over the view's own skipWeekends and
holidays calendar, which ADR-0157 keeps until its Follow-up switches the
gantt to the platform calendar. Two reasoned ALLOW entries in the
spec-symbol derivation gate; no gantt behaviour changes.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4

维护者速读

  • 用户能看到什么变化:暂时没有。平台内部学会了按"工作日历"计算:几个工作日之后、几个工作小时之后,节假日和调休上班日都算对;要等日历设置页(同一张卡的另一半)上线后才用得上。
  • 为什么做:公式和审批提醒需要按工作日计算期限,而不是按自然日。
  • 出错会怎样:按工作日算出的到期日会差一天或落在休息日,审批提醒会提前或推迟;这一半只新增、不改旧功能。
  • 要你做什么:无。席位做合同复审;两半必须在同一次发布里上线。
  • 席位意见:通过,只差一处补登记(文字即可);另有三点留给席位合同复审时定:版本号级别、未指明组织时的读取范围、两半同批发布。

席位核对

L1-a: ACCEPT, one text-only item · head ad45d084f4e820b0b0c99ad29beb89cdd8fb9082 · Part of #35355 (PR-A of the seat-approved split; PR-B #35642) · base main · K=11 · merge-tree clean · not governed (0 of 20 paths) · 1,887 lines · CI 63 success, 11 skipped, 0 failed · 2026-11-19T21:40Z

Card status. Claimed 15:09Z (7013077388), before the 15:24Z hand-off of the data area, so it is in-flight for data-1. The split and both branches are in amendment 7021881794 and re-claim 7022517146.

The wall-clock move is byte-identical. I extracted zonedWallClockToUtcMs and wallClockToUtcMs from packages/core/src/utils/datetime.ts at the merge base and from packages/spec/src/data/wall-clock.ts at this head, and both function bodies compare equal. Core re-exports both functions and WallClockParts, so no import site moves.

Arithmetic read (work-calendar.ts).

  • Every loop ends either by finding a working day or by stepping outside the maintained span: isWorkingDay and workingPeriodsOn call requireMaintained. So a calendar with no working day at all is refused ERR_WORK_CALENDAR_NOT_MAINTAINED rather than looping forever. This holds for addWorkingDays and for addWorkingHours, which calls requireMaintained on each new day.
  • workingDaysBetween counts (s, e] forward and [e, s) backward, the exact inverse of addWorkingDays.
  • addWorkingHours rounds to whole milliseconds and skips an empty period (pe <= ps), which covers a DST gap inside a period.
  • localDayOf checks the UTC day ±1 against local midnights through the same primitive.

Service and hooks (work-calendar-service.ts).

  • Resolution reads limit: 2 and refuses ambiguous on two rows. It never falls back to the wall clock, and it pages the exceptions in (date, id) order.
  • The write hooks run at beforeInsert. In engine-insert.ts, hooks dispatch at ~673 and validateRecordInScope runs at ~1371, so the timezone fill lands before PR-B's required: true on timezone is judged. The fixture in the service test declares timezone not required, so no pin covers that ordering. It holds by reading the engine.
  • engine.ts is not touched (claim ⛔).

Pins. 37 describe/it names across work-calendar.test.ts and work-calendar-service.test.ts, with CONTROLs on the 调休 Saturday, the National Day week and the New York DST pair. The PR body lists seven ablations, one per mechanism. I did not re-run them (no install here); CI ran both files green.

R1 (text only, no push, no fresh L1): claim amendment for ui/scripts/check-spec-symbol-derivation.mjs. The two reasoned ALLOW entries for the gantt's module-local isWorkingDay and addWorkingDays (last round) sit in a file that neither claim 7013077388 nor amendment 7021881794 names. One amendment line on #35355, naming the file and the reason (the new spec exports collide by name with the gantt's helpers), closes it. The entries themselves read right: they name ADR-0157's gantt Follow-up, and ratchet 3 retires them.

For the seat's contract L2 (my observations, not required items).

  1. Semver. Both halves grade @objectstack/spec patch, while this half adds published functions, error classes, constants and three ledger codes to @objectstack/spec/data. The seat graded an additive spec change minor on feat(spec): a formula field can return percent #35565. Which grade applies here is the seat's call.
  2. P4 with no organization. readContext(undefined) reads elevated with no tenantId, which the body calls the single posture. In a multi-organization deployment, a caller that omits organizationId reads across organizations. limit: 2 catches two defaults as ambiguous, but a named code that only one other organization holds resolves to that organization's calendar. Today's callers (Working calendars ③: formula functions addWorkingDays / workingDaysBetween / addWorkingHours #35356, Working calendars ④: approval escalation clock key (wall_clock | working_time) #35357) are said to always pass the org. Whether undefined should be refused outside the single posture is part of open point 4.
  3. D4 release coupling. The changeset says "Not released alone", but nothing mechanical holds a release cut between PR-A landing and PR-B landing. A cut in that gap would publish a service that refuses every resolution, which is harmless but out of contract. The land order A then B, back to back, is the only guard.

Routing. Clause-② yes (widening) with a packages/spec face: L2 at CONTRACT_REVIEW_TIER by seat 5, covering the six open points in the body. Not governed, so data-1 lands A after the L2, then retargets B to main.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CbUb7TcZK1XUAddUmQ

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: ad45d084f4e820b0b0c99ad29beb89cdd8fb9082
Local-runs: none
Scope: packages/spec/src/api/error-code-ledger.zod.ts, packages/spec/src/data/index.ts, packages/spec/src/data/wall-clock.ts, packages/spec/src/data/work-calendar.ts + packages/objectql/src/work-calendar-service.ts, packages/objectql/src/plugin.ts, packages/objectql/src/index.ts, packages/core/src/utils/datetime.ts, ui/scripts/check-spec-symbol-derivation.mjs, scripts/adr-anchors/packages__spec__src__data__work-calendar.ts.json, scripts/adr-anchors/packages__spec__src__data__wall-clock.ts.json, scripts/adr-anchors/packages__objectql__src__work-calendar-service.ts.json

PR #35641, part one of two for card #35355 (pair: #35642). Read: the card body and its ten comments, the PR body and its two comments, the net diff against main, ADR-0157 and the cited code in the head tree, and the check-runs on this head (no failure: every run is success or skipped). #35642 was read only for the two object declarations and its changeset, as the first consumer of this half's constants and hooks. The rest of the diff (the two test files, the regenerated references and baselines, the changeset body) is the lane seat's ACCEPT.

① Derived judgments

  1. ApiErrorSchema.code gains three members through ERROR_CODE_LEDGER['@objectstack/spec']: ERR_WORK_CALENDAR_UNRESOLVED, ERR_WORK_CALENDAR_NOT_MAINTAINED, ERR_WORK_CALENDAR_INVALID. Right: a closed enum widens, each code has a thrower in this diff (the three classes in work-calendar.ts), and each sits under the package that stamps it. If S1 moves the classes, the entry moves with them.
  2. @objectstack/spec/data gains 33 exports: 14 functions, 3 error classes, 7 constants, 9 types. Right as a widening; nothing is removed or renamed. Wider than the contract needs in two places: calendarDayOf and exceptionDayOf are published only because the write hooks sit in another package than the arithmetic.
  3. @objectstack/core: published surface unchanged. wallClockToUtcMs and zonedWallClockToUtcMs are re-exported and their bodies are the base's bodies, character for character (compared on the two blobs). WallClockParts is re-exported and no longer spelled extends CalendarParts; it declares the same three members itself, so it is the same structural type. The PR body's "byte-identical" holds for the two functions, not for the type's spelling. Right.
  4. @objectstack/objectql gains the WorkCalendarService class, installWorkCalendarHooks, four constants and four option types, and ObjectQLPlugin registers a kernel service named work-calendar on every kernel. Right as a widening.
  5. Write accept-set: the four before* hooks bind by object name to sys_work_calendar and sys_work_calendar_exception. Neither object exists on this tree, so no existing write is narrowed; with feat(platform-objects): working calendars in Setup — sys_work_calendar and sys_work_calendar_exception (ADR-0157, part 2 of 2) #35642 the refusals apply to two new objects from their first row. Right: no (narrowing) arm is owed.
  6. Metadata-protocol: none: right. Nothing a metadata author can write changes in this half (no key, no accepted value, no metadata type).

② Semver level

Right as written. @objectstack/spec, @objectstack/objectql and @objectstack/core at patch is what the repo's rule requires, not a leniency: AGENTS.md, Post-Task step 3, sets the level by the Metadata-protocol kind alone ("none takes patch; a non-protocol change, widening or breaking, ships patch"), and scripts/check-changeset-no-major.mjs refuses a minor beside none. New functions and three response-enum members are a Clause-② widening, which the changeset declares, and not a protocol kind. The minor on #35565 that the L1 record cites carried Metadata-protocol: added (a new authorable returnType value); it is a different kind, not a different reading of the same one. On main, every changeset that declares none and names @objectstack/spec grades it patch. Both Check Changeset runs on this head are green.

Clause-②: yes (widening) — correct, in the PR body and in the changeset body.

③ Boundary flags

The six design choices (the dev's open_questions, comment 7021836813):

  1. P2, maintained_through required: right. D3 forbids reading a blank as "no holidays from here on", and a required field makes the blank unrepresentable. This half holds its side: WorkCalendar.maintainedThrough is not optional and buildWorkCalendar refuses a blank stored value with ERR_WORK_CALENDAR_INVALID.
  2. The past bound, a required maintained_from: right. Comment 7005998663 puts "refuse like D8" inside the card's remit and "covered by the weekly pattern" outside it. An explicit field is the only bound that does not move when a row is deleted and that exists on a calendar with no exception rows. Two things to carry: D1's field list does not name the field, so ADR-0157 is owed a dated note by the hand that owns it; and a record dated before the bound now reads blank or waits, which is the D8 consequence on the other side.
  3. P3, the arithmetic in @objectstack/spec/data: not right as argued. S1. The primitive's move is the route open point 3 names and is right. The arithmetic is a different matter, below.
  4. P4, elevated read in the organization the caller names: right for a named organization, wrong for an absent one. M1.
  5. The 60-day lead: right. D8 leaves the lead to this card as a default. Sixty days opens the notice around the usual publication window and leaves weeks to act. N1 is about the sentence that justifies it, not the number.
  6. The server-side time-zone fill: right as the write door's floor, and it does not discharge D7. The hook fills from the organization's effective localization.timezone (default UTC) and stores it as the calendar's own, which is D7's second half. D7's first half is "Setup prefills it", and feat(platform-objects): working calendars in Setup — sys_work_calendar and sys_work_calendar_exception (ADR-0157, part 2 of 2) #35642 declares timezone required, so the Setup form asks the administrator for the value and the fill is reached only by API, seed and import writes. That gap belongs on a follow-up card named before Working calendars ②: sys_work_calendar objects, calendar service and Setup page #35355 closes, not on an acceptance note; it is feat(platform-objects): working calendars in Setup — sys_work_calendar and sys_work_calendar_exception (ADR-0157, part 2 of 2) #35642's review to hold.

The three points the L1 record (7022981176) left for this review:

  • Semver: answered in ②.
  • An absent organizationId: yes, it is refused outside the single posture. M1.
  • D4 release coupling: procedural only, and that is what D4 prescribes. ADR-0157 D4 holds the pairing the way ADR-0144 D9 does: each pull request says it is not released alone and names its pair, and the maintainer merges Version Packages only when the set is complete. In the tree, the only carrier is the changeset sentence "Not released alone"; no script or workflow reads it. Blocked-by: #35641 on feat(platform-objects): working calendars in Setup — sys_work_calendar and sys_work_calendar_exception (ADR-0157, part 2 of 2) #35642 orders the two merges and holds nothing at release time. The fixed group in .changeset/config.json gives the packages one version number and does not stop a cut between the two merges. A cut in that gap publishes a service that refuses every resolution and hooks bound to no object: inert, and outside D4. Two prose gaps against D4's own "names its pair": N2.

Other dev flags:

  • The service contract sits in spec/data, not spec/contracts: S2.
  • Clause-② measured yes (widening) against the claim's no: right as measured; amendment 7021881794 records it.
  • Files beyond the claimed surface (three ADR anchors, the regenerated surfaces and references, the two ALLOW entries in ui/scripts/check-spec-symbol-derivation.mjs): covered by amendments 7021881794 and 7022993369. The two ALLOW entries read right against the gate's own rule (same name, different on purpose, purpose written down, a ratchet that retires them). They exist only because spec/data now exports isWorkingDay and addWorkingDays; if S1 moves those functions, the entries go with them.
  • PR-body readings from the previous head: the body states which readings are from which head. No action.

SQL push-down: no finding. The resolver reads one calendar row by a pushed-down where with limit: 2, then pages its exceptions by where: { calendar: id } with a stable sort; one resolved id feeds one filter, there is no id list and no in-app join. The one-default check is a pushed-down limit: 2 read. Exception rows outside the maintained span are read and then left out by buildWorkCalendar; that is deliberate (every row is validated before it is skipped) and the volume is tens of rows a year.

④ Design judgment

M1 (must-fix) — an absent organization is answered with an elevated read that carries no organization. readContext(undefined) builds { isSystem: true } and nothing else. isSystem skips the security layer, and with no tenantId the driver receives no scope under a walled posture (driverReadScope in engine-driver-options.ts: a deny verdict projects a scope only where an active organization names one). So under isolated or group, a named code that exactly one other organization holds resolves to that organization's calendar, and the default resolves the same way when exactly one organization has one. limit: 2 refuses only when two rows answer. This contradicts four things the change itself cites:

The jsdoc's "right only where rows carry none" is a condition nothing enforces. Fix: outside the single posture an absent organization is refused ERR_WORK_CALENDAR_UNRESOLVED before any read (the engine already answers the posture in force, resolveEnginePosture); the WorkCalendarRef jsdoc, the service header and the anchor state the rule; a pin holds it. The same rule binds the hooks' elevated reads (judgeCalendar's default check and timezoneOf), whose organization comes from insertOrganization; the delta re-reads where that value comes from. Under single the behaviour stays as built. Graded must-fix and not should-fix because #35356 and #35357 are being built against this contract and ship in the same release, so no later head makes it cheaper, and because the boundary it crosses is the tenant wall.

S1 (should-fix) — P3: about 330 lines of counting logic and three error classes in the contract package, justified against an incomplete option set and a paraphrase of Prime Directive #2.

Closes one of two ways: the logic moves to @objectstack/formula (with the ledger entry, the surfaces and the two ALLOW entries following it); or a ruling on the card keeps it in spec with the formula route named and declined, and the header's sentence about PD #2 is corrected. The wall-clock primitive in spec/data is right either way.

S2 (should-fix) — the service contract is published in the wrong place under a colliding name. WorkCalendarService (interface) is exported from @objectstack/spec/data; the class of the same name is exported from @objectstack/objectql, whose own file has to alias the interface to import it. The tree keeps service contracts in packages/spec/src/contracts/ under I-prefixed names (38 of them on this head; "All interfaces should be defined in @objectstack/spec" is that barrel's header). #35356 and #35357 will type ctx.getService against this name, and renaming a published export afterwards is a breaking changeset with a migration. Fix now: IWorkCalendarService in contracts/, with WorkCalendarRef beside it or left in data.

N1 (nit) — the jsdoc on WORK_CALENDAR_MAINTENANCE_LEAD_DAYS states a fact that does not hold in most years. It says next year's holidays "are normally published" by the first of November. From memory, not checked against a source, the notice has come out after that day more often than before it, once as late as December. The number stands on the plainer reason (the notice opens around the publication window); the sentence should say that when the file is next touched.

N2 (nit) — D4's "names its pair" is met by branch, not by number. The PR body still links #35642 through a head-branch search and says the seat fills the number in; the changeset says "the second half of this change" where the maintainer reading Version Packages needs #35642. The body is a prose face and can be fixed without moving the head; the changeset line can ride the M1 push.

N3 (nit) — a resolved calendar is cached and handed out unfrozen. resolve returns the same WorkCalendar object to every caller for up to the TTL; the types are readonly and nothing enforces it at run time. A consumer that mutated exceptions would change every later answer on that node. Freeze on build, or leave as an accepted deviation.

Read and found to hold:

  • wall-clock.ts: the moved bodies equal the base's; the header says where the primitive lived and why it moved; core re-exports. D11's "no rule of their own" holds: work-calendar.ts converts only through zonedWallClockToUtcMs.
  • work-calendar.ts, the periods: a period crossing midnight is refused, 24:00 is accepted and only as an end, an empty period and an overlap are refused, ascending order is forced by the overlap test (D7, D10).
  • work-calendar.ts, the counts: every walk reads days through requireMaintained, so a calendar with no working day ends in the D8 refusal and not in a loop; workingDaysBetween is the inverse of addWorkingDays in both directions; addWorkingHours counts instants, so a period spanning a transition counts its real length (D11). A period edge that falls exactly on a skipped reading takes the primitive's earlier-candidate answer, which can move an hour between two adjacent periods; D11 rules that outcome, so it is not a finding.
  • work-calendar.ts, D2 and D8: a named code that does not exist is refused not_found and never falls through to the default; a blank name takes the default; a date outside the span is refused on both sides.
  • error-code-ledger.zod.ts: three codes, one comment that says no HTTP door answers with them yet, which matches the tree.
  • work-calendar-service.ts, the named-organization path: { isSystem: true, tenantId } on both reads is the exchange-rate reader's shape; a refusal is never cached; the cache drops on every calendar or exception write on the node and the TTL bounds the other replicas.
  • The write hooks: bound per row on insert (the engine fans a batch out row by row) and with previous bound on by-id and predicate updates alike, so the import door and bulk edits are judged. The one-default check is read-then-write and can race; the resolver refuses two defaults as ambiguous, so the race fails closed.
  • plugin.ts: the service registers in init, the hooks install in start beside the localization resolver they share a read with; engine.ts is untouched, as the claim requires.

M1 open, S1 open, S2 open on this head.

Implemented-by: claude/issue-35355-work-calendar-objects-service
Reviewed-by: isolated-l2-35641

VERDICT: FAIL

… IWorkCalendarService, no-organization refusal

Fix round 1 on the contract review of the first half of #35355 (ADR-0157).

- The arithmetic, the period parser, buildWorkCalendar and the three error
  classes move to @objectstack/formula (an edge objectql already has); spec
  keeps zonedWallClockToUtcMs, the types, the constants and the ledger codes,
  and its module header states Prime Directive #2 as schemas/types/constants
  only. buildWorkCalendar returns a frozen calendar.
- The service contract becomes IWorkCalendarService in
  @objectstack/spec/contracts; the objectql class keeps its name.
- Outside the single tenancy posture (resolveEnginePosture), a computation that
  names no organization is refused ERR_WORK_CALENDAR_UNRESOLVED
  (no_organization) before any read; single is unchanged. The hooks take the
  organization from the session and read nothing without one outside single.
- The 60-day lead's note no longer asserts a publication date.
- The gantt's two ALLOW entries go: the spec no longer exports those names.
- The changeset names the pair, #35641/#35642, and adds @objectstack/formula.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb
…om the session

A seed or an import writes under its organization's tenant, so its session
names it; the hooks no longer branch on the caller. The test read double
scopes by tenant in a step of its own, so the where-matcher gate judges its
matcher as before.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4

维护者速读

  • 用户能看到什么变化:与上一版相同,暂时没有;工作日历计算仍要等设置页那一半上线才用得上。
  • 为什么做:合同复审要求三件事:没指明组织时不许跨组织读日历;计算逻辑从协议包搬到公式包;服务接口放进统一的契约目录。
  • 出错会怎样:已修好;没指明组织的请求现在直接拒绝,不会读到别的组织的日历。
  • 要你做什么:无。
  • 席位意见:通过;只差合并一次主干(主干已领先 25 个提交,其中两个改了同样的生成文件),重新跑绿后交席位做合同复审。

席位核对

L1-a delta: ACCEPT, one item before the L2 · head e8af40289106e5f37f73c64a18ee48254d982d5f (delta over ad45d084f4, my record 7022981176; contract review 7023325199 FAIL; ruling record 7023403692) · K=25 · merge-tree clean · not governed · 2,161 lines · CI 62 success, 12 skipped, 0 failed · 2026-11-19T23:53Z

Surface. Amendment 7023393749 adds packages/formula/** for this move only and lifts the claim's fence there. #35356 is still unclaimed, with no branch. The amendment also adds packages/spec/src/contracts/**. ui/scripts/check-spec-symbol-derivation.mjs is back to main's bytes: no diff against the merge base, which also retires my earlier R1 for that file.

M1 (ruling 4): closed.

  • resolve() reads the posture, from options.posture or else enginePostureOf(getEngine()) through the engine's own resolveEnginePosture. Outside single, a ref with no organization is rejected ERR_WORK_CALENDAR_UNRESOLVED (no_organization) before the cache key is built, so no cached calendar is served to it. single still reads unscoped.
  • The hooks read in ctx.session.organizationId on insert and in the stored row's organization_id on update. Outside single, a write with no organization makes no elevated read.
  • New describes:
    • no organization, outside single, per posture: a code or a default only another organization holds is refused before any read;
    • single CONTROL;
    • the engine posture read;
    • the calendar hooks take the organization from the session: a member's create, a system writer, and an isolated write naming no org that reads nothing.

S1 (ruling 3): closed, behaviour-preserving. I compared the old packages/spec/src/data/work-calendar.ts at ad45d084f4 with the new packages/formula/src/work-calendar.ts function by function: 24 of 26 bodies are identical. The two that differ are the N3 freeze in buildWorkCalendar (new frozenPeriods) and WorkCalendarUnresolvedError with the new reason and its unresolvedMessage. @objectstack/formula still depends only on cel-js and @objectstack/spec, so no new edge. Spec keeps constants, codes, types and the pattern and lead-days only. The ledger staying under @objectstack/spec is the reported deviation; the provenance gate is green.

S2: closed. IWorkCalendarService, WorkCalendarRef and WORK_CALENDAR_SERVICE are in packages/spec/src/contracts/work-calendar-service.ts, with api-surface/contracts.json and export-origins/contracts.json regenerated, and the objectql class implements it.

N1–N3: closed per the relay. The changeset adds @objectstack/formula patch, and the ruling keeps patch.

Observation (no action; for the contract delta). On insert, a row whose organization_id differs from the session's gets read: false. The timezone fill and the one-default judgement are then skipped. The missing timezone fails loud, as required at validation. A second default would pass the write door, but resolve then refuses that org ambiguous, never picks one. This holds as long as seeds and imports write under their organization's session, which the module note asserts.

R1 (before the L2): merge main and re-run green. K=25 is past the 15 line. #35581 and #35583 have both merged and touch api-surface/data.json, export-origins/data.json and spec/data/index.ts, so regenerate those on the merged tree. If the merge needs more than that regeneration, the new head needs a delta L1. Otherwise the green head goes straight to the seat.

Routing. Seat 5's contract delta at CONTRACT_REVIEW_TIER on the merged head. Then data-1 lands it, and #35642 follows, retargeted to main (ruling order).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CbUb7TcZK1XUAddUmQ

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 28fca759a93407cb2f86f55fea3f55cf715d8324
Local-runs: none
Scope: packages/spec/src/api/error-code-ledger.zod.ts, packages/spec/src/contracts/index.ts, packages/spec/src/contracts/work-calendar-service.ts, packages/spec/src/data/index.ts, packages/spec/src/data/wall-clock.ts, packages/spec/src/data/work-calendar.ts + packages/formula/src/work-calendar.ts, packages/formula/src/index.ts, packages/objectql/src/work-calendar-service.ts, packages/objectql/src/plugin.ts, packages/objectql/src/index.ts, packages/core/src/utils/datetime.ts, scripts/adr-anchors/packages__formula__src__work-calendar.ts.json, scripts/adr-anchors/packages__objectql__src__work-calendar-service.ts.json, scripts/adr-anchors/packages__spec__src__data__wall-clock.ts.json

Delta d1 on PR #35641 (card #35355), over my record 7023325199 on head ad45d084f4. One record for two steps: the fix round, which ends at e8af402891, and the merge of main on top of it, which is this head. Read: the three commits of the round and their net diff against the previous head, the merge commit against both of its parents, ruling record 7023403692, claim amendment 7023393749, dev report 7025547193, the L1 delta 7025611951, and the cited engine and security code in the head tree.

Check-runs on this head: 60 success, 10 skipped, none failed, none pending. On the fix-round head e8af402891 before the merge: 62 success, 12 skipped, none failed.

Fix-round scope: three commits, no merge commit among them. Every path that moved is in the fix order or in amendment 7023393749 (packages/formula/**, packages/spec/src/contracts/**). No package.json and no lockfile moved. ui/scripts/check-spec-symbol-derivation.mjs is back to main's bytes.

The merge, judged on the tree:

  • Parents. First parent is e8af40289106e5f37f73c64a18ee48254d982d5f, the fix-round head. Second parent is 03865ae9952e33c2de912f9b0fb0b1a369cd312a, which is an ancestor of main, 25 commits past the old merge base.
  • Tree. The head tree is identical to the plain three-way merge of the two parents, which has no conflict. So the merge commit carries no hand edit, and the two regenerated files are byte for byte what the merge of both sides gives.
  • Paths both sides touched: three. packages/spec/api-surface/data.json, packages/spec/export-origins/data.json and packages/spec/src/data/index.ts.
  • The two generated files hold exactly the union of both sides: the 11 entries main added and this PR's 15, with no entry of the base dropped and none invented. A correction to the area's account: the 11 are not all unit exports. Seven come from standard-units.ts and four from user-action-transfer.ts, two separate changes on main. Nothing follows from it for this PR.
  • data/index.ts takes main's two export * lines beside this PR's two.
  • Of the PR's own files, only those three differ between the fix-round head and this head. The PR's file list is the same 25 paths. What main brought into objectql and plugin-security in these 25 commits does not touch the code this review rests on (the posture resolver, the write wall's payload check, the insert and update hook order).

Everything below was judged on the fix-round head and holds unchanged on this one.

M1: closed
S1: closed
S2: closed
N1: closed
N2: closed
N3: closed

① Derived judgments

  1. @objectstack/spec/data now keeps 15 of the names the first head added: six constants, seven types, and the two wall-clock functions. The 17 that left (the three classes, the twelve functions, WorkCalendarRef, the service interface and the service name) were never published, so nothing is narrowed against main. Right. A correction to my first record: it counted 33 new exports and 14 functions on the old head; the right counts were 32 and 13.
  2. @objectstack/spec/contracts gains IWorkCalendarService, WorkCalendarRef and WORK_CALENDAR_SERVICE. Right.
  3. @objectstack/formula gains 14 exports: the three error classes, isWorkCalendarRefusal, and ten functions. Right as a widening, on a package that already depended on spec and on nothing else new.
  4. WorkCalendarUnresolvedReason gains no_organization. The code set of ApiErrorSchema.code is the same three codes as before. Right.
  5. The ledger entry stays under @objectstack/spec. Right, see ③.
  6. Metadata-protocol: none still holds: nothing an author can write changed.

② Semver level

Right. The changeset adds '@objectstack/formula': patch and keeps spec, objectql and core at patch, which is what Metadata-protocol: none requires. Its body now names where each part lives.

Clause-②: yes (widening) — correct, unchanged.

③ Boundary flags

  • The ledger entry stays under spec (the area's deviation): right. My first record said the entry would move if the classes moved. What decides the owner is where the wire value is spelled: the three code constants stay in spec/data/work-calendar.ts under ruling 3, formula's classes carry them by reference, and the provenance gate attributes a code to the package whose source spells it. The ledger comment now says where the classes are. The gate is green on this head, as it was before the merge.
  • The hooks take every writer's organization from the session, system writers included (the dev's step past the seat's text): right as the source of the organization. Its cost on a create that names another organization is S3.
  • enginePostureOf is exported from the service file and not from the package index: right; the service and hooks default to it and plugin.ts wires nothing.
  • The merge of main: stated by the area, and true on the tree as set out above. It is the mechanical merge and nothing else.
  • The L1 delta's observation (a create whose row names an organization other than the session's skips the time-zone fill and the one-default check): answered in S3.

SQL push-down: no finding. No read was added; the resolver now refuses before its first read where it has no organization.

④ Design judgment

M1, as fixed.

  • resolve reads the posture first and, outside single, rejects an absent, null or empty organization with ERR_WORK_CALENDAR_UNRESOLVED, reason no_organization, before the cache key is built and before any read. single reads as before.
  • The posture is the engine's own reading: enginePostureOf hands the engine's provider to resolveEnginePosture, read per call, and an unreadable posture answers isolated.
  • The rule is stated in the WorkCalendarRef jsdoc (now in contracts/), the service header and the anchor, and the anchor's sentence "one organization's calendar never counts another's" is now true of the code.
  • Pins: under isolated and under group, a code and a default that only another organization holds are both refused with zero reads, with a named-organization CONTROL; a single CONTROL; and the engine's own posture on a real engine.
  • The hooks take the organization from the session. On insert the one-default check and the time-zone read run in the session's organization or not at all; on update they run in the stored row's own organization, which the engine read under the write's own scope. Outside single no hook reads without an organization. A refusal quotes only a calendar of the organization the read ran in.

S1, as fixed. The period parser, buildWorkCalendar, the four counts and the three classes are in packages/formula/src/work-calendar.ts. Compared with the first head's text, the logic is the same except for the two intended changes (the no_organization message, the freeze). Formula's dependencies are unchanged, so no edge was added; objectql imports over the edge it had. The spec module's header now states Prime Directive #2 as it is written.

S2, as fixed. IWorkCalendarService sits in packages/spec/src/contracts/work-calendar-service.ts beside its ref type and service name; the objectql class keeps its name and implements it.

N1, N2, N3, as fixed. The lead-days jsdoc no longer asserts a date. The changeset and the PR body both say "Not released alone; pair #35641/#35642". buildWorkCalendar returns a calendar frozen down to its periods, and a pin holds both levels.

S3 (should-fix) — a create that names an organization other than the session's passes the write door with its default unjudged. insertReadOrganization answers read: false for such a row, so the hook skips the time-zone fill and the one-default check and lets the row through.

  • Who reaches it. Not an ordinary member under isolated: the tenant wall judges a supplied organization before the hooks and refuses a foreign one. The sys_ namespace adds no guard of its own for this column. The writers that do reach it are ones the platform admits: a member under group creating in a sibling organization of their access set, a platform administrator the wall exempts, any writer under single whose row names an organization, and a system writer whose context carries a different organization or none while the row names one (a seed load with no organization of its own, the runtime's fallback seed insert).
  • What follows. The skipped time-zone fill is loud: feat(platform-objects): working calendars in Setup — sys_work_calendar and sys_work_calendar_exception (ADR-0157, part 2 of 2) #35642 declares the column required. The skipped default check is not: a second default is stored, the writer is told the write succeeded, and from then on every computation in that organization that takes the default is refused ambiguous until an administrator clears one flag. The resolver never picks one, so no deadline is wrong; the organization's default is simply out of service, caused by a write that was answered as fine.
  • Why it is a finding. The service's rule this round is "cannot scope it, refuse it". The door's rule for the same situation is "cannot scope it, let it pass". The header still says the hooks judge every write for one default per organization and does not say that this class is not judged. The first head judged these creates; this round stopped, for a good reason, without putting a refusal in the check's place.
  • Mainstream writers are not affected either way: Setup and API creates in the active organization, pinned seed loads and sole-organization seed loads (the loader writes each row under its organization), and imports (only exception rows import, and the exception hooks read nothing) all carry a session organization equal to the row's.

Closes one of two ways. Preferred: a create whose row names an organization other than the session's and sets is_default: true is refused at the door, with no read, and told to write under that organization or to set the default by update (which is judged in the stored row's organization); the pin that today asserts the silent pass asserts the refusal. Or: a ruling on the card accepts the skip, and the service header and #35642's object note say that such a create's default is judged only at resolution.

N4 (nit) — the posture is read through a member the engine declares private. enginePostureOf reaches tenancyPostureProvider by a structural cast, because engine.ts is fenced and the engine's resolveEnginePosture is private. A rename would not fail to compile; the real-engine pin would catch it. Accepted as it is; a public reader on the engine is the clean form when that file is next open.

Carried to #35642's tests on the real objects: no pin drives the update hook through a real engine under a walled posture, where its organization comes from the stored row.

No must-fix. S3 open on this head.

Implemented-by: claude/issue-35355-work-calendar-objects-service
Reviewed-by: isolated-l2-35641

VERDICT: PASS

…r organization

A create whose row names an organization other than the session's is not
read for, so its one-default judgement cannot run where the row lands. When
it sets is_default it is now refused at the door, before any read, with
400 VALIDATION_FAILED on is_default: write it under that organization, or
set the default afterwards by an update, which is judged in the stored row's
own organization. The same create without a default passes as before. The
hook header says a seed that sets a calendar's default must load pinned to
its organization or set the default by an update afterwards.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CbUb7TcZK1XUAddUmQ

Contract review

VERDICT: PASS

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: f502d9238ccaf3ceee589ee56b4858727a61c807
Range: 28fca759a93407cb2f86f55fea3f55cf715d8324..f502d9238ccaf3ceee589ee56b4858727a61c807, one commit, no merge
Local-runs: none
Scope: packages/objectql/src/work-calendar-service.ts, packages/objectql/src/work-calendar-service.test.ts, .changeset/35355-working-calendar-service.md

Delta d2 on PR #35641 (card #35355), over my record 7026479156. Narrow: this range only. Read: the commit's diff, the hook code around it in the head tree, dev report 7027000220, the PR body. Check-runs on this head: 62 success, 12 skipped, none failed, none pending.

S3: closed

No must-fix, no should-fix.

① Derived judgments

No export, no ledger entry, no schema and no file under packages/spec moved in this range. The one behaviour change is a refusal on objects that are not registered until #35642, so nothing is narrowed against main.

② Semver level

Unchanged and right: every entry stays patch under Metadata-protocol: none. The changeset's write-door line now names the refusal and matches the code.

Clause-②: yes (widening) — unchanged by this range.

③ Boundary flags

  • Reusing VALIDATION_FAILED: right. The refusal goes out through the door's one envelope, 400 VALIDATION_FAILED, with a field entry is_default / invalid_value, the same field and field code as the second-default refusal. A client that handles the one handles the other, the form marks the field the writer has to change, and it joins the door's other problems in one answer. It is not a permission answer: the writer was admitted, and it is the combination on the row that the door cannot judge. A ledger code of its own would add a public value for a case that already has a field to point at.
  • Scope: three files, all in the fix order. Nothing else moved.

SQL push-down: no finding. The range adds no read.

④ Design judgment

S3, as fixed.

  • A create whose row names an organization other than the session's and sets is_default: true is refused before any read. On that path the time-zone fill is not asked and the one-default read is not made; the refusal is built from a fixed text.
  • The reason names no calendar and no organization. It tells the writer the two ways through: create it while working in that organization, or create it without Default and set Default by an edit.
  • CONTROL holds: the same create with is_default: false passes with zero reads and no time-zone fill. A second CONTROL keeps the session's own organization read and judged.
  • The system-writer leg is pinned too: with no organization of its own, a default is refused and a plain create passes, neither reading.
  • Ablation, by reading: with the new branch off, the two member pins and the system-writer pin lose their refusal and the other 21 are untouched. That agrees with the 3 red and 21 green the dev reports. The file holds 24 tests.
  • The header note is there and is accurate: a seed that sets a calendar's default loads pinned to its organization, or sets the default by an update afterwards. No seed in feat(spec, objectql): working-calendar service, arithmetic and refusal codes (ADR-0157, part 1 of 2) #35641 or feat(platform-objects): working calendars in Setup — sys_work_calendar and sys_work_calendar_exception (ADR-0157, part 2 of 2) #35642 sets one today.
  • The hooks take the organization from the session; an update reads in the stored row's own organization. Both are unchanged by this range.

N5 (nit) — the update-route pin does not separate the stored row's organization from any other. The code is right: the update hook reads in the stored row's organization and looks nowhere else. The new pin holds the session and the stored row in one organization, so it shows that an edit setting Default is judged, that it reads once, and where; it does not show that the organization is the stored row's. It closes in two lines here (a session in another organization, the read still in the stored row's), or in #35642's real-engine pin, whichever lands first.

N6 (nit) — the PR body has two stale lines. Its round section and write-door bullet match the code. Its two-minute check still expects 23 passed where the file now holds 24, and its acceptance notes still say main was not merged, above a section that says it was.

Deferring the real-engine pin of the update hook under a walled posture to #35642: acceptable. In #35641 alone the hooks are bound by name to objects that do not exist, so no caller can reach the update hook on a real object until #35642 registers them, and the two are not released apart. The pin belongs with the real objects. Carried to #35642's round as a condition of that PR, not of this one: drive the edit through a real engine under isolated or group, from a session whose organization is not the stored row's, and assert the read ran in the stored row's organization. That one pin also closes N5.

N4 stands as accepted.

Implemented-by: claude/issue-35355-work-calendar-objects-service
Reviewed-by: isolated-l2-35641

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb

Landing · area data-1 · 2026-11-20T01:34Z

reading value
Head f502d9238c (fix round 2 over the main merge 28fca759a9, K=25 at merge). CI green: 62 success, 12 skipped
Reviews L1-a 7022981176, delta 7025611951 ACCEPT. Seat contract L2 7023325199 (FAIL) → ruling 7023403692 → delta d1 7026479156 PASS (S3) → delta d2 7027578203 PASS. N4 accepted; N5 carried to #35642; N6 (body) fixed
Scope Not governed; 2204 lines; claim 7013077388 with amendments 7021881794, 7022993369, 7023393749
Pair Not released alone; pair #35641/#35642 (ADR-0157 D4). #35642 is retargeted to main and lands next

State: ready → auto-merge (merge queue). Part of #35355; the card closes with #35642.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 20, 2026 01:34
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit ed906d5 Nov 20, 2026
79 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-35355-work-calendar-objects-service branch November 20, 2026 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation protocol:data size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants