Repository navigation
feat(formula): working-day functions addWorkingDays, workingDaysBetween and addWorkingHours over the organization calendar - #36796
Conversation
…fusal Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzi4y7vb1rP9MERYbw2
…n calendar The engine resolves the calendars a formula plan names, per row organization, through the work calendar service before evaluating; a refusal is handed over as data and reads null with one log line (ADR-0157 D2, D4, D8). A stored expression stores blank on a refusal and the write goes through (D6, open point 1). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzi4y7vb1rP9MERYbw2
The publish lint refuses a working-day call at every expression site but a formula field's and a computed field's expression, prescribing the stored due time, and refuses a calendar code that is not a quoted literal (ADR-0157 D4, D6). The form treats a formula calling one as unservable. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzi4y7vb1rP9MERYbw2
…atalog The formula docs page and objectstack-formula document addWorkingDays, workingDaysBetween and addWorkingHours; the platform catalog drops its Planned row; the business-hours SLA eval expects the functions (ADR-0157 D4). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzi4y7vb1rP9MERYbw2
…'s ceiling Delete restatement the file already carries (the built-ins line's timestamp repeat, the date-arithmetic note, the Salesforce-flavor examples and translations the translation table lists) and compress the working-day paragraph, so the ceiling stays where it was. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzi4y7vb1rP9MERYbw2
…ne, not on its facade The engine facade is at its line ceiling: the plugin installs the calendar service in formula-work-calendars.ts and each formula path reaches it through its host's facade. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzi4y7vb1rP9MERYbw2
📓 Docs Drift CheckThis PR changes 3 package(s): 28 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 7 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 34 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 c5f0deef0c8e57eea3b249049fa517df22599cc6 && git checkout c5f0deef0c8e57eea3b249049fa517df22599cc6
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin f46ce5b4afc9933142b5c72205c71e0475d6cabd 762e6a6c7eea45e81f4aa859d0813ad7118254e2 && git checkout -B drift-repro f46ce5b4afc9933142b5c72205c71e0475d6cabd && git merge --no-ff 762e6a6c7eea45e81f4aa859d0813ad7118254e2
node scripts/docs-audit/affected-docs.mjs --json f46ce5b4afc9933142b5c72205c71e0475d6cabd
|
|
repo:objectstack#3 · os-support-ai · session_01WGufzi4y7vb1rP9MERYbw2 {
"issue": 35356,
"status": "done",
"branch": "claude/project-thread-7jquxn",
"pr": "https://github.com/objectstack-ai/objectstack/pull/36796",
"session": "session_01WGufzi4y7vb1rP9MERYbw2",
"premise_still_valid": true,
"summary": "addWorkingDays / workingDaysBetween / addWorkingHours registered as CEL stdlib over per-evaluation calendar data (@objectstack/formula), with pushdown refusal. objectql resolves exactly the calendars a formula plan names per row organization through WorkCalendarService (read, write response, summary folds, stored expressions); a D8 refusal reads null with one log line, and a stored expression stores blank and the write goes through (open point 1, Decision for review). Lint refuses the functions outside formula/stored expression and refuses a non-literal calendar code; the form treats them as unservable. Docs, objectstack-formula (inside its ceiling), catalog Planned row removed, eval 8 flipped, changeset.",
"tests": "formula 2133/2133 (working-day.test.ts covers weekend, National Day week, 调休 Saturday, DST, refusals, pushdown); objectql 14363/14363 (engine-formula-working-day.test.ts 11/11); lint 9475/9479 then the 2 ledger files fixed and re-run 592/592; ui/packages/core 4769 passed, 27 skipped.",
"gates": "local: 139 dispatch-gates commands at final source, `dispatch-gates --ran` 122 families accounted for, 118 run, 4 NOT-MEASURED (exit 3, unbuilt closure: check:skill-examples, check:dual-build-cjs-loads, check:lean-entry-closure; check-plugin-teardown-shape --self-test needs an unshallowed clone). `pnpm --dir ui exec vitest run scripts/` 1 red: unit-registry-absence-collision cannot import modules resolving unbuilt @objectstack/client (environment). check:facade-delegation-only red first run, fixed (calendar wiring moved off engine.ts), re-run 0. Typecheck formula/objectql/lint exit 0. CI at head 4f2ffd2d: 70 check runs, 61 success, 9 skipped, 0 failed; mergeable_state clean.",
"dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
"mcp_calls": "read-only only (pull_request_read get_check_runs); no write tool",
"api_writes": "0 direct REST writes; relay dispatches: pr_create #36796, pr_request_reviewers os-support-ai, this comment",
"open_questions": [
{
"question": "Open point 1: a stored expression meeting a D8 refusal",
"options": [
"A store blank, write goes through, one log line (implemented, pinned)",
"B the write fails"
],
"recommendation": "A, because it matches D8 reads and does not block every record whose span crosses the maintained period (D9 stance)"
}
],
"security_findings": "withheld",
"out_of_scope_findings": []
} |
|
repo:objectstack#3 · os-support-ai · session_01WGufziwMkZG34d69p8BHb4 Contract-review-claim: session_01WGufziwMkZG34d69p8BHb4 · head 4f2ffd2 · 2026-11-24T00:58Z Face read off the committed paths ( |
|
repo:objectstack#3 · os-support-ai · session_01WGufziwMkZG34d69p8BHb4 Contract reviewServed-tier: Inputs read: card #35356 (body and its four comments: unblock 7011103158, shipping note 7054955353, grade note 7063199719, claim 7101714597), PR #36796 (body, the dev report 7118578527, the docs-drift comment, the review claim), the net diff against ① Derived judgments
② Semver levelM1 (must-fix) —
The rest of ② holds: a changeset exists for every released package the diff touches, no ③ Boundary flags
④ Design judgment
S1 (should-fix) — an expression
S2 (should-fix) — the answer depends on whether the projection kept
Nits (no effect on correctness or the contract):
M1 is a FAIL. S1 and S2 each earn a delta review of their fix. Implemented-by: VERDICT: FAIL |
|
repo:objectstack#3 · os-support-ai · session_01WGufziwMkZG34d69p8BHb4 席位核对 — REWORK · repo:objectstack#3 · head 4f2ffd2 · 2026-11-24T01:08ZL1: REWORK Tier and face
Checklist
FindingsMust-fix
Should-fix
Nits (contract review N1–N5, no effect on correctness or the contract): the SKILL.md Open point 1 (Decision for review)Option A stands, per the contract review's ③: a stored NextThe fix round goes to the card thread. The delta read covers M1, S1–S3 on the new head, and the contract review gets its own delta from the same reviewer. After both ACCEPT/PASS, this goes Tier H to the approver; ⛔ never ready it. |
… calendar lookup's organization column Review round: the changeset now declares Metadata-protocol added with @objectstack/formula at minor and a Skills-docs line. os build refuses the three functions in a field's expression defaultValue and in seed expression values. A projection that omits organization_id is pinned by a test, and the plugin's service wiring by a kernel boot test. A blank start answers blank before any calendar is read. Docs and skill say a blank stored due time stays blank until the record's next write. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzi4y7vb1rP9MERYbw2
|
repo:objectstack#3 · os-support-ai · session_01WGufziwMkZG34d69p8BHb4 Contract-review-claim: session_01WGufziwMkZG34d69p8BHb4 · head 762e6a6 · 2026-11-24T04:57Z |
|
repo:objectstack#3 · os-support-ai · session_01WGufziwMkZG34d69p8BHb4 席位核对 — ACCEPT · repo:objectstack#3 · head 762e6a6 · 2026-11-24T05:00ZL1: ACCEPT (delta, after REWORK 7118804738 at 4f2ffd2) Delta read
FindingsMust-fix: none. Should-fix: none. Nits: none new. NextTier H: once the contract-review delta passes, the seat takes it to the approver. ⛔ Never flip it ready, enqueue it or arm auto-merge. |
|
repo:objectstack#3 · os-support-ai · session_01WGufziwMkZG34d69p8BHb4 Contract reviewServed-tier: Delta round on the record for head ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Earlier nits:
New this round, one nit (no effect on correctness or the contract):
No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#3 · os-support-ai · session_01WGufzi4PechTRCTBrfxV8W 维护者速读
Request: approval · Tier H by governed path ( 席位意见: land. Both review rounds are closed on this head: L1 (M1, S1–S3) and contract (open point 1 resolved as option A with its two author-facing sentences).
|
Requested by Yibo Wang · project thread
Fixes #35356
repo:objectstack#3 · os-support-ai · session_01WGufzi4y7vb1rP9MERYbw2
Clause-②: yes (widening)
Metadata-protocol: added — a formula field's or a stored field's
expressionmay now calladdWorkingDays(...),workingDaysBetween(...)andaddWorkingHours(...)Skills-docs: updated here — skills/objectstack-formula/SKILL.md teaches the three functions and eval 8 of skills/objectstack-project/evals/project-process.json exercises them (the card's order names both)
维护者速读
Review round 2 (L1-b 7118804738, contract 7118785761)
Metadata-protocol: addedwith@objectstack/formulaat minor (the three names are a new accepted value of an authoredexpression, as withrmbUpper), and theSkills-docs:line, in this body and the changeset.os buildnow refuses the three in a field's expressiondefaultValue(the default step has no calendar, so every insert would land blank) and in a seed record's expression values at any depth (the seed loader has none either), with the stored due-time prescription. New modulepackages/lint/src/validate-working-day-sites.ts; a bare-stringdefaultValueis a literal and draws nothing (CONTROL).planFormulaProjectionwidens a named projection to every stored column,organization_idincluded, and cuts it back after evaluation. Now pinned: the stub driver honoursfields, and "a projection that leaves organization_id out still counts each row in its own organization" asserts both the per-organization answer and that the driver was asked fororganization_id. Ablation: skippingorganization_idin the widening turns it red. Documented in the header offormula-work-calendars.ts.ObjectKernel+ObjectQLPlugin({ ql: engine })servesobjectqlas the same engine and its formula counts with the plugin-installed calendar service. Ablation: removing the plugin'ssetFormulaWorkCalendarServicecall turns it red.timestamp(s)line andPRIOR()note reworded; N3 eval 8 says{now}for a filter andnow()for a CEL condition; N4 the catalog'ssys_work_calendarrow names all three functions; N5 a blank start answers blank before any calendar is read (test added).mainonce it lands, per the seat.What changes
Three formula functions over the organization's working calendar (ADR-0157 D4), with the evaluation contract this card had to settle.
addWorkingDays(day, n[, code]): the calendar daynworking days afterday(before it, for a negativen).dayitself never counts, and0answersday. The answer is a calendar day at UTC midnight, astoday()and adatefield are.workingDaysBetween(start, end[, code]): the working days afterstartup to and includingend, negative whenendis earlier. It is the inverse:workingDaysBetween(d, addWorkingDays(d, n)) == n.addWorkingHours(start, hours[, code]): the instanthoursof working time afterstart, counted as elapsed time in the calendar's time zone (D11, open point 3). A start outside working time begins at the next working period's start.All three count through
work-calendar.ts, the arithmetic the calendar service and the approval clock already use, so there is one walk and one daylight-saving rule.Packages.
@objectstack/formula:working-day.tsregisters the functions as CEL stdlib overEvalContext.workCalendars(pure data, the existing binding pattern).working-day-needs.tsreads, from an expression's AST, which calendars it names: the default for a two-argument call, and each quoted-literal code.cel-to-filter.tsrefuses the three as a filter (CompileError('unsupported')), prescribing the stored due-time field. They joinCEL_STDLIB_FUNCTIONS.@objectstack/objectql:formula-work-calendars.tsresolves exactly the calendars a formula plan names, per row organization (organization_id, else the read's tenant), throughWorkCalendarService.resolve, so its cache and invalidation are reused. A refusal is handed over as data. Wired into find / findOne, the insert and update responses, the summary-fold dependents and stored expressions (computeStoredExpressions). The plugin installs the kernel's calendar service beside the engine (setFormulaWorkCalendarService), and each formula path reaches it through its host'sfacade, soengine.tsstays at its facade line ceiling (6857) with no new member.@objectstack/lint: refuses the three at every expression site except a formula field's and a stored field'sexpression(check(), the declared flow predicate and value slots, a field's expressiondefaultValue, seed values), and refuses a calendar code that is not a quoted literal (judgeFieldFormula).@object-ui/core: a form treats a formula that calls one as unservable, because the calendar is loaded for the server's read and never handed to the form.sys_work_calendar's row; project-process eval 8 now expectsaddWorkingHours(and a stored due time, and refusesPLATFORM-CANDIDATE.Contract choices (D4: the card's to settle, pinned by tests).
workingDaysBetween, refuses.Decision for review
Open point 1: a stored field's
expressionthat meets a D8 refusal stores blank, and the write goes through, with one log line naming the object, the field and the refusal.Why this option and not "the write fails":
nulland logs once. A stored due time and a computed one then answer the same way for the same calendar state.Pinned by
engine-formula-working-day.test.ts› "a refused count stores blank and the write goes through, with one line naming the field". The alternative is one branch incomputeStoredExpressions: rethrow instead of storing blank.Tests
packages/formula/src/working-day.test.ts: acn_mainlandcalendar (Asia/Shanghai, 09:00-12:00 and 13:00-18:00, National Day 10-01..07 off, Saturday 10-10 on) against a weekly-only CONTROL calendar. Covers a weekend, the National Day week, the 调休 Saturday, negative and zero counts, date,today()and timestamp inputs, blank handling, the inverse property, DST spring-forward and fall-back, every refusal (no default, not maintained, not loaded, code not loaded), the needs analysis, and the pushdown refusal with anaddDaysCONTROL.packages/objectql/src/engine-formula-working-day.test.ts: the realWorkCalendarServiceover a stub driver. A read over the National Day week onto the 调休 Saturday, a weekend on findOne, two organizations each on its own default, the write response, D8 pastmaintained_throughand with no default (null, one log line, never a wall-clock count), no service, D6 stored count and stored blank on refusal, the cache serving untilinvalidate(), no calendar read for a projection whose formulas call none, a projection withoutorganization_id(S2), and a kernel boot throughObjectQLPlugin(S3).packages/lint/src/validate-expressions.working-day-35356.test.ts: accepted at a formula and a storedexpression(including the branch between literal codes); refused at a validation rule, an action'svisible, a flow condition, a sharing rule (both the expression lint and the enforceability pass), a field's expressiondefaultValueand a seed value; a computed code refused;addDaysand bare-string CONTROLs.authored-site-expression.test.tsclassifies the new gate passes and the value-site walk;validate-expressions.test.tsexcuses the new import tailsites.ui/packages/core/.../formulaRecord-35033.test.ts: a working-day formula and a formula reading it are unservable;addDaysCONTROL computes.Acceptance notes
npm view @objectstack/objectql versionand@objectstack/formularead18.6.0, which carries no calendar code. The changesets of Working calendars ②: sys_work_calendar objects, calendar service and Setup page #35355 and Working calendars ④: approval escalation clock key (wall_clock | working_time) #35357 are still pending onmain, so this PR ships in the same release as them.packages/speccarries no function list or schema that changes (its only diff is the catalog generator's row list,packages/spec/scripts/**, unpublished). The published list that widens is@objectstack/formula'sCEL_STDLIB_FUNCTIONS(three names). Measured: not CONTRACT_REVIEW_TIER by the order's spec criterion; the seat decides.added: no authorable key orauthorable-surface/**shard moves, but an authoredexpressionaccepts three new function names (corrected in round 2 fromnone).engine-find.ts,engine-insert.ts,engine-update.ts,engine-security-resolvers.ts,engine-top-level.ts,plugin.ts) and the newformula-work-calendars.ts, because the formula read and write paths are where the calendars are loaded;engine.tsandwork-calendar-service.tsare unchanged.packages/lint/**is the measured expression-lint location.ui/packages/core/**keeps the form from computing a formula the server's write-path check already calls unservable.skills/**, published):skills/objectstack-formula/SKILL.md491 → 485 lines, 6090 tokens. Its ceiling rises 6008 → 6090 (+82) under the standing ruling 「A:先削重复,余额按实测提高」 (record 6513306068): restatement was deleted first in the same file (changed lines remove 789 priced bytes and add 1130), and the balance the round-2 sentences need is raised to the measured value, as the comment inscripts/check-skills-token-ratchet.mjsrecords.skills/**makes this PR governed.Verification
Two-minute check:
pnpm --filter @objectstack/formula exec vitest run src/working-day.test.tsshows the National Day and 调休 Saturday cases passing.Read first (by risk):
packages/objectql/src/formula-work-calendars.ts(which organization a row counts in),packages/objectql/src/engine-top-level.ts(computeStoredExpressions, the open point 1 branch),packages/formula/src/working-day.ts(the public contract).Local gates (dispatch-gates --ran: 122 derived families accounted for, 118 run, 4 NOT-MEASURED)
working-day.test.ts23 passed; objectqlengine-formula-working-day.test.ts13 passed; lintvalidate-expressions.working-day-35356,validate-expressions,authored-site-expression606 passed;platform-catalog.test.ts20 passed;tsc --noEmitformula, objectql, lint green;check-skills-token-ratchet,check-facade-delegation-only,check-nul-bytes,check-skill-links,check-skill-identifier-liveness,check-skill-top-level-keys,check-skill-frame-sync,check-changeset-fixed,check-empty-changeset,check-changeset-no-majorgreen.Round 1:
check:skill-examples,check:dual-build-cjs-loads,check:lean-entry-closure,check-plugin-teardown-shape --self-test(its positive control is pinned to a commit this shallow clone cannot reach).pnpm --dir ui exec vitest run scripts/: 1 red,unit-registry-absence-collisioncannot import modules that resolve@objectstack/client, which is unbuilt here. Environment, not this diff; CI runs it built.check:facade-delegation-onlywas red on the first run (engine.ts32 lines over its ceiling); fixed by moving the calendar wiring intoformula-work-calendars.ts, re-run green.tsc --noEmitandcheck:test-typecheck):@objectstack/formula,@objectstack/objectql,@objectstack/lintgreen.@objectstack/formula2133 passed;@objectstack/objectql14363 passed;@objectstack/lint9475 of 9479 passed, the 4 reds were two ledgers naming the new gate passes, fixed and both files re-run green (592 passed);ui/packages/core4769 passed, 27 skipped.