Skip to content

fix(lint): a context pack may name a system column the platform injects - #37426

Draft
objectstack-fleet[bot] wants to merge 4 commits into
mainfrom
claude/issue-37415-ai-context-injected-columns
Draft

objectstack-fleet[bot] wants to merge 4 commits into
mainfrom
claude/issue-37415-ai-context-injected-columns

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #37415

Clause-②: no
Metadata-protocol: none

维护者速读

  • 写资料包的作者:在资料包里写平台自动加的字段(负责人、创建时间等),保存和校验时不再误报「字段不存在」;平台没加的字段照旧提醒。
  • 属于「AI 资料包」专题的跟进,替写资料包的作者解决误报。
  • 出错只会多报或少报一条提醒,资料包照常保存和读取;可以直接撤回。
  • 无。

What changes

Measured first, on one real kernel (the /mcp door, the real protocol, SqlDriver, sys_user registered as the platform registers it): on an object that declares neither owner_id nor created_at, the served object listing carries both (plus organization_id, created_by, updated_at, updated_by, owning_business_unit_id, queue), and get_record_context answers owner_id and created_at in the root's fields and in a related list's fields (owner_id as a lookup entry, its value marked notVisible because the harness caller cannot open the sys_user row, as for any lookup whose target row it cannot read), filters the list by a where on owner_id (one of two rows came back, the caller's) and orders it by created_at. On an ownership: 'org' object the listing carries no owner_id and the tool leaves it out. So the runtime carries injected columns, and the warning was false.

  • packages/lint/src/validate-ai-context.ts: fieldMapOf now returns the effective map, the declared fields plus injectedColumnDefsFor(object) (this package's one indirection over the spec's injectedSystemColumnDefs, the tables applySystemFields and the served read's applyInjectedSystemColumns spread), a declared field winning. Every place the rule reads a field map reads it: root fields, body.field, related fields, where, orderBy, and the related link. The orderBy sortability projection now reads the same effective map instead of the declared fields.
  • Consequences, each matching the runtime: a body.field naming 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 a sys_* object, the child's injected references to it (owner_id, created_by, updated_by to sys_user) count as links, as resolveRelatedLink counts them over the published definition, so a child with one declared reference and no field is reported as having several. No non-sys_* root is affected: every injected reference points at a sys_* object.
  • A column the platform does not inject on that object is still reported: owner_id under ownership: 'org' / 'none', every system column under systemFields: false.
  • .changeset/37415-ai-context-injected-columns.md: @objectstack/lint patch.

Read first (by risk)

  1. packages/lint/src/validate-ai-context.ts, the fieldMapOf hunk: the merge direction (declared wins) and the sortability line.
  2. packages/lint/src/validate-ai-context.test.ts, the four new cases, especially the sys_* root link case.
  3. 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.ts shows 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_by in root fields, related fields, where, orderBy on objects that do not declare them: no finding. ownership: 'org' keeps owner_id unknown in all four places; systemFields: false keeps created_at unknown. body.field: 'created_at' is ai-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 serving injectedSystemColumnDefs merged under the declared fields, the executor answers owner_id (with the sys_user display) and created_at in root and related fields, filters by where: { owner_id } and orders by created_at desc; the same pack over a door serving declared fields only leaves every such name and the list out, silently.

Acceptance notes

  • Acceptance bullet 1 (a test pins the lint verdict for owner_id on 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.
  • Corroboration: the real-kernel harness on sibling PR fix(service-record-context): get_record_context leaves out an unserved related child; both MCP doors supply queryableFieldsOf and their page cap #37412 shows the executor and both MCP doors read a related list ordered by created_at on an object that does not declare it, while the rule warned ai-context-field-unknown: the same runtime answer for created_at in orderBy, measured independently. owner_id was measured here.
  • Measurement method: the real-kernel reading was a scratch copy of the real-protocol harness in 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.
  • Without sys_user registered (a composition the platform never ships), naming owner_id refuses the whole call PERMISSION_DENIED ("reads an object you cannot read"): owner_id is a lookup to sys_user, and an unreadable lookup target refuses the call, as for any lookup. Measured, noted, not filed.
  • The os explain text for ai-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.
  • An ADR-0015 external object 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.
  • The new service test is a new file, as the dispatch order and the claim's file surface direct; the shared executor test file is owned by an in-flight sibling card.

Verification

Real-kernel measurement (scratch, deleted)
MEASURE served-listing rcm_policy fields: organization_id,created_at,created_by,updated_at,updated_by,owner_id,owning_business_unit_id,queue,title
MEASURE served-listing rcm_orgdoc fields: organization_id,created_at,created_by,updated_at,updated_by,title
rcm_brief (fields title, owner_id, created_at; related fields version, owner_id; where owner_id; orderBy created_at desc), sys_user registered:
  fields: title "Fire cover", owner_id (label Owner, notVisible: the sys_user row is not readable to this harness's caller), created_at "2026-11-26T03:16:17.088Z"
  related rcm_revision rows: r1 only (v1, owner_id) -- r2 (owner usr_other) filtered out by the where on owner_id
rcm_c (related fields version, created_at; where owner_id usr_member; orderBy created_at desc): rows r1 only (v1, created_at)
rcm_org_brief (ownership org; fields title, owner_id): fields title only
rcm_b (fields title, owner_id) WITHOUT sys_user registered: PERMISSION_DENIED 403
Ablation (one, on the chosen behaviour)

Deleted the injected-column merge line in fieldMapOf via scripts/ablation-replace.mjs (anchor x1 to x0, blob c2119a56ce9c to 2c8b47c54ad1); validate-ai-context.test.ts went 3 failed / 18 passed (the injected-column case, the ownership-org case through created_at, the body case); restored, blob equals HEAD (c2119a56ce9c), git diff HEAD empty. 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):

pnpm --filter @objectstack/service-record-context test       Test Files 3 passed (3) · Tests 102 passed (102)
pnpm --filter @objectstack/service-record-context typecheck  exit 0 (tsc --noEmit + check-test-typecheck)
pnpm --filter @objectstack/lint test                         Test Files 235 passed (235) · Tests 9637 passed (9637)
pnpm --filter @objectstack/lint typecheck                    exit 0 (tsc --noEmit + check-test-typecheck)

Gates: node scripts/pm/dispatch-gates.mjs --commands derived 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) and pnpm check:dual-build-cjs-loads (reads every package's dist/; only the runtime closure is built here). --ran reconciliation: 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/lint and @objectstack/service-record-context), VERDICT command-exit 0.


Generated by Claude Code

…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>
@github-actions github-actions Bot added size/m 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 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

2 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
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 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; 124 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 — 4 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 ee11fce924ee0be609807738a3e0770cf6c396a3 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 9093ea008d3eb37ec04bb8509820c9666bff48b1 — the merge of head 83f809e905c3ad3d202495a7d304a23ad595662c into base ee11fce924ee0be609807738a3e0770cf6c396a3, 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 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

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

This branch has not been deployed

No deployments
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/m 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.

37177 跟进:资料包校验对平台注入字段(owner_id)误报 ai-context-field-unknown

2 participants