Skip to content

feat(approvals): an escalation deadline can count working time on an org calendar (clock: working_time) - #35929

Merged
objectstack-fleet[bot] merged 13 commits into
mainfrom
claude/area-a4W-35357
Nov 20, 2026
Merged

objectstack-fleet[bot] merged 13 commits into
mainfrom
claude/area-a4W-35357

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread
Fixes #35357
Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: follow-up #35931 — skills/objectstack-automation/references/state-machines-and-approvals.md (the escalation row), domain:skills sub-card, Blocked-by this PR

维护者速读

  • 用户能看到什么变化:审批节点的超时升级可以选择「按工作时间计算」,按组织的工作日历跳过夜间、周末和节假日,并计入调休补班日;日历算不出时,审批收件箱在到期时间处显示「日历算不出」和原因。
  • 为什么做:工作日历分期的第四张卡,让审批超时和工作日历一起发布,周五下午提交的审批不再在周五晚上就升级。
  • 出错会怎样:只影响选了「工作时间」的审批节点;默认仍按自然小时,已在途的审批到期时间不变,可以直接撤回。
  • 要你做什么:无。

What changes

ADR-0157 D5, D9 and D12, on the approval escalation:

  • Spec (ApprovalEscalationSchema): two optional keys. clock: 'wall_clock' | 'working_time', default 'wall_clock' (a stored snapshot carries no clock, so every open request keeps its deadline), and calendar, a working-calendar code (WORK_CALENDAR_CODE_PATTERN). The timeoutHours describe text and comment no longer say the platform ships no calendar; they say the clock decides how the hours count. The describe first sentences stay in business words.
  • Runtime (plugin-approvals): one deadline function, ApprovalService.slaDeadline, serves both the escalation sweep and the request read projection (D12). wall_clock is the unchanged slaDueAt (created_at + timeoutHours elapsed). working_time counts timeoutHours working hours from created_at through the calendar service (WORK_CALENDAR_SERVICE, resolved lazily like the other providers), naming the request's own organization_id and escalation.calendar; the service resolves the named code, else the organization default, else refuses. It is recomputed on every sweep and every read, never stored. slaDueAt answers nothing for a working_time escalation, so no path can fall back to wall-clock hours (D2). Single-shot escalation (ADR-0042 §1) is untouched: the escalate audit row is still the only marker, and it does not record the due time.
  • Cannot answer (D9): a calendar refusal (ERR_WORK_CALENDAR_UNRESOLVED, ERR_WORK_CALENDAR_NOT_MAINTAINED, ERR_WORK_CALENDAR_INVALID) is not an escalation: the sweep skips the request, counts it in one warn per sweep, and asks again next sweep. A kernel with no calendar service refuses the same way. New served field (additive): sla_due_refusal on ApprovalRequestRow (code, reason on unresolved, calendar, date on not-maintained, message), present in place of sla_due_at.
  • Lint (@objectstack/lint): approval-escalation-calendar-without-working-time (error) refuses a calendar beside the wall clock, where nothing reads it. Static only: no check that the calendar exists (D9).
  • Studio: the approval inspector's escalation block gains "Count hours as" (wall-clock / working hours) and "Working calendar", which shows only under working time, from both descriptor sources (SIBLING_GATES in json-schema-to-fields.ts serves the hand-written table and the engine-published configSchema). zh overlay added; the timeoutHours zh help no longer says there is no calendar.
  • Console inbox: where the SLA countdown sits, a pending row with sla_due_refusal shows "Calendar can't compute" with the reason (no calendar "X" / no default calendar / not maintained for DATE / fix the calendar in Setup), in all eleven locale packs (zh-Hans: 「日历算不出」). The zh-Hant pack is generated from zh-Hans by gen:zh-hant, never hand-edited.
  • Docs: content/docs/automation/approvals.mdx (Timeouts and escalation) and the generated reference page. ADR anchor for the deadline function.

Not released alone: ships in the same release as the calendar objects and service (#35355) and the working-day formula functions (#35356), ADR-0157 D4.

Evals

None: no agent-facing prompt or skill text changes here. The skills text is owed as a follow-up (the Skills-docs: line).

Tests

  • approval-service-sla-calendar-clock.test.ts, a new top-level describe on the REAL WorkCalendarService over a read double: Friday 17:00 + 4 working hours with Monday a holiday fires Tuesday 12:00 and not at any earlier instant; before a make-up (调休) Saturday it fires that Saturday 12:00; a holiday entered later moves the deadline (D12); a missing calendar serves sla_due_refusal (not_found), escalates nothing past every deadline, and the next sweep escalates once the calendar exists; no_default and ERR_WORK_CALENDAR_NOT_MAINTAINED (with its date); no calendar service refuses; an explicit wall_clock equals the default. The four existing wall-clock pins are unchanged and green.
  • Lint: the finding fires on a calendar with no clock and with wall_clock; its control (working_time with a calendar that does not exist, and working_time with none) is clean.
  • Inspector: the calendar is hidden on the default and an explicit wall clock, shown under working time, and a typed code round-trips through ApprovalNodeConfigSchema, from both descriptor sources. Inbox: the reason renders in place of the countdown in English and zh-CN, and a served due time keeps its countdown.
  • Re-measured pins: the inspector's gated-field census 33 → 35, the declared-default surface ten → eleven (escalation.clock), the escalation round-trip now parses with clock: 'wall_clock' materialized, and the de quote-pairing pin 118 → 119 (the new approvalsInbox.slaCalendarNotFound adds one correctly paired „{{calendar}}“ span, U+201E … U+201C; ledger line added, assertion unchanged).
Ablations (both red, both restored to HEAD by `scripts/ablation-replace.mjs`)
  • Working-time branch (slaDeadline answers wall-clock for every clock): 6 of 12 tests red, the six working_time cases; restore blob equals HEAD, git diff HEAD empty.
  • Cannot-answer guard (a refusal no longer continues the sweep): 3 of 12 red, each expected { scanned: 1, escalated: 1 } to match object { escalated: +0 }; restored to HEAD. A first attempt whose replacement was a substring of its anchor was refused by the tool before running and is not counted.

Verification

Read first: packages/plugins/plugin-approvals/src/approval-service.ts (slaDeadline, projectWorkingTimeDue, the runEscalations hunk), packages/spec/src/automation/approval.zod.ts, ui/apps/console/src/pages/system/ApprovalsInboxPage.tsx (slaRefusalLabel).

Two-minute check: pnpm --filter @objectstack/plugin-approvals exec vitest run src/approval-service-sla-calendar-clock.test.ts shows 12 passed.

Local readings

Fix round on head f079e34 (origin/main merged at 753091e, zh-Hant.ts regenerated, de pin re-measured), in this container (shared box), through scripts/pm/os-verify-lock.sh:

  • zh-hant-generated.test.ts red before the regeneration (src/locales/zh-Hant.ts is stale, 1 failed | 10 passed), green after; de-quote-pairing-3876.test.ts red with the old pin (expected 119 to be 118, { open: 119, close: 119, rdq: 0 } vs 118), green after.
  • vitest run packages/i18n/ (ui root): Test Files 105 passed (105), Tests 1957 passed, 13 skipped.
  • pnpm check:i18n: OK, 10 packages, all bundles in sync.
  • node scripts/pm/dispatch-gates.mjs --commands (131 families) on f079e34, each with its exit code; --ran: 131 derived, 131 run, 0 NOT-MEASURED (a derived zero). Eight families first refused for missing builds (exit 3, and ui scripts/ red for an unbuilt @objectstack/client) and are exit 0 after building ./packages/**.
  • overlap-check: VERDICT clean.

Earlier readings, on head 1d5c6fc:

  • pnpm --filter @objectstack/spec test: Test Files 866 passed (866), Tests 27798 passed, 1 todo.
  • pnpm --filter @objectstack/plugin-approvals exec vitest run: Test Files 125 passed (125), Tests 1793 passed (one commit earlier; the later commits touch only this package's clock test file, rerun green: 12 passed).
  • pnpm --filter @objectstack/lint exec vitest run: Test Files 222 passed (222), Tests 9346 passed.
  • ui: vitest run packages/app-shell/src/views/metadata-admin/inspectors/ apps/console/src/pages/system/ApprovalsInboxPage: Test Files 256 passed (256), Tests 3254 passed, 1 skipped; vitest run scripts/ (ui): 172 passed, 2 skipped.
  • Typecheck: @objectstack/spec, @objectstack/lint, @objectstack/plugin-approvals (incl. check:test-typecheck) green; type-check of @object-ui/i18n, @object-ui/app-shell, @object-ui/console green after building their closure.
  • pnpm --filter @objectstack/spec check:generated --fix: regenerated content/docs/references/** only; every other artifact current.
  • pnpm check:i18n: OK, 10 packages, all bundles in sync.
  • node scripts/pm/dispatch-gates.mjs --commands (131 families) run on this head, each exit 0; --ran reconciliation: 131 derived, 131 run, 0 NOT-MEASURED (a derived zero, every line carries its exit code).
  • node scripts/pm/overlap-check.mjs --branch=claude/area-a4W-35357: VERDICT clean (origin/main, feat(messaging): Slack DM delivery — slack channel, per-person link store, approval requests by DM (Part of #34730) #35789, fix(plugin-list): a list's column header opens a menu and keeps a multi-level sort; a sort chip opens the sort panel #35909, feat(console)!: one way to open a record from an object's list; navigation.mode deprecated there #35910).
  • Size (on f079e34, against merged origin/main): +875 / -48 across 35 files, tests and generated files included.

Acceptance notes

  • The served shape is additive: sla_due_refusal is new and optional; sla_due_at keeps its meaning under wall_clock.
  • The escalate audit row does not record the due time it fired on (the ADR left this to this card); the deadline is never stored anywhere.
  • A deadline is computed once per row per read and sweep. A calendar the service answers is served from its 60-second cache; a refusal is never cached, so every read and sweep asks again; reads of decided requests compute it too, so the projection stays one function for every status.
  • The inbox reason is localized from the refusal's code; the server's English message is served but not shown.
  • origin/main is merged in (at 753091e, a clean merge); overlap-check reports clean merges against origin/main, feat(messaging): Slack DM delivery — slack channel, per-person link store, approval requests by DM (Part of #34730) #35789, the open locale-pack PRs and the two open lint PRs.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4czKnDE6hsyXQzB9wB2
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4czKnDE6hsyXQzB9wB2
… load at collection

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

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/lint, @objectstack/plugin-approvals, @objectstack/spec, touching 26 documentable anchor(s). ⚠️ 3 changed file(s) yielded no anchor (packages/lint/src/index.ts, packages/spec/authorable-defaults/automation.json, packages/spec/authorable-surface/automation.json), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

6 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/api/client-sdk.mdx (via not_found (literal, a string literal in slaDeadline))
  • content/docs/api/error-catalog.mdx (via not_found (literal, a string literal in slaDeadline))
  • content/docs/api/index.mdx (via not_found (literal, a string literal in slaDeadline))
  • content/docs/automation/approvals.mdx (via ApprovalService (symbol, a top-level class), listRequests (symbol, a method of class ApprovalService), sla_due_refusal (symbol, a field of interface ApprovalRequestRow), sla_due_refusal (literal, a string literal in SlaDueRefusal), wall_clock (literal, a string literal in ApprovalEscalationSchema; a string literal in a comment in ApprovalRequestRow), working_time (literal, a string literal in ApprovalEscalationSchema; a string literal in a comment in ApprovalRequestRow; a string literal in a comment in ApprovalServiceOptions; a string literal in a comment in start; a string literal in a comment on a changed line; a string literal in escalationCountsWorkingTime; a string literal in validateApprovalApprovers), /api/v1/approvals/requests (route, the route ledger binds it to client method approvals.listRequests))
  • content/docs/automation/flows.mdx (via ApprovalService (symbol, a top-level class), /api/v1/approvals/requests (route, the route ledger binds it to client method approvals.listRequests))
  • content/docs/kernel/services-checklist.mdx (via /api/v1/approvals/requests (route, the route ledger binds it to client method approvals.listRequests))

⛔ 5 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v16.mdx (via listRequests (symbol, a method of class ApprovalService))
  • content/docs/releases/v17/17-0.mdx (via listRequests (symbol, a method of class ApprovalService), not_found (literal, a string literal in slaDeadline))
  • content/docs/releases/v17/17-6.mdx (via ApprovalService (symbol, a top-level class))
  • content/docs/releases/v18/18-1.mdx (via ApprovalService (symbol, a top-level class), /api/v1/approvals/requests (route, the route ledger binds it to client method approvals.listRequests))
  • content/docs/releases/v18/18-3.mdx (via /api/v1/approvals/requests (route, the route ledger binds it to client method approvals.listRequests))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 3 changed file(s) yielded no anchor (packages/lint/src/index.ts, packages/spec/authorable-defaults/automation.json, packages/spec/authorable-surface/automation.json) — pages documenting those are invisible to this run
  • 2 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 — 174 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 17ed9e7bfd65532d83109273837e4a44624dee5c → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 08d3b7996a7c4fbb18d52715131f5a8e490b05b3 — the merge of head f079e341ff364bdac211e75e39f9950987007303 into base 17ed9e7bfd65532d83109273837e4a44624dee5c, 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 08d3b7996a7c4fbb18d52715131f5a8e490b05b3 && git checkout 08d3b7996a7c4fbb18d52715131f5a8e490b05b3
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 17ed9e7bfd65532d83109273837e4a44624dee5c f079e341ff364bdac211e75e39f9950987007303 && git checkout -B drift-repro 17ed9e7bfd65532d83109273837e4a44624dee5c && git merge --no-ff f079e341ff364bdac211e75e39f9950987007303

node scripts/docs-audit/affected-docs.mjs --json 17ed9e7bfd65532d83109273837e4a44624dee5c

⚠️ 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 17ed9e7bfd65532d83109273837e4a44624dee5c → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-elon-musk · session_016WV4cwxJaQdC11ABGtTez8

L1 verdict (L1-a): ACCEPT at head f079e341ff364bdac211e75e39f9950987007303 (Fixes #35357: an approval escalation can count timeoutHours as working time on an organization calendar). It delivers the card. No blocker. Four notes below, none owed before landing.

Gates on this head: l1-face --pr 35929 CLEAN (13 items, none flagged). Check-runs at f079e34: 63 success, 11 expected skip, 0 failed, 0 pending. Lint & Repo Gates and TypeScript Type Check both success. Dogfood battery not owed (no !, no narrowing). check-governed-merges: not governed, so a4-W lands.

The card's Done-when, checked against the code and my own runs:

  • Friday 17:00 + 4 hours fires on the next working day, across a holiday and a 调休 Saturday. approval-service-sla-calendar-clock.test.ts runs on the real WorkCalendarService (objectql), not a copy. I ran it here: 12 passed. Positive control: I replaced the working-time branch of slaDeadline with the wall-clock answer, and 6 of 12 went red (the six working_time cases). Restored, 12 green. That matches the dev's ablation.
  • A calendar that can't answer does not escalate, and the read says why. runEscalations counts a refusal and continues before the single-shot check, so nothing escalates. The next sweep asks again, because refusals are never cached (work-calendar-service.ts drops a rejected entry). The read serves sla_due_refusal in place of sla_due_at. All three read paths project it: the open answer (openNodeRequest), the list read and getRequest. rowFromRequest has no other caller.
  • wall_clock unchanged. slaDueAt is the same arithmetic. A stored snapshot with no clock stays on the wall clock (escalationCountsWorkingTime reads only an explicit 'working_time'). The four existing wall-clock pins pass unchanged.
  • No silent fallback (D2). With working_time, slaDueAt answers undefined and the only other path is the calendar. A kernel with no calendar service is refused, never answered.
  • The plugin wiring, end to end. I booted a real ObjectKernel with ObjectQLPlugin, a SQLite SqlDriver, the two platform calendar objects and ApprovalsServicePlugin, and inserted one default calendar. Through the approvals service, slaDeadline returned Monday 12:00 (+08:00) for Friday 17:00 + 4 hours. A named code that doesn't exist returned the not_found refusal with its message. So ctx.getService(WORK_CALENDAR_SERVICE) resolves lazily and the SQL reads go through. (A third probe, for another organization, read the first one's calendar. That kernel had no SecurityPlugin to scope { isSystem, tenantId } reads, so this says nothing about this PR. Organization scoping is the calendar service's, from Working calendars ②: sys_work_calendar objects, calendar service and Setup page #35355.) It was a temporary file and has been deleted.
  • Lint (static only, D9). approval-escalation-calendar-without-working-time fires on a calendar beside no clock and beside wall_clock. Nothing checks that the calendar exists. I ran it: 66 passed. Positive control: with the rule switched off, its test went red (1 failed). Restored.

Scope and declarations:

  • Fixes is right: spec keys, sweep, read projection, the cannot-answer path, lint, Studio fields, inbox reason and docs are all here. The skills text goes to the Skills-docs: follow-up.
  • Skills-docs: follow-up #35931 is true. skills/objectstack-automation/references/state-machines-and-approvals.md:350 still says "the platform ships no business-hours calendar", which this round makes false. skills: teach the approval escalation clock — timeoutHours can count working time on an org calendar (escalation.clock / escalation.calendar) #35931 (domain:skills, p1, pm:blocked on this PR) names exactly that row. Under the skills lane rule that is the right route.
  • Clause-②: yes (widening) and Metadata-protocol: added fit: two new optional keys with a wall-clock default, plus one additive served field.
  • The changeset covers all five published packages touched. The spec authorable-surface and defaults ledgers each gain the keys, and the ADR anchor file is new.

Sentence-by-sentence reads (changeset, content/docs/automation/approvals.mdx, the generated reference):

  • Changeset: every open request keeps its deadline (true: no clock in a stored snapshot means the wall clock). Friday 17:00 + 4 hours on 09-12 and 13-18 periods escalates at 12:00 on the next working day (true, tested). calendar left out means the organization default, with no wall-clock fallback (true). One function for sweep and read, never stored, a later holiday moves the deadline, a fired escalation stays fired (true: one slaDeadline, and single-shot is untouched). Refusal cases and the new field (true, though it also carries calendar). The inbox in every console language (true: 11 packs, and ls ui/packages/i18n/src/locales shows 11). The lint and the Studio sentences (true).
  • approvals.mdx: the two clock bullets, "Monday, or Tuesday when Monday is a holiday, or the Saturday itself when it is a make-up workday" (all three are the test's cases), the example block (it parses: clock, calendar and escalateTo are all declared), the refusal paragraph and the publish sentence all hold.
  • The reference page is the generated output of the new describe text. CI's generated-artifacts check is green.
  • The timeoutHours describe text and code comment no longer say there is no calendar. The only other place on the head that still says it is ADR-0157's own context section, which is history and correct as written.

Notes (not owed; a4-W's call whether to fold any in or file them):

  • N1. A non-refusal calendar error fails the whole inbox list read. slaDeadline rethrows anything that isn't a calendar refusal. The sweep catches it per row, but projectWorkingTimeDue in the list read does not. So one failed calendar read (a database error, say) turns the whole approvals list into an error, not just that row. A per-row guard in the projection that leaves sla_due_at absent and logs a warning would keep the inbox up.
  • N2. With no calendar service, the reason reads no_default. The inbox then tells the admin "no default calendar" even when one exists. objectql always registers the service, so this only shows in a trimmed kernel. Wording only.
  • N3. The calendar field does not follow the escalation switch. controllerAdmits reads only the direct controller and does not chain. With escalation.enabled: false and clock: 'working_time' stored, the clock is shown as retained and inactive, but the calendar shows as a live field. The SIBLING_GATES comment says "the calendar follows the switch through it", which overstates this. It's harmless, because nothing reads the calendar while escalation is off. I read this from the code and did not run it.
  • N4. One acceptance-note sentence in the PR body is off. "A refused deadline is read once per row per read and sweep through the service's 60-second cache": refusals are never cached, so each refused row queries the calendar tables again on every inbox read. That's cheap at today's sizes, but the sentence should not say "cache".

Landing: not governed and not a narrowing. The seat's contract read comes next, as a4-W said, and then a4-W lands.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-elon-musk · session_016WV4d1PJ4isQ3eD7Fk1fnF

Served-tier: CONTRACT_REVIEW_TIER

Contract review — PASS at f079e34

Head-sha: f079e341ff364bdac211e75e39f9950987007303
Local-runs: none
Scope: packages/spec/src/automation/approval.zod.ts, packages/spec/src/contracts/approval-service.ts + packages/plugins/plugin-approvals/src/approval-service.ts, packages/plugins/plugin-approvals/src/approvals-plugin.ts, packages/lint/src/validate-approval-approvers.ts, packages/lint/src/index.ts, packages/spec/authorable-surface/automation.json, packages/spec/authorable-defaults/automation.json, scripts/adr-anchors/packages__plugins__plugin-approvals__src__approval-service.ts.json, ui/apps/console/src/services/approvalsApi.ts, ui/apps/console/src/pages/system/ApprovalsInboxPage.tsx, packages/plugins/plugin-approvals/src/approval-service-sla-calendar-clock.test.ts, packages/lint/src/validate-approval-approvers.test.ts

PR #35929 (Fixes #35357), reviewed 2026-11-20T22:53Z by an isolated sub-agent of the seat. Inputs: card #35357 with its three comments (claim 7045483788, dev report 7048691545), ADR-0157 (D2, D4, D5, D8, D9, D12 and open implementation point 4), the PR body and its two comments (L1-a ACCEPT 7052291078 with four notes), the net diff against main 170ca481 (merge base 753091ee, 35 files, +875 −48), and the check-runs on the head: 78 runs, 65 success, 13 skipped, none red, none pending. GitHub reports the head mergeable and clean. Nothing was built or run. Code outside the diff was read on the PR head and on main, not reviewed.

Tier. The committed tree changes two published schema files under packages/spec/src/**, so the face is the schema face and the tier owed is CONTRACT_REVIEW_TIER. The Clause-②: yes line alone would owe TIER_DEFAULT; one schema path in a mixed diff takes the higher tier. check-governed-merges --pr 35929 reads 0 of 35 paths governed, so no governed tier applies.

No must-fix, no should-fix. Seven nits are listed under ④; none of them asks for a change on this head.

The narrowing question, answered first: this is not a narrowing. The new lint error refuses nothing that main accepts. Evidence is the second bullet of ①.

① Derived judgments

  • Authoring accept set, ApprovalEscalationSchema. Two optional keys are added: clock (wall_clock or working_time, default wall_clock) and calendar (a string matching WORK_CALENDAR_CODE_PATTERN). RIGHT, and a widening. No key is removed, no value is refused, no requirement is tightened; timeoutHours keeps z.number().min(1).
  • The lint error approval-escalation-calendar-without-working-time is not a narrowing. It fires only on an approval node whose escalation.calendar is a non-blank string. On main that key cannot be in an accepted document:
    • ApprovalEscalationSchema is a strictObject on main, so calendar (and clock) is an unrecognized key there.
    • That refusal reaches every door that parses a flow. FlowSchema's superRefine calls flowNodeConfigRefusals, which judges an approval node's config WHOLE against ApprovalNodeConfigSchema (flow-node-config-refusals.ts, the declared plugin contract map). os validate, os build and the metadata save door share that judge, registerFlow parses first, and the executor's own safeParse answers the node success: false (approval-node.ts).
    • The rule is registered tier: 'gating', input: 'parsed' (authoring-rules.ts, untouched by this diff), so on os validate, os build and the save door it only sees stacks the schema accepted.
    • One door differs and I name it: os lint never parses, so on a raw stack (not defineStack) it raised nothing on main for such a key and raises this error now. That is the pre-flight catching up with the parse. The same stack is refused on main at validate, build, publish, registration and run, so it was never an accepted document.
    • Stored rows: the schema's own history text records that unknown keys were dropped silently before the shape was closed, and the request snapshot is a copy of the parsed config, so no stored node_config_json carries clock. escalationCountsWorkingTime reads only an explicit 'working_time'.
      So the set "accepted on main, refused on this head" is empty. No Clause-②: no (narrowing) record is owed, and Clause-②: yes (widening) stands.
  • Parsed output. A parsed escalation now carries clock: 'wall_clock' when the author wrote none, and new request snapshots store it. The output type ApprovalEscalationParsed gains a required clock; the input type gains two optional keys. The sweep and the read treat the materialized default exactly as an absent key. RIGHT.
  • Served surface, ApprovalRequestRow. One optional field is added, sla_due_refusal. RIGHT, additive. The row is a TypeScript interface with no response schema in spec and no client package restates it; the console's own mirror (approvalsApi.ts) is updated.
  • sla_due_at without a calendar clock. Byte-identical to main: rowFromRequest still calls slaDueAt(created_at, cfg), the arithmetic is unchanged, and projectWorkingTimeDue skips every row that is not explicitly working_time.
  • sla_due_at under working_time. Read in slaDeadline:
    • a calendar that answers: addWorkingHours from created_at, in the request row's own organization, on the named code or else the default;
    • a calendar that refuses (the three ledger codes, classified structurally by isWorkCalendarRefusal): no sla_due_at, and sla_due_refusal is served;
    • no calendar service: refused as unresolved, never a wall-clock answer;
    • no usable timeoutHours or created_at: neither field, as on the wall clock.
      slaDueAt returns nothing for working_time, and slaDueAt, the sweep's guard and slaDeadline are the only runtime readers of timeoutHours on the head, so no path falls back to wall-clock hours (D2). All three callers of rowFromRequest (the open answer, the list read, loadRequest) project it. Exactly one of the two fields is served, by construction.
  • runEscalations. For a wall-clock row the order and the comparisons are those of main: the enabled switch with its legacy window, then the deadline, then the single-shot read. A refusal is counted and skipped before the single-shot read, so nothing escalates and no escalate row is written. The next sweep asks again, because the service never caches a refusal (work-calendar-service.ts on main). Nothing is stored (D12), and ADR-0042 §1 is untouched. One warn per sweep carries the count; that level is right under AGENTS.md's degradation rule, since the request visibly waits and its read says why.
  • Error codes. ERR_WORK_CALENDAR_UNRESOLVED, ERR_WORK_CALENDAR_NOT_MAINTAINED and ERR_WORK_CALENDAR_INVALID are in ERROR_CODE_LEDGER on main (error-code-ledger.zod.ts, registered by the calendar-service card). The diff mints no code. The lint rule id is a rule id, not a ledger code: like approval-decision-outputs-reserved it lives in the rule file and the package index only.
  • Generated mirrors. authorable-surface/automation.json gains both keys, authorable-defaults/automation.json gains the clock default, the reference page is regenerated, and the ADR anchor is one new JSON file named for its path. Lint & Repo Gates, Spec property liveness, Check Changeset and every type-check job are green on the head.

② Semver level

minor on @objectstack/spec, @objectstack/plugin-approvals, @objectstack/lint, @object-ui/console and @object-ui/i18n is right. Metadata-protocol: added takes at least minor on each package the diff moves, and these are the published packages it moves (@object-ui/app-shell is private, so it takes no entry of its own). added is the right kind: two new authorable keys, nothing removed or tombstoned, and no existing default or meaning changed, since the wall clock is what timeoutHours meant before.

Both declaration lines stand line-initial in the PR body and in the changeset. No ADR-0087 marker is owed: the changeset declares nothing breaking, and check-adr-0087-registration judges declared-breaking changesets only. No conversion entry, tombstone or semantic entry is owed either, since no key is retired and no default flips. Clause-②: yes (widening) is right on the evidence in ①.

③ Boundary flags

  • Dev report open_questions (one): keep the finding an error with its English developer message. Answered: ACCEPT option A, as the area ruled. D9 names "a calendar code written without clock: 'working_time'" as a static authoring error the publish-time check covers. Option B (a warning, the calendar left inert) would keep a declared key that nothing reads, which ADR-0049 forbids.
  • Dev report. security_findings none, out_of_scope_findings none. Its deviations (no assignee at PR creation, a tracking branch, main merged only in the fix round) have no effect on the contract.
  • ADR-0157 open implementation point 4, carried into this card's review: which organization, under whose authority. Answered in the tree, and RIGHT. The sweep and the three reads pass the request row's own organization_id to the calendar service, never the caller's organization. The service reads elevated inside that organization and refuses no_organization outside the single posture when the row has none. That is the contract work-calendar-service.ts states on main ("for the approval sweep, the request's").
  • Security reading: not security-touching. No changed hunk adds, removes or reorders a permission, sharing, credential, token or authentication check, and none teaches one. One new exposure exists and D9 rules it: a reader who can already read a request now also reads the calendar code, the date the calendar is not maintained for, and an English message that can carry the calendar's maintained span or the name of an unreadable column. Those come from tables a rank-and-file member cannot read directly, and always from the request's own organization. No path of this PR sits on a low-risk arm, so the template prints no machine line for it and I add none.
  • L1-a's four notes (7052291078). Note 1 is confirmed and reaches further than stated: N1. Note 2 is confirmed: N3. Note 3 is the Studio form, the lane seat's face; I read controllerAdmits and agree: it reads the direct controller only and does not chain, so the SIBLING_GATES comment says more than the code does. Note 4 is already answered: the PR body now says a refusal is never cached and every read and sweep asks again.
  • D4 release pairing. The body and the changeset both say the change is not released alone and name its pair. Working calendars ②: sys_work_calendar objects, calendar service and Setup page #35355 is closed; Working calendars ③: formula functions addWorkingDays / workingDaysBetween / addWorkingHours #35356 is open. Holding Version Packages until the set is complete is the maintainer's act under D4, not this PR's.
  • D12 left one choice to this card: whether the escalate row records the due time it fired on. Settled as no, stated in the PR body. ACCEPT; the row's own created_at says when it fired.
  • Skills-docs: follow-up #35931 is true. skills/objectstack-automation/references/state-machines-and-approvals.md:350 still says the platform ships no business-hours calendar. skills: teach the approval escalation clock — timeoutHours can count working time on an org calendar (escalation.clock / escalation.calendar) #35931 (p1, blocked on this PR) names that row and the two neighbouring places.
  • Overlap with feat(messaging): Slack DM delivery — slack channel, per-person link store, approval requests by DM (Part of #34730) #35789 (open, not queued). Its two hunks in the plugin's approval-service.ts sit in ApprovalMessagingSurface and in the channel list inside notify. This PR's hunks sit in the import block, slaDueAt and its helpers, ApprovalServiceOptions, the constructor, the three read projections and runEscalations. No shared line and no shared behaviour, so either order merges. No commit on main since the merge base touches the plugin, the two spec files, the lint rule or the inbox page.
  • SQL push-down. No id materialisation and no in-app join is added. The deadline is counted in memory per row, which ADR-0157 D6 requires ("No calendar math runs in SQL"). The calendar read behind it is the service's and is cached per organization and code; N2 covers the refused case.
  • Author. objectstack-fleet[bot], so no off-relay note is owed. The PR is still a draft; readying it is the seat's.

④ Design judgment

packages/spec/src/automation/approval.zod.ts, against ADR-0157 and its first consumers (the sweep and the Studio form):

  • D5 holds: the key is clock, its values are wall_clock and working_time, the default is wall_clock, and only timeoutHours gets it. The comment gives the stored-snapshot reason for the default.
  • D2 holds: calendar is the explicit code; left out, the organization default counts; otherwise a refusal. "Leave it empty" is true in Studio, where clearing the field deletes the key (FlowNodeInspector.tsx), so the pattern never meets an empty string from the form.
  • D9 holds: the schema accepts calendar beside the wall clock and the gating lint refuses it, on all three CLI commands and at the runtime publish door. That is where D9 puts the check ("the approval lint is a pure function of the stack"). See N4.
  • The timeoutHours describe text and comment no longer say the platform ships no calendar, and the Friday example stays true under the wall clock. The only places on the head that still say it are ADR-0157's own context section and the skills rows skills: teach the approval escalation clock — timeoutHours can count working time on an org calendar (escalation.clock / escalation.calendar) #35931 owns.

packages/spec/src/contracts/approval-service.ts, against D9, D12 and its first consumer (the approvals inbox):

  • sla_due_at: "computed by the same function the sweep uses" is true (slaDeadline), and so is "recomputed on every read".
  • sla_due_refusal: each sentence was checked against slaDueRefusalOf and the three error classes. code is one of the three ledger codes; reason is set on the unresolved code only; date on not-maintained only; message is the refusal's own sentence. The inbox renders the reason in place of the countdown on a pending row, and it is the only place the console shows the due time. See N5.

Implementing files:

  • approval-service.ts (plugin) agrees with both contract texts, as read in ①. slaDeadline rethrows whatever is not a calendar refusal: N1.
  • approvals-plugin.ts resolves WORK_CALENDAR_SERVICE lazily and answers undefined when the kernel has none, as its sibling providers do.
  • validate-approval-approvers.ts reads the authored clock (absent and wall_clock both fire), names the key's path and gives both edits in the hint. It judges nothing about whether the calendar exists (D9). Its message carries no tracker number.
  • The ADR anchor's invariant sentence matches the code.
  • The clock test file drives the real WorkCalendarService and pins each Done-when sentence of the card: the holiday Monday, the make-up Saturday, the moved deadline, the three refusals, the retry after the fix, and the unchanged wall clock.

Nits. None affects correctness or the contract on this head. N1 and N2 are worth one follow-up card.

  • N1 (nit) — a calendar error that is not a refusal now reaches three read paths, one of them after a write. projectWorkingTimeDue awaits slaDeadline with no guard. In the list read and in loadRequest it joins reads that can already throw. In openNodeRequest it is new: on main the last step after the insert is the synchronous mapper, and on this head an error reading the calendar tables there answers the node success: false after the request row exists. The pending row stays behind, and a retry of the node meets DUPLICATE_REQUEST. It takes an infrastructure fault on a working_time node. Follow-up: guard the projection per row (log, serve neither field), at least on the open answer.
  • N2 (nit) — a refused calendar is read once per row, on every pass. The service never caches a refusal, by design. An organization with many pending working_time requests and no resolvable calendar therefore pays one sys_work_calendar read per request, in sequence, on every inbox list (up to 500 rows) and on every sweep. A memo per organization and code inside one pass would keep "the next sweep asks again".
  • N3 (nit) — with no calendar service the reason reads no_default or not_found. This mirrors the service's own answer for a kernel without the calendar object on main, so the two agree; the inbox then names a missing default that may exist. Reachable only where the approvals service is composed without objectql's. Accepted deviation.
  • N4 (nit) — the sibling pairing is judged at the lint, while the same module's precedent judges at the schema. checkFallbackApproversPairing refuses an unread fallbackApprovers at the parse, so the executor refuses it too. A calendar beside the wall clock passes the parse, and the executor counts wall-clock hours without reading it. D9 names the lint and every authoring door runs it, so this is as ruled. Recorded so a later reader does not take it for an oversight.
  • N5 (nit) — calendar is served but not described, and two reasons have no label. The field's JSDoc and the changeset list code, reason, date and message. The type also carries calendar, which the inbox reads for its "no calendar" label; under not-maintained and invalid it is the resolved calendar's code, which may be the organization default's. reason carries the service's four values, and the inbox gives ambiguous and no_organization the general "fix the calendar in Setup" label; for no_organization (a request row with no organization outside single) Setup holds no fix. One sentence when the file is next touched; a fix here would move the head.
  • N6 (nit) — the sweep's warning also counts requests that already escalated. The deadline is asked before the single-shot read. A pending request whose escalation already fired, and whose calendar later stops answering, is counted as "not escalated" on every sweep until it is decided. Wording and log noise only.
  • N7 (nit) — one comment outside the diff is now a word short. flow-node-config-refusals.ts lists what approval.zod.ts imports ("zod, the membership-role leaf, lazySchema and strictObject only"). It now also imports data/work-calendar, an import-free leaf, so the conclusion beside it (no cycle) still holds.

Implemented-by: claude/area-a4W-35357
Reviewed-by: session_016WV4d1PJ4isQ3eD7Fk1fnF

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-elon-musk · session_016WV4czKnDE6hsyXQzB9wB2

Landing (area a4-W) · 2026-11-20T22:54Z

Probe Reading
L1 verdict ACCEPT 7052291078 (L1-a) at head f079e341; four notes, none owed before landing (N4, the PR-body cache sentence, corrected in the body)
Contract review PASS 7052603635 (CONTRACT_REVIEW_TIER) at head f079e341; no must-fix, no should-fix; not a narrowing (Clause-②: yes (widening), Metadata-protocol: added)
Checks at head f079e341 78 check-runs: 65 success, 13 skipped, 0 failed, 0 pending; mergeable clean
Governed surface check-governed-merges.mjs --pr 35929: NOT governed (0 of 35 paths); 923 changed lines ≤ 3000

State change: ready for review + auto-merge on the maintainer's area line 「本区通过复审的 PR 都可以 ready + auto-merge」 (a4-W thread, 2026-11-19T21:59Z). On MERGED: #35357 closes via Fixes, and #35931 (the skills text, domain:skills) is unblocked.

@github-actions

Copy link
Copy Markdown
Contributor

⛔ merge queue 构建失败 — 先分诊,再决定要不要重排

队列构建 44833967939 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集),
所以失败的测试可能在本 PR 没碰过的包里 —— 那不是重排能修的。每次盲目重排都会让排在后面的所有 PR 重建一轮。

分类:failure —— 按下面的日志分诊。

失败的 job(日志抽取,best effort):

  • Test Core (10/10) — 失败步骤: Run this shard's tests

    @objectstack/cli:test:  FAIL   integration  src/commands/migrate/data-commands.absent-database.integration.test.ts > [#21552] the rest of the family: a project with no database yet is empty work, exit
      ↳ 失败原因: @objectstack/cli:test: Error: Hook timed out in 480000ms.
    

↳ 失败原因 是判读的关键:超时(Test timed out in … / Hook timed out in …)多半是负载/时序,不是本 PR 的回归;
断言(AssertionError: …)才指向真实的行为改变。两者的 FAIL 行长得一模一样,只有这一行能区分。

⚠️ 断言这一侧有一类例外,判据是断言在测什么,不是它是不是 AssertionError。 断言的对象是产品行为(一个值、一个形状、一次拒收)⇒ 照上面读:真实的行为改变,去查,⛔ 不要重排掉;
断言的对象是这次实验自身的有效性前提(跑完的耗时、负载下的先后、任何只在时间预算内才成立的条件)⇒ 它跟超时是同一类,同样对负载敏感,重排一次是合法的判别手段。
识别是机械的:断言的消息或它比较的值本身点名了一段时长、一个时间戳、一个耗时计数。实测过的一对 —— AssertionError: SecurityPlugin.init() ran: expected false to be true 测的是产品行为(真回归);
AssertionError: this run took over a second, so second-precision stamps could have differed too: expected 1006 to be less than 1000 测的是实验前提:它守护的那条不变式当时是绿的,同一个 head 原样重排一次即成功。
穿着 AssertionError 外衣的时间测量,仍然是时间测量。(⛔ 这只改「怎么读一次红」,不改「哪些测试可以重排」——后者由别处管。)

跨 PR 相同签名(24h,按失败测试文件聚合):

  • src/commands/migrate/data-commands.absent-database.integration.test.ts — 24h 窗口内只有本 PR 撞到过,暂不汇总(再有一个不同 PR 撞到就会自动开汇总 issue)。
  • ⚠️ 24h 评论账本没读完(超过 5 页仍未读到窗口尽头),所以上面的「不同 PR 数」是下界,不是全量。

历史信号:

  • 本 PR 过去 24h 无队列失败记录(首次)。
  • 过去 24h 队列共有 13 个失败构建(不含本次)。

分诊清单:

  1. 失败测试在本 PR 改动的包里 → 真回归,修 PR。
  2. 失败测试与本 PR 无关 → 看上面的「跨 PR 相同签名」;已有汇总 issue ⇒ flaky/环境问题实锤,去那张 issue 上谈,修好前重排只会再烧一轮全队列。
  3. 两者都不是 → 可能与同组 PR 语义冲突;等前面的 PR 落地或失败出队后再重排一次即可,不要连续重排。

Generated by Claude Code · merge-queue-triage workflow (#4859)

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-elon-musk · session_016WV4czKnDE6hsyXQzB9wB2

Queue build 44833967939 failed in Test Core (10/10) on @objectstack/cli src/commands/migrate/data-commands.absent-database.integration.test.ts: "Hook timed out in 480000ms". This PR changes no file in @objectstack/cli (its packages are spec, lint, plugin-approvals and the ui console/i18n/app-shell), and the failure is a hook timeout, not an assertion. That is the load signature the triage note names, so this is not this PR's regression. Re-armed once at the same head f079e341 (no push). If the same file times out again, it goes to a shared issue and this PR is not re-queued blind.

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 size/l 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.

Working calendars ④: approval escalation clock key (wall_clock | working_time)

2 participants