Repository navigation
feat(lint): report ai_context author defects at save (validateAiContext on the runtime publish door) - #37247
Conversation
…context ADR-0160 D1: a context pack's author defects are reported at save as well as by os validate. The rule crosses to CLI_AND_RUNTIME with runtimeTypes ['ai_context'], and the gate maps the type to the aiContexts collection. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
…ule family, parity with os validate Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
…h saveMetaItem; add changeset Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
…-context-save-time-errors
📓 Docs Drift CheckThis PR changes 1 package(s): 1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 4 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 069b083f2cc89d1546b8726a3116f770794592fe && git checkout 069b083f2cc89d1546b8726a3116f770794592fe
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 1b91538bb206a01b027af64250394b30aa03fdff 30b20cf8047fbcac2c9c36904354988c74e905f9 && git checkout -B drift-repro 1b91538bb206a01b027af64250394b30aa03fdff && git merge --no-ff 30b20cf8047fbcac2c9c36904354988c74e905f9
node scripts/docs-audit/affected-docs.mjs --json 1b91538bb206a01b027af64250394b30aa03fdff
|
|
repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs 席位核对 — REWORK · repo:objectstack#3 · head fa24633 · 2026-11-25T07:19ZL1: REWORK (L1-w, zone ai-A) There is one should-fix, so under the merge standard this head is REWORK. Tier S: no governed path, 191 changed lines on this card's only PR. No L2 is owed. Should-fix
Read and found right (head fa24633)
Path to ACCEPT
|
…-context-save-time-errors
… under a stated scope Under a stated package scope the save door narrows objects to the write's closure, so an installed object outside it was told 'this stack does not define ... check the spelling'. validateAiContext now reads the scope, words that verdict for the closure and hints closureDependencyRemedy, as every save-door rule judging an object name under a scope does. Unscoped wording (os validate) is unchanged. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
… asserts Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
|
repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs 席位核对 — REWORK · repo:objectstack#3 · head 59f26fa · 2026-11-25T08:40ZL1: REWORK (L1-w, delta read, zone ai-A) Round 1's S1 is closed in the code. One new should-fix remains: the published changeset sentence the fix made false. It is a one-line prose push. This is Tier S, and no L2 is owed (the declaration face, as in round 1). Delta
|
…at names a package Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
|
repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs 席位核对 — ACCEPT · repo:objectstack#3 · head 30b20cf · 2026-11-25T09:14ZL1: ACCEPT (L1-w, delta read, zone ai-A) No must-fix, no should-fix. No L2 is owed (the declaration face: no Delta
|
|
repo:objectstack#3 · os-support-ai · session_01WGufzi13yZRqVcp2mGonWK Landing · 2026-11-25T09:15Z · ACCEPT 7158071623 at head 30b20cf (no L2 owed, Tier S)
State: ready + auto-merge (Tier S), ahead of #37143. On MERGED, #37176 closes by |
Requested by Yibo Wang · project thread
repo:objectstack#3 · os-support-ai · session_01WGufzi13yZRqVcp2mGonWK
Fixes #37176
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
validateAiContextcrosses to the runtime publish door:surfaces: CLI_AND_RUNTIME,runtimeTypes: ['ai_context'](packages/lint/src/authoring-rules.ts, the row at :1984), and the gate maps the type to its stack collection,ai_context: 'aiContexts'(packages/lint/src/runtime-gate.ts:312,TYPE_TO_STACK_KEY). Nothing inpackages/metadata-protocol/srcchanges: the host already gathers the liveobjects(registry plus stored rows, narrowed to the write's package closure) for every gated type, and that is the only collection the rule resolves into.packages/metadata-protocol/src/protocol-save.ts:1871(the gate's errors are thrown as the 422, its advisories are captured and ride the 2xx) and:2416-:2437(the receipt's conditionaladvisorieskey, omitted when empty). Every advisory-tier rule already on the runtime surface follows it, for examplevalidateRetiredPermissionResidue(authoring-rules.ts:2444) andvalidateEmailTemplateDefaultArguments(authoring-rules.ts:3212).validateAiContextis advisory (all four verdicts arewarning), so a defective pack is saved and told; a draft save is not judged.os validate), the answer carries the rule ids,where, messages and hintsos validateprints (the same rule function, run by the same registry). The path is the gate's per-write spelling (aiContexts[0]...: the written pack is the only member of its collection), so for a stack with several packs only the index can differ fromos validate's.objectsto the write's closure (narrowObjectsToWriteClosure), so an object missing from the snapshot may still be installed, andget_record_context, which reads the live merged objects, would read it. The rule now takes the scope, the wayvalidateFlowTriggerReadinessdoes:run: (stack, ctx) => validateAiContext(stack, ctx.packageScope ? { packageScope: ctx.packageScope } : {}). Under a scope,ai-context-object-unknownis worded for the closure: "names object 'X', which is outside the closure of package "P" (the package, the packages its manifest declares independencies, and platform objects), so the pack reads nothing of it where the package is installed without that dependency". Its hint isclosureDependencyRemedy(X, P, 'name an object inside that closure'), the remedy every save-door rule judging an object name under a scope prints. It is still awarning. With no scope the wording is byte-for-byte unchanged.get_record_contextandpackages/services/service-record-context/**are untouched (card What 3).Clause-② measured:
noNo member is added to the save answer: the findings ride
SaveMetaItemResponseSchema.advisories, which already exists and is already optional. Nothing that was accepted is refused, so no published accepted set narrows and none widens. The REST/client save-response types are not touched.Tests
packages/lint/src/validate-ai-context.test.ts, new top-level describe "validateAiContext on the runtime publish door": the dispatch and the stack key, then one case per rule family (misspelled field, unknown related object, related list with no link, body not long text). Each asserts no error, exactly one advisory with that rule and path, and{rule, severity, where, path, message, hint}equal torunAuthoringRules('validate', …)over the same pack. A clean pack earns nothing. Two more cases: under a stated scope, an installed object outside the closure gets the closure message and the exactclosureDependencyRemedyhint, and declaring the dependency clears it; with no scope, theos validatemessage and hint are pinned verbatim.packages/metadata-protocol/src/protocol.runtime-authoring-gate.test.ts(the sharedsaveMetaItemharness, per AGENTS.md's shared-harness rule), new top-level describe "ai_context author defects at save (ADR-0160 D1)": a runtime-created pack per family goes through the realsaveMetaItem, is persisted, and answerssuccess: truewithadvisoriesequal toos validate's{rule, where, message, hint}. A clean pack's answer has noadvisorieskey; a draft save is not judged and the same body saved active is. A pack saved withpackageId: 'app.fx'(installed, no dependencies) that namesaccount, owned by another installed package, is saved with the closure message and the exact remedy. The same object judged with no package keeps theos validatewords.Run readings, round 2 (head 59f26fa)
pnpm --filter @objectstack/lint test: Test Files 235 passed (235), Tests 9628 passed (9628), exit 0.pnpm --filter @objectstack/lint typecheck: exit 0.protocol.runtime-authoring-gate.test.ts: 259 passed.pnpm --filter @objectstack/metadata-protocol typecheck: exit 0.const closure = options.packageScope;replaced with a read of an unset global (the marker__ablated_scope__, injected 1 / original 0 on disk). Lint was rebuilt andablation-dist-preflightfound the marker in 4 dist files. Exactly the two scoped pins went red: lint 1 failed of 14, door 1 failed of 8. Restore: blob equal to HEAD, rebuilt, preflight--absentclean, then 14/14 and 8/8. An earlier attempt spelled its marker as an expression esbuild rewrites, so preflight could not see it in dist; that reading is void and is not counted.Run readings, round 1 (head fa24633 unless noted)
pnpm --filter @objectstack/lint test: Test Files 235 passed (235), Tests 9626 passed (9626), exit 0.pnpm --filter @objectstack/lint typecheck: exit 0.pnpm --filter @objectstack/metadata-protocol test: Test Files 370 passed, 9 skipped (379), Tests 23418 passed, 45 skipped, exit 0.pnpm --filter @objectstack/metadata-protocol typecheck: exit 0. (Both runs at 090e4c0; the merge of origin/main brought onlypackages/spec/src/ai/record-context-tools.zod.tsinto these packages' closure.)runtimeTypes: ['ai_context']replaced by['ablated_ai_context']throughscripts/ablation-replace.mjs(injected 1 / original 0 on disk), lint rebuilt,ablation-dist-preflightfound the marker in 4 dist files. The lint describe went 6 failed / 6 passed of 12; the door describe 5 failed / 1 passed of 6 (the clean-pack case passes either way, as expected). Restore: blob equal to HEAD,git diff HEADempty, rebuilt, preflight--absentclean, both green again (12/12, 6/6).Acceptance notes
objectsis narrowed to that package's closure (narrowObjectsToWriteClosure, unchanged). A pack naming an installed object outside that closure is toldai-context-object-unknownworded for the closure, with theclosureDependencyRemedyhint. It is not told the object is undefined or misspelled, which would be false at that install. A tenant overlay pack (no package) is judged against every live object, in theos validatewords.authoring-rules.tsandvalidate-ai-context.ts; the crossing also needs the oneTYPE_TO_STACK_KEYrow inruntime-gate.ts(a declared runtime type with no mapping builds no snapshot, andauthoring-rule-wiring.test.tsrefuses it). Stated in the report for the seat.Verification
packages/lint/src/authoring-rules.ts(thevalidateAiContextrow),packages/lint/src/runtime-gate.ts(theai_contextmapping row), then the new describe at the end ofprotocol.runtime-authoring-gate.test.ts.pnpm --filter @objectstack/lint exec vitest run src/validate-ai-context.test.ts. Expect 12 passed, including the four "is reported at save as ai-context-…" cases.dispatch-gates.mjs --commands, 65 families,--ranreconciles 65 of 65): 61 exit 0. Not measured locally, all run by CI:check-plugin-teardown-shape --self-test(exit 3, shallow checkout cannot read its pinned fixture),check:dual-build-cjs-loadsandcheck:lean-entry-closure(exit 3, need a whole-repo build),check:query-options-erasure(repo-wide ESLint scan, stopped at the local 300 s cap).Generated by Claude Code