Repository navigation
feat(spec, runtime, lint, core): a hook writes the sentences it declares in the organization's language (ctx.text) - #34545
Conversation
Claude-Session: https://claude.ai/code/session_01ADHkmNwjZuUekdsr5UH3GP Co-authored-by: Claude <noreply@anthropic.com>
…tion's language Claude-Session: https://claude.ai/code/session_01ADHkmNwjZuUekdsr5UH3GP Co-authored-by: Claude <noreply@anthropic.com>
…angeset Claude-Session: https://claude.ai/code/session_01ADHkmNwjZuUekdsr5UH3GP Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmNwjZuUekdsr5UH3GP Co-authored-by: Claude <noreply@anthropic.com>
… erasing them Claude-Session: https://claude.ai/code/session_01ADHkmNwjZuUekdsr5UH3GP Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmNwjZuUekdsr5UH3GP Co-authored-by: Claude <noreply@anthropic.com>
…anizationLocaleSetting; skills follow-up is #34546 Claude-Session: https://claude.ai/code/session_01ADHkmNwjZuUekdsr5UH3GP Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmNwjZuUekdsr5UH3GP Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 5 package(s): 11 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 3 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 185 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 b4be2bf1fe57667d52b373ba68b108db576b5261 && git checkout b4be2bf1fe57667d52b373ba68b108db576b5261
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 60552cd9398ad516ed367cd41530188fe97542be 7b8d110d6c524f77f7a808dd227b8b10039644da && git checkout -B drift-repro 60552cd9398ad516ed367cd41530188fe97542be && git merge --no-ff 7b8d110d6c524f77f7a808dd227b8b10039644da
node scripts/docs-audit/affected-docs.mjs --json 60552cd9398ad516ed367cd41530188fe97542be
|
…ol added Claude-Session: https://claude.ai/code/session_01ADHkmNwjZuUekdsr5UH3GP Co-authored-by: Claude <noreply@anthropic.com>
…erves 24 properties; texts' Studio row is recorded as owed Claude-Session: https://claude.ai/code/session_01ADHkmNwjZuUekdsr5UH3GP Co-authored-by: Claude <noreply@anthropic.com>
…ext rows it lists The ledger gained HookText and four hook `texts.valueType` sites by hand but its measured header still read 266 schemas / 1090 sites; it now reads 267 / 1096, which is what its body holds. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmNwjZuUekdsr5UH3GP
|
repo:objectstack#2 · os-steve · session_01ADHkmNwjZuUekdsr5UH3GP
Reading: this looks like a flake outside this PR's change, not a regression. The next step is one re-run of the failed jobs once the run completes; if it fails again, the failure is real and I will fix it. Generated by Claude Code |
|
repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz Re-run reading (area o2-D) — run 44001704215 @ Read the job log of Test Core (3/8) (job 133767960037). The one failure:
Judgement: flake. The case races a CPU budget on a worker thread (whether any page finished before the budget ran out depends on runner load), and this PR touches no file under |
…-l1nf08 # Conflicts: # packages/spec/dropped-refinements.baseline.json
…-l1nf08 # Conflicts: # packages/spec/dropped-refinements.baseline.json
…surface on the merged tree Discharges the os-regen deferral of the merge of main d57d6ee: both files are generated, so they are rebuilt from the merged tree rather than text-merged. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmNwjZuUekdsr5UH3GP
|
repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz Final head for review (main merge): |
|
repo:objectstack#2 · os-steve · session_01ADHkmTHGRTjPqZAcBuo9WH 席位核对L1 delta (merge of Delta read
The verdicts 6937770388 and 6939309851 stand for everything outside this delta. Owed after this
|
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head 7b8d110 · 2026-11-17T06:19Z |
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract reviewServed-tier: Delta record over 6939428411 (PASS on ① Derived judgmentsThe lane's claim, read from the git objects:
Five blobs moved between the two heads; in every one the movement from
So the accept sets, exports and key spellings judged in 6939428411 are the ones on this head. Its ① judgments hold as written and are not re-reviewed here. ② Semver levelUnchanged. ③ Boundary flags
④ Design judgmentNo must-fix, no should-fix.
Nits N1 to N5 of 6939428411 stand unchanged, each with the disposition recorded there. No new nit. Implemented-by: VERDICT: PASS |
|
repo:objectstack#2 · os-steve · session_01ADHkmQ2SN4K183oqAvUajA Seat record · 2026-11-17T06:24Z · Head-sha: 7b8d110 维护者速读
席位意见:同意合并。有 HotCRM 实测拉动,新键只在声明时生效,失败方向是写出声明原文,不会写空或报错。 席位核对
|
Requested by Steve · project thread
Part of #34374
Clause-②: yes (widening) — a hook may now declare
textsand its code may callctx.text; translation bundles accepthooks.<hook>.texts.<key>.message;@objectstack/coreexportsreadOrganizationTextLocale. Nothing that was accepted before is refusedMetadata-protocol: added
Skills-docs: follow-up #34546
This is the hook half of #34374 (ruling 6913660232 option B, parameter 7; split recorded on the card by
repo:objectstack#2). The action half is left to PR2: action-written text (objects.<obj>._actions.<act>.*/globalActions.<act>.*, e.g. HotCRM'ssend_emailscript action writing'Email: ' + subject) lands after #34273 merges, reuses #34273's shared declared-entry factory, starts from fresh main, and is the PR that closes the card. This PR does not touchaction.zod.ts.维护者速读
texts),运行时用await ctx.text('key', { … })取,按组织语言给出(Localization 设置有人设过就用它,否则应用的i18n.defaultLocale),从不按触发保存的那个人的语言。texts的钩子行为不变;缺译文写声明原文,不失败;只有 Localization 设置读不出来(非「未注册」)时那次ctx.text拒绝。回滚即 revert。packages/runtime/src/sandbox/hook-text.ts(取语言、选译文、填洞),然后packages/spec/src/data/hook.zod.ts的texts与保存期检查。pnpm --filter @objectstack/runtime exec vitest run src/sandbox/hook-text.integration.test.ts,预期 11 条全过(返工后加了「译文渲染不了回落到声明句」在两条路径上各 1 条)。What changes
HookSchema.texts(packages/spec/src/data/hook.zod.ts,hook-refusal-codes.ts): a hook declarestexts: { <snake_case key>: { message, params? } }.paramsnames the{{ }}holes, under the same closed-scope rule a declared refusal's message follows; a text with noparamsis plain and a hole in it is refused. Save-time checks:textson anexpressionbody or on a hook with neither body nor handler is refused attexts; actx.text('<literal>')key the hook does not declare is refused atbody.source/handler(comments and strings are masked; a computed key is left to the run).i18n-resolver.ts,translation.zod.ts): the key ishooks.<hook>.texts.<key>.message(hookTextMessageKey); the translation bundle'shooks.<hook>group acceptstexts.packages/core/src/organization-locale.ts):readOrganizationTextLocale(getService, organizationId)— the Localization setting somebody set (source !== 'default'), else the app'si18n.defaultLocale, else nothing. An unregistered Localization namespace/key (SETTINGS_UNKNOWN_NAMESPACE/SETTINGS_UNKNOWN_KEY) is "not set"; any other read failure propagates. The flow record write (service-automation) used its own private copy of exactly this; it now calls the shared one, answers unchanged.ctx.text(key, params?)(packages/runtime/src/sandbox/hook-text.ts,body-runner.ts,quickjs-runner.ts,script-runner.ts,app-artifact-handlers.ts): translate the template first (through thei18nservice, negotiated as refusals are), then fill the holes through the formula template engine (renderHookTemplate, shared with the refusal filler, which keeps its behaviour). A missing translation answers the declaredmessage; a translation whose holes do not render is dropped for the declaredmessage, filled, with a warning that says so; an undeclared key throws aSandboxErrornaming the hook and the key. Same answer on a sandboxedjsbody (installed on the VM'sctx) and an in-processhandler(thewithInProcessHookTitleseam).i18n-walk.ts,validate-translation-references.ts,validate-hook-refusal-templates.ts):os i18n extractscaffoldshooks.<hook>.texts.<key>.messagewith the declared sentence;objectstack validaterefuses ahooks.<hook>.texts.<key>translation over a key the hook does not declare (nearest key offered). The compile half of a hook sentence (hooks: the refusal catalogue (refusals) cannot translate a handler-authored hook's refusals, and holds one sentence per code — a TS hook has no way to refuse in the user's language #33214) now judgestexts.<key>.messagefor an entry withparamsbeside the refusal sentences: logic, an unknown formatter, an empty hole andcurrencywith no code are errors atobjectstack validate,compileand the publish gate'shookwrite.automation/hooks.mdx(new section),automation/hook-bodies.mdx(ctx.textrow),ui/translations.mdx(key row).HookTextobject-level check and thetexts.valueTypesites), liveness rows (hook.texts,translation.hooks.texts), and thecheck:generated --fixoutputs (api-surface, export-origins, declaration-map, reference docs, strictness ledger, liveness counts, and the two generator-ownedskills/*/references/_index.mdlines that listHookTextSchema).Not changed: no backfill of rows already written (parameter 6); no
org.localeroot (parameter 8); a string a hook builds itself is written as it is (parameter 4).Tests
packages/runtime/src/sandbox/hook-text.integration.test.ts(new): the HotCRM lead follow-up shape on the realObjectQL+SqlDriver(better-sqlite3) +QuickJSScriptRunner+ in-memoryi18n, on both the sandboxed body and the in-process handler path, every assertion on the stored task row. An en-US caller in a zh-CN app writes the zh-CN translation, holes filled; a ja-JP Localization setting somebody set wins and is asked in the write's organization (CONTROL: thesource: 'default'placeholder does not count); no translation writes the declared sentence filled;SETTINGS_UNKNOWN_KEYanswers the app default whileSETTINGS_STORE_UNAVAILABLErejects the update with no task written; an undeclared key rejects naming hook and key; a translation whose holes do not render writes the declared sentence filled and warns so (CONTROL: a translation that renders, with a known formatter, is written).packages/spec/src/data/hook-texts.test.ts(new): schema acceptance, key pattern, hole rules, alias, expression-body / no-code refusal, handler acceptance, literal undeclared key atbody.sourceandhandler, masked-comment/string/computed-key CONTROL, run-time message, translation face, key spelling.packages/core/src/organization-locale.test.ts:readOrganizationTextLocale— set wins in the organization; no settings / placeholder → app default; unregistered namespace/key → app default; other failure rejects; no lookup → nothing.packages/lint/src/validate-hook-refusal-templates.test.ts: a hook text withparams— CONTROLs accepted (a path, a known formatter,currency:EUR, plain text); an unknown formatter, logic and an empty hole refused as errors attexts.<key>.message;currencywith no code refused namingcurrency:EUR; a text with noparamsnot read; a text and a refusal on one hook each at its own path; part of the stack expression pass; refused at the publish gate'shookwrite (CONTROL passes).packages/lint/src/validate-translation-references.test.ts,i18n-walk.test.ts: declared text passes; undeclared key refused with suggestion; key on a hook with notextsrefused; the walk yields the key with the declared sentence from thehookbucket.packages/metadata-protocol/src/protocol.meta-types-degenerate-derivation.test.ts(hookserves 24 top-level properties, was 23);packages/spec/src/system/metadata-form-zod-reconciliation.test.ts(a root ledger row forhook.texts);packages/spec/src/type-alias-convention.pin.test.tspinsHookTextSchemaas an isomorphic alias (ADR-0122; no default, no transform, besideHookRefusalSchema) and moves the pin count by one (857 after merging main, which added two). No other existing test was changed.Acceptance notes
Action half → PR2 (after actions: an action body has no refusal catalogue — a person-facing throw from an action stays in the author's language #34273), as above.
The Studio hook form (
hook.form.ts) gets notextsrow in this PR: adding one needs its labels and help text translated in the eleven metadata-forms bundles, which is outside this half's file surface. The form↔Zod reconciliation records the omission as a root ledger row, owed to a follow-up card. A hook authored in Studio can still carrytextsthrough its source. Filed: Studio hook form: add thetextsrow (11 locale packs) and retire its reconciliation-ledger omit #34575.ctx.textis a pull API rather than a write-time marker because the HotCRM hooks truncate and compose the sentence (both cut to 255 characters) before writing it.New public names, confirmed by the seat:
texts,ctx.text,HookTextSchema,hookTextMessageKey.readOrganizationTextLocaleis kept because its reading differs from main'sreadOrganizationLocaleSetting(it is built on it, not beside it); its JSDoc carries the side-by-side table below.readOrganizationLocaleSettingreadOrganizationTextLocalesource: 'tenant',ja-JP)ja-JPja-JPsource: 'default'placeholderundefinedzh-CN)undefinedzh-CN)SETTINGS_UNKNOWN_KEYzh-CN)SETTINGS_STORE_UNAVAILABLERead by a probe at head over both exports (app default
zh-CN, organizationorg_1). The flow record write's private copy of the second column (service-automation) is gone; the seed loader keeps the first.Needs a contract-tier review (
Metadata-protocol: added).Verification
Every heavy run went under
os-verify-lock.Head 7b8d110 merges main d57d6ee through
scripts/pm/os-regen-merge.sh(merge 5e33619, then the regeneration commit 7b8d110).packages/spec/dropped-refinements.baseline.jsonconflicted only in itsmeasuredheader (main 268 / 1116, this PR +1 schema / +6 sites) and was recomputed from the merged body, 269 / 1122;authorable-surface/data.jsonandcontent/docs/references/data/hook.mdxwere regenerated from the merged tree (gen:schema,gen:docs) rather than text-merged. After the merge:check:generated14/14;@objectstack/spectests 848 files, 27168 passed;@objectstack/lint214 files, 9107 passed; runtime sandbox + app-artifact-handlers 52 files, 649 passed; spec, lint and runtimetypecheckexit 0 (runtime's first run was red on a stale localdriver-tursobuild, green after rebuilding it).check-governed-merges.mjs --pr 34545at 7b8d110: "0 of 48 path(s) hit the register after 2 generated-artifact lift(s) (13 surfaces govern objectstack). ✅ NOT governed". Outside the baseline and the generated docs and surface, this PR's diff against main is line-for-line the one reviewed at 8929099 (git diff 31096af8 8929099eagainstgit diff d57d6eed 7b8d110d, same changed lines).Head 8929099 is L1 rework round 1 (review 6937770388), plus a merge of main 31096af:
validate-hook-refusal-templates.tsjudges hook texts;hook-text.tsfalls back from a translation that does not render to the declaredmessage, filled.@objectstack/lintvalidate-hook-refusal-templates.test.ts24/24; runtimehook-text.integration.test.ts+ hook-refusal suites 49/49.git diffempty after each): the lint pass skippingtexts⇒ 7 of 24 red (every refusal case, the stack pass and the publish gate; the 4 CONTROLs and the no-paramscase stay green). The run-time fallback writing the unrendered translation ⇒ 2 of 11 red (the new case, both paths).HookTextSchema.params, its JSDoc,automation/hooks.mdxand the changeset now say where each hole is refused (parse, oros validate/compile/ the publish gate). The liveness rowhook.texts.paramsis re-anchored atrenderHookTemplate.gen:schemaandgen:docsexit 0;check:generatedfailedcheck:livenesson its first run (thehook.texts.paramscitation named the replaced filler) and passed 14/14 after the re-anchor above.dispatch-gates --commandsderived 129 families at 8929099; all 129 ran: 128 exit 0, andcheck:skill-examplesexit 3 on a stale@objectstack/clientdist (nothing measured), exit 0 on its rerun afterpnpm --filter @objectstack/client build.node scripts/pm/check-governed-merges.mjs --pr 34545at 8929099, in a built tree: "governed-surface predicate: 0 of 48 path(s) hit the register after 2 generated-artifact lift(s) (13 surfaces govern objectstack). ✅ NOT governed". Bothskills/*/references/_index.mdlines read as a puregen:skill-refsregeneration on this tree ([finding]skills/*/references/_index.mdis generator-owned (gen:skill-refs) yet sits inside theskills/**governed-merge fence — every spec PR touching an indexed headline is forced to carry a governed-surface file #11705).@objectstack/runtimesandbox + app-artifact-handlers suites: 10 files, 308 passed (the hook-text pin 9/9 again at head).@objectstack/coreorganization-locale.test.ts: 10 passed.@objectstack/lintwalk + translation references: 255 passed.@objectstack/service-automation: 286 files, 4076 passed.@objectstack/spechook texts + hook refusals: 113 passed.Typecheck (
tsc --noEmit) of core, runtime, lint, service-automation: exit 0.pnpm --filter @objectstack/spec check:generated: 14/14 green after--fix;check:test-typecheckgreen.Ablation (
scripts/ablation-replace.mjs, restored, blob == HEAD,git diff HEADempty): replace the translation pick inhook-text.tswithundefined⇒ 6 of 9 integration tests red (every translated-language pin, both paths); the 3 that stay green are the missing-translation fallback (both paths) and the undeclared-key refusal, which read no translation.Head df9ac15 merges main 8dd8192.
packages/spec/dropped-refinements.baseline.jsonconflicted only in itsmeasuredheader (main moved sites 1090 → 1114, this PR 1090 → 1096); the header was recomputed from the merged body, 267 schemas / 1120 sites, andauthorable-surface/data.jsonwas regenerated withgen:schema. After the merge:check:generatedexit 0;@objectstack/speclocal tests 848 files, 27148 passed; runtime sandbox + app-artifact-handlers 52 files, 647 passed; runtime and service-automationtypecheckexit 0 (runtime's first run was red on a stale localdriver-tursobuild, green after rebuilding it).Head 70a4381 fixes
Test Core (2/8)at aae87d7:scripts/dropped-refinements.test.tschecks that the ledger'smeasuredheader totals equal its body. The hand-edited rows forHookTextand the four hooktexts.valueTypesites were added, but the header still read 266 schemas / 1090 sites; it now reads 267 / 1096.@objectstack/speclocal project: 847 files, 1 failed before the fix (this test), 27/27 in the file after.Head aae87d7 fixes three red CI checks at d4e652a:
Type Check · workspace: the new pin importedEngineInsertOptions, which@objectstack/spec/datadoes not export; it now namesDataEngineInsertOptions.pnpm --filter @objectstack/runtime typecheck(withcheck:test-typecheck) exit 0; core, lint and service-automationtypecheckexit 0.Test Core (2/8):metadata-form-zod-reconciliation.test.tsrefusedtextsas accepted by the Zod but not offered by the hook form. A root ledger row (omit,hook,texts) now records why: the Studio row is owed to a follow-up (see Acceptance notes). 76/76.Test Core (6/8):protocol.meta-types-degenerate-derivation.test.tspins the top-level property count/meta/typesserves;hook23 → 24 fortexts, with its history line.@objectstack/metadata-protocol: 355 files, 1 failed before the fix (this pin), 18/18 in the file after.check:query-options-erasure,check:slot-lookup,check:test-source-alias,check:type-check-debtexit 0;check:generatedexit 1 on a first run beside a concurrent build and exit 0 on a second run.Head d4e652a: the changeset's
Clause-②line now readsyes (widening), matchingMetadata-protocol: added(CICheck Changesetrefusednobesideadded).check-empty-changesetandcheck:changeset-fixedexit 0.Head a3a4bb5 merges main 107d2e8. GitHub read the PR as conflicting because both sides moved the generated schema counts in
content/docs/references/index.mdx(this PR +1 in Data, main +1 in UI), and GitHub does not use the repo's merge driver for generated artifacts. The local merge applied that driver. Resolution:gen:docson the merged tree (1667 schemas: Data 188, UI 177), thencheck:generated14/14 andcheck:docsexit 0.check-governed-merges --pr 34545: NOT governed, and bothskills/*/references/_index.mdlines are a puregen:skill-refsregeneration on this tree ([finding]skills/*/references/_index.mdis generator-owned (gen:skill-refs) yet sits inside theskills/**governed-merge fence — every spec PR touching an indexed headline is forced to carry a governed-surface file #11705).Head 7bebb37 (35212cf plus a JSDoc table on
readOrganizationTextLocaleand theSkills-docsline in the changeset): coreorganization-locale.test.ts10 passed andtsc --noEmitexit 0; the same 129-family derivation, of which the 26 changeset/docs/core families reran with exit 0. At 35212cf, merged with main after branching from e8cba8f. Gates:dispatch-gates --commandsderived 129 families; all 129 ran with exit 0 at this head, and--ranreports 129 run, 0 NOT-MEASURED, 0 UNRUN. On the first roundcheck:query-options-erasurecaught two erased options bags in the new pin (now typed) andcheck:spec-parsed-aliasasked for theHookTextSchemapin (added); the exit-3 prerequisites (shallow clone, unbuiltclient-reactand other dists) were built and every family rerun.🤖 Generated with Claude Code
https://claude.ai/code/session_01ADHkmNwjZuUekdsr5UH3GP