Repository navigation
feat(spec, objectql): working-calendar service, arithmetic and refusal codes (ADR-0157, part 1 of 2) - #35641
Conversation
…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
…lugin pins 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
📓 Docs Drift CheckThis PR changes 4 package(s): 57 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 14 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 183 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # 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
|
…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
|
repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4 维护者速读
席位核对L1-a: ACCEPT, one text-only item · head 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 Arithmetic read (
Service and hooks (
Pins. 37 R1 (text only, no push, no fresh L1): claim amendment for For the seat's contract L2 (my observations, not required items).
Routing. Clause-② yes (widening) with a |
|
repo:objectstack#5 · os-bill · session_01Utp6CbUb7TcZK1XUAddUmQ Contract reviewServed-tier: 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 ① Derived judgments
② Semver levelRight as written. Clause-②: yes (widening) — correct, in the PR body and in the changeset body. ③ Boundary flagsThe six design choices (the dev's
The three points the L1 record (7022981176) left for this review:
Other dev flags:
SQL push-down: no finding. The resolver reads one calendar row by a pushed-down ④ Design judgmentM1 (must-fix) — an absent organization is answered with an elevated read that carries no organization.
The jsdoc's "right only where rows carry none" is a condition nothing enforces. Fix: outside the 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 S2 (should-fix) — the service contract is published in the wrong place under a colliding name. N1 (nit) — the jsdoc on 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 N3 (nit) — a resolved calendar is cached and handed out unfrozen. Read and found to hold:
M1 open, S1 open, S2 open on this head. Implemented-by: 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
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
|
repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4 维护者速读
席位核对L1-a delta: ACCEPT, one item before the L2 · head Surface. Amendment 7023393749 adds M1 (ruling 4): closed.
S1 (ruling 3): closed, behaviour-preserving. I compared the old S2: closed. N1–N3: closed per the relay. The changeset adds Observation (no action; for the contract delta). On insert, a row whose R1 (before the L2): merge Routing. Seat 5's contract delta at |
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb
|
repo:objectstack#5 · os-bill · session_01Utp6CbUb7TcZK1XUAddUmQ Contract reviewServed-tier: Delta d1 on PR #35641 (card #35355), over my record 7023325199 on head Check-runs on this head: 60 success, 10 skipped, none failed, none pending. On the fix-round head Fix-round scope: three commits, no merge commit among them. Every path that moved is in the fix order or in amendment 7023393749 ( The merge, judged on the tree:
Everything below was judged on the fix-round head and holds unchanged on this one. M1: closed ① Derived judgments
② Semver levelRight. The changeset adds Clause-②: yes (widening) — correct, unchanged. ③ Boundary flags
SQL push-down: no finding. No read was added; the resolver now refuses before its first read where it has no organization. ④ Design judgmentM1, as fixed.
S1, as fixed. The period parser, S2, as fixed. 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". S3 (should-fix) — a create that names an organization other than the session's passes the write door with its default unjudged.
Closes one of two ways. Preferred: a create whose row names an organization other than the session's and sets N4 (nit) — the posture is read through a member the engine declares private. 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: 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
|
repo:objectstack#5 · os-bill · session_01Utp6CbUb7TcZK1XUAddUmQ Contract reviewVERDICT: PASS Served-tier: 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 judgmentsNo export, no ledger entry, no schema and no file under ② Semver levelUnchanged and right: every entry stays Clause-②: yes (widening) — unchanged by this range. ③ Boundary flags
SQL push-down: no finding. The range adds no read. ④ Design judgmentS3, as fixed.
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 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 N4 stands as accepted. Implemented-by: |
|
repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb Landing · area data-1 · 2026-11-20T01:34Z
State: ready → auto-merge (merge queue). Part of #35355; the card closes with #35642. |
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)
singletenancy posture (the engine's own reading,resolveEnginePosture), a computation whoseorganizationIdis absent is refusedERR_WORK_CALENDAR_UNRESOLVEDwith reasonno_organizationbefore any read, the cache's included;singleis unchanged. The rule is stated in theWorkCalendarRefjsdoc, 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.buildWorkCalendar, the four counts,isWorkingDay,workingPeriodsOn,exceptionDayOf,calendarDayOfand the three error classes move to@objectstack/formula(packages/formula/src/work-calendar.ts). The edge already existed:@objectstack/objectqlandplugin-approvalsdepend on formula, and formula depends on spec, so no dependency edge is new. Spec keepszonedWallClockToUtcMs, 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 inui/scripts/check-spec-symbol-derivation.mjsare dropped, since spec no longer exports those names; that file is back to itsmainbytes.IWorkCalendarService,WorkCalendarRefandWORK_CALENDAR_SERVICEare inpackages/spec/src/contracts/work-calendar-service.ts, beside the other service contracts. The objectql class keeps its name andimplements IWorkCalendarService.buildWorkCalendarreturns a frozen calendar (the calendar, the weekly lists, every period, the exceptions and each day), so a cached calendar answers every caller alike.@objectstack/spec. The three code constants stay in spec, andcheck:error-code-provenanceattributes a code to the package whose constant spells it. Formula's error classes stamp it by reference.patch(Metadata-protocol: none);@objectstack/formulais added to the changeset aspatch.Main merge and fix round 2 (contract delta 7026479156, PASS with S3; seat ruling: refuse)
28fca759a9mergesmain(03865ae995, K=25); the merge regeneratesapi-surface/data.jsonandexport-origins/data.jsonand 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 setsis_default: true, before any read, with400 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) atf502d9238c: 617 files, 13947 tests passed. 2204 lines againstmain.Comments read (through 7023325199)
content/docs,skillsordocs(ADRs aside) names the moved names:git grepfor the arithmetic, the service, the contract constant andzonedWallClockToUtcMsfinds none. The reference pages are generated, andcheck:docspasses.mainbytes.patch, M1, and the pair sentence.What changes
packages/formula/src/work-calendar.ts(new).isWorkingTime,addWorkingDays,workingDaysBetweenandaddWorkingHoursare pure functions over a resolved calendar, so Working calendars ③: formula functions addWorkingDays / workingDaysBetween / addWorkingHours #35356 can call them synchronously.parseWorkPeriodsenforces D7 and D10: a period crossing midnight is refused,24:00is a legal end, and overlapping or malformed text is refused.buildWorkCalendarvalidates a stored row and its exceptions, and builds frozen.packages/spec/src/data/work-calendar.tsandwall-clock.ts.zonedWallClockToUtcMs,wallClockToUtcMsandWallClockPartsmove from@objectstack/corebyte-identical, and core re-exports all three (D11).ERR_WORK_CALENDAR_UNRESOLVED,ERR_WORK_CALENDAR_NOT_MAINTAINEDandERR_WORK_CALENDAR_INVALID, each a 400.packages/objectql/src/work-calendar-service.ts, registered aswork-calendarfrom 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 outsidesingle, caches with a 60 s TTL, drops the cache on any calendar or exception write, and never caches a refusal.400 VALIDATION_FAILEDwith an ADR-0114 field code: a period crossing midnight, a malformed or overlapping period,offwith periods,onwithout,maintained_throughbeforemaintained_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 withouttimezonetakes the organization's Localization zone. The hooks take the organization from the session.Service API for #35356 and #35357
@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) andinvalidate().refisWorkCalendarRef,{ organizationId, calendar? }.WORK_CALENDAR_SERVICE(work-calendar); the implementation isWorkCalendarServicein@objectstack/objectql.@objectstack/formula: the same four computations taking a resolvedWorkCalendarfirst, plusbuildWorkCalendar,parseWorkPeriods,isWorkingDayandworkingPeriodsOn. The conversion iszonedWallClockToUtcMsfrom@objectstack/spec/data.@objectstack/formula:WorkCalendarUnresolvedError, with reasonnot_found,no_default,ambiguousorno_organization.WorkCalendarNotMaintainedErrorandWorkCalendarInvalidError.isWorkCalendarRefusal.@objectstack/spec/dataconstants.Tests
Head
e8af402891. Each run below went throughos-verify-lockand read VERDICTcommand-exit 0. Commands are--maxWorkers=2.--project localis the package's owntestscript.@objectstack/objectqlplus its dependency closure; spec, formula and core among them.@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 aftercheck:generated --fixrewrote and re-checkedapi-surface/andexport-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):isolatedand undergroup. A named code held only by another organization is refusedno_organization, and so is a default held only by another organization. An empty-string organization is refused the same way, and so isaddWorkingDays. Each refusal reaches HTTP as 400ERR_WORK_CALENDAR_UNRESOLVED, with zero engine reads. CONTROL: naming the holding organization resolves it.single. A computation without an organization still reads, unscoped.singleand underisolated, with a CONTROL showing the session's own organization is read and judged. A system writer reads in its session's organization too.single. Underisolated, an insert and an update that name no organization read nothing. CONTROL: undersinglethe same writes are judged.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 emptygit diff HEAD. Subjects are imported by relative source path, so there is no dist leg.Gates
node scripts/pm/dispatch-gates.mjs --commandsat treee8af402891derives 132 families. Each ran with its exit code captured before any pipe, and all 132 exited 0.--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.check:error-code-provenance,check:error-code-casing,check:dispatcher-error-vocabulary.check:api-surface,check:export-origins,check:docs,check:generated.check:authorable-surface: no authorable key moved, henceMetadata-protocol: none.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.node scripts/check-platform-checklist.mjs --changed-from origin/main(exported symbols moved) exits 0, andoverlap-checkgivesVERDICT clean exit 0.743be6587f, both fixed ine8af402891:check:system-context-censusflagged 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-matchercould not lift the test double's matcher once tenant scoping shared its callback. The scoping is now a step of its own.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
resolverefusesERR_WORK_CALENDAR_UNRESOLVED(not_foundorno_default), and the hooks bind by object name.mainis merged at28fca759a9(K=25); feat(spec, platform-objects): the standard unit table and the organization unit object sys_unit (ADR-0158 U1-U3) #35581 and feat(spec): userActions.transfer, the per-object switch for the Change Owner action, and its structural eligibility #35583 shared three files with this PR (packages/spec/api-surface/data.json,packages/spec/export-origins/data.json,packages/spec/src/data/index.ts), and the two generated files were regenerated in the merge.maintained_from) stays outside both PRs.Verification
packages/objectql/src/work-calendar-service.ts:resolve(the no-organization guard) andinsertReadOrganization(the hooks' organization).packages/formula/src/work-calendar.ts:addWorkingHoursandrequireMaintained, the D8 and D11 core.packages/spec/src/contracts/work-calendar-service.ts: the contract.pnpm --filter @objectstack/objectql exec vitest run src/work-calendar-service.test.ts. Expect 24 passed, including theisolatedandgroupno-organization pins and the session pins.Generated by Claude Code