Repository navigation
fix(lint): a context pack may name a system column the platform injects - #37426
objectstack-fleet[bot] wants to merge 4 commits into
Conversation
…ted system columns ai-context-field-unknown warned on owner_id / created_at in a pack on an object that does not declare them, while get_record_context reads the published definition, which carries the injected columns, and serves them. Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
… system columns Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift Check2 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. 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 9093ea008d3eb37ec04bb8509820c9666bff48b1 && git checkout 9093ea008d3eb37ec04bb8509820c9666bff48b1
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin ee11fce924ee0be609807738a3e0770cf6c396a3 83f809e905c3ad3d202495a7d304a23ad595662c && git checkout -B drift-repro ee11fce924ee0be609807738a3e0770cf6c396a3 && git merge --no-ff 83f809e905c3ad3d202495a7d304a23ad595662c
node scripts/docs-audit/affected-docs.mjs --json ee11fce924ee0be609807738a3e0770cf6c396a3 |
Fixes #37415
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
Measured first, on one real kernel (the
/mcpdoor, the real protocol,SqlDriver,sys_userregistered as the platform registers it): on an object that declares neitherowner_idnorcreated_at, the served object listing carries both (plusorganization_id,created_by,updated_at,updated_by,owning_business_unit_id,queue), andget_record_contextanswersowner_idandcreated_atin the root'sfieldsand in a related list'sfields(owner_idas a lookup entry, its value markednotVisiblebecause the harness caller cannot open thesys_userrow, as for any lookup whose target row it cannot read), filters the list by awhereonowner_id(one of two rows came back, the caller's) and orders it bycreated_at. On anownership: 'org'object the listing carries noowner_idand the tool leaves it out. So the runtime carries injected columns, and the warning was false.packages/lint/src/validate-ai-context.ts:fieldMapOfnow returns the effective map, the declared fields plusinjectedColumnDefsFor(object)(this package's one indirection over the spec'sinjectedSystemColumnDefs, the tablesapplySystemFieldsand the served read'sapplyInjectedSystemColumnsspread), a declared field winning. Every place the rule reads a field map reads it: rootfields,body.field, relatedfields,where,orderBy, and the related link. TheorderBysortability projection now reads the same effective map instead of the declared fields.body.fieldnaming an injected column is judged by its type (ai-context-body-not-long-text, as the executor reads the served definition); on a related list whose root is asys_*object, the child's injected references to it (owner_id,created_by,updated_bytosys_user) count as links, asresolveRelatedLinkcounts them over the published definition, so a child with one declared reference and nofieldis reported as having several. No non-sys_*root is affected: every injected reference points at asys_*object.owner_idunderownership: 'org'/'none', every system column undersystemFields: false..changeset/37415-ai-context-injected-columns.md:@objectstack/lintpatch.Read first (by risk)
packages/lint/src/validate-ai-context.ts, thefieldMapOfhunk: the merge direction (declared wins) and the sortability line.packages/lint/src/validate-ai-context.test.ts, the four new cases, especially thesys_*root link case.packages/services/service-record-context/src/__tests__/injected-system-columns.test.ts: the executor half over a door serving the registry-injected shape.Two-minute verification
pnpm --filter @objectstack/lint exec vitest run src/validate-ai-context.test.tsshows 22 passed, including "an injected system column the object does not declare is no unknown field (owner_id, created_at)".Tests
packages/lint/src/validate-ai-context.test.ts:owner_id,created_at,created_byin rootfields, relatedfields,where,orderByon objects that do not declare them: no finding.ownership: 'org'keepsowner_idunknown in all four places;systemFields: falsekeepscreated_atunknown.body.field: 'created_at'isai-context-body-not-long-text.sys_*root: injected references count as links.packages/services/service-record-context/src/__tests__/injected-system-columns.test.ts(new, read-only use of the service): over the fake door servinginjectedSystemColumnDefsmerged under the declared fields, the executor answersowner_id(with thesys_userdisplay) andcreated_atin root and related fields, filters bywhere: { owner_id }and orders bycreated_at desc; the same pack over a door serving declared fields only leaves every such name and the list out, silently.Acceptance notes
owner_idon an object that does not declare it, matching the measured runtime answer): the first new lint case; the measured runtime answer is quoted in a comment above it and in the service test's header.created_aton an object that does not declare it, while the rule warnedai-context-field-unknown: the same runtime answer forcreated_atinorderBy, measured independently.owner_idwas measured here.packages/runtime/src/mcp-record-context-tools-bridge.test.ts, run once and deleted, never committed (packages/runtime/**is fenced for this card). The committed pin of the executor half is the new service test over the fake door.sys_userregistered (a composition the platform never ships), namingowner_idrefuses the whole callPERMISSION_DENIED("reads an object you cannot read"):owner_idis a lookup tosys_user, and an unreadable lookup target refuses the call, as for any lookup. Measured, noted, not filed.os explaintext forai-context-field-unknown(packages/lint/src/rule-explanations.ts) still says "a name the object does not define"; it is outside this card's file surface and stays correct in substance (an injected column is defined on the object). Noted, not changed.externalobject carries injected columns with no storage behind them; this rule now lets a pack name one (the published definition carries it, so the executor plans it), and the read degrades at query time. The provenance warning other rules give (unprovisionedInjectedColumnsFor) is not wired into this rule. Noted, not filed: no producer measured.Verification
Real-kernel measurement (scratch, deleted)
Ablation (one, on the chosen behaviour)
Deleted the injected-column merge line in
fieldMapOfviascripts/ablation-replace.mjs(anchor x1 to x0, blob c2119a56ce9c to 2c8b47c54ad1);validate-ai-context.test.tswent 3 failed / 18 passed (the injected-column case, the ownership-org case throughcreated_at, the body case); restored, blob equals HEAD (c2119a56ce9c),git diff HEADempty. The lint test imports the rule from source, so no build leg applies.Package suites and gates
All at head
83f809e90, through the verify lock (VERDICT command-exit 0, 129 s held):Gates:
node scripts/pm/dispatch-gates.mjs --commandsderived 64 families for this diff; all 64 run locally, 62 exit 0, 2 exit 3 (PREREQUISITE NOT MET, read as NOT MEASURED, left to CI):node scripts/check-plugin-teardown-shape.mjs --self-test(its pinned positive control needs an unshallow clone) andpnpm check:dual-build-cjs-loads(reads every package'sdist/; only the runtime closure is built here).--ranreconciliation: 64 derived, 62 run, 2 NOT-MEASURED, 0 UNRUN. Package-closure build ahead of these:pnpm --workspace-concurrency=2 --filter '@objectstack/runtime^...' build(includes@objectstack/lintand@objectstack/service-record-context),VERDICT command-exit 0.Generated by Claude Code