Skip to content

feat(spec)!: refuse a user field whose reference names an object other than sys_user; every user field resolves to sys_user - #25074

Merged
objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/issue-24952-user-field-reference-refused
Oct 22, 2026
Merged

objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/issue-24952-user-field-reference-refused

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #24952

Clause-②: no (narrowing: a user field naming an object other than sys_user is refused; ships now under the amended 「甲」, #6015 6303865025)
Metadata-protocol: narrowed

The refusal half of #24808 (ruled A on #24854), re-timed to 18.x by the amended 「甲」 ruling. BREAKING: the accept set of FieldSchema narrows. Shipped as a minor changeset.

What changed

  • FieldSchema refuses the shape (packages/spec/src/data/field.zod.ts). A field of type: 'user' whose reference names anything but sys_user gets one custom issue at reference. The message names the lookup spelling ({ type: 'lookup', reference: 'TARGET' } / Field.lookup('TARGET', ...)) and says that deleteBehavior must be chosen. Absent, blank and 'sys_user' still parse. The check is on FieldSchema rather than as an ObjectSchema superRefine (the refuseForeignTreeReference precedent), because the verdict needs only the field. So objects, object extensions and defineStack all refuse it through the same code.
  • referenceTargetOf answers sys_user for every user field, whatever the carrier says (field-value.zod.ts). A carrier that cannot be read still throws. A stored body saved before this release therefore resolves to sys_user as well.
  • Field.user(): reference is now typed 'sys_user' (still @deprecated) and is written after the config spread. The output keeps its key order and its literal types.
  • ADR-0087 D3 semantic entry user-field-foreign-reference-refused (packages/spec/src/migrations/entries/semantic/18.user-field-foreign-reference-refused.ts). It is not a conversion, because the rewrite to a lookup is not lossless: a lookup joins the referential delete walk with deleteBehavior: 'set_null', and deleteBehavior has no value meaning "leave it". objectstack migrate meta reports the entry.
  • The @objectstack/lint advisory user-field-foreign-reference is withdrawn. It was added for 18.x and never published, and the parse refusal replaces it. Removed: the rule, its RULE_EXPLANATIONS entry, its export and its tests.
  • The 18.x pins are retired. In field-value.test.ts (my_people) and the object-graph.test.ts explicit-carrier control, both now assert that the hop lands on sys_user. The validate-object-references unknown-object control is now proven on a lookup.
  • Changeset: .changeset/24952-user-field-reference-refused.md (breaking, with FROM/TO, the fix and the ADR-0087 marker).

The pending 24808 changeset (route B, seat decision 2026-10-22)

This PR no longer deletes .changeset/24808-user-field-foreign-reference-warning.md, the pending release note of #24942. The file is restored byte-identical to main, so check-empty-changeset is green.
Instead, this PR's own .changeset/24952-user-field-reference-refused.md names @objectstack/lint as well as @objectstack/spec, carries Metadata-protocol: narrowed, and has a Supersedes paragraph. That paragraph says the user-field-foreign-reference advisory, the USER_FIELD_FOREIGN_REFERENCE export and its os explain entry that 24808 announced are withdrawn before release, and that a foreign reference on a user field is now refused by FieldSchema. Both entries land in @objectstack/lint's CHANGELOG together, so a reader can tell which one is current. The packages version in lockstep, so naming lint moves no version number.

Producers

The first act from the re-timing comment was to measure who writes this shape. A source grep over the tree (tests excluded) found no type: 'user' with a foreign reference in any app, example or package. pnpm --filter @objectstack/spec test:repo, which parses the repo's example stacks, is green. So no producer needs fixing in this PR. Two test fixtures used the shape: the object-graph.test.ts module fixture was already a lookup, and the explicit-carrier control is rewritten here.

Verification (head bf738d1f99, merged with origin/main at 63085c3806)

  • pnpm --filter '@objectstack/lint^...' build (spec and the rest of lint's dependency closure): exit 0.
  • pnpm --filter @objectstack/spec check:generated: all 14 generated artifacts up to date. No regeneration was needed: no .describe(), authorable key or public export changed.
  • pnpm --filter @objectstack/spec exec vitest run --project local: 706 files, 21433 tests passed.
  • pnpm --filter @objectstack/spec test:repo: 72 files, 1237 tests passed.
  • pnpm --filter @objectstack/spec typecheck: exit 0. This includes check:test-typecheck, which compiles the expectTypeOf pins in the new test file.
  • pnpm --filter @objectstack/lint exec vitest run: 153 files, 7045 tests passed. pnpm --filter @objectstack/lint typecheck: exit 0.
  • node scripts/pm/dispatch-gates.mjs --ran, round 2 at 1a4eb0cf80, after merging origin/main and restoring 24808: 91 derived, 87 run, 4 NOT MEASURED on the first pass (missing dist). Three of those were re-run green after the closure builds (check:doc-formula-expressions, check:docs-transcript-drift, check:lean-entry-closure), which leaves check:dual-build-cjs-loads to CI. check-empty-changeset, check-changeset-no-major --event, check:adr-0087-registration, check-changeset-fixed and check:nul-bytes all exit 0. spec: 21471 tests and test:repo 1247 passed; lint: 7069 passed.

Acceptance notes

  • objectui half of the card's item 6 is not in this PR. packages/fields/src/__tests__/userCell.readGate-10535.test.tsx at the pinned .objectui-sha (cf153eb2e5) still pins that the user cell's person object is the field's reference (crm_member). The fixture casts its field and never parses it, so nothing here turns it red. But it now pins a reading the spec refuses. The renderer reads reference directly rather than the type's constant, so for a stored body saved before this release it would gate by a different object than the runtime resolves. Retiring it is a change in objectui, outside this claim's file surface.
  • The save door is inferred, not measured. The changeset says the metadata save door refuses the shape. That follows from object mapping to ObjectSchema in packages/spec/src/kernel/metadata-type-schemas.ts. It was not measured over HTTP in this PR.
  • Contract review. The claim says this PR owes a CONTRACT_REVIEW_TIER contract review.
  • Open PRs that touch field.zod.ts, field-value.zod.ts, object.zod.ts or the lint files in this diff: none (all 11 open PRs were read).

Generated by Claude Code

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/lint, @objectstack/spec, touching 13 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/lint/src/index.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

19 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json b6e870707b95d7b8ee9cedd68ad358b51de0da91.

⛔ 5 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/lint/src/index.ts) — pages documenting those are invisible to this run
  • 1 anchor(s) matched too much of the corpus to be a work list: sys_user (literal, 42 pages)
  • 7 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 54 of 206 client-bound route-ledger rows — the other 152 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 152: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 97 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 — 144 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 b6e870707b95d7b8ee9cedd68ad358b51de0da91 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 78ac70748fed2ec9853aabb65ce179fd9adb3a7f — the merge of head 1a4eb0cf80a72df05c8bde66858344a65de3ceda into base b6e870707b95d7b8ee9cedd68ad358b51de0da91, 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 78ac70748fed2ec9853aabb65ce179fd9adb3a7f && git checkout 78ac70748fed2ec9853aabb65ce179fd9adb3a7f
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin b6e870707b95d7b8ee9cedd68ad358b51de0da91 1a4eb0cf80a72df05c8bde66858344a65de3ceda && git checkout -B drift-repro b6e870707b95d7b8ee9cedd68ad358b51de0da91 && git merge --no-ff 1a4eb0cf80a72df05c8bde66858344a65de3ceda

node scripts/docs-audit/affected-docs.mjs --json b6e870707b95d7b8ee9cedd68ad358b51de0da91

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

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs b6e870707b95d7b8ee9cedd68ad358b51de0da91 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

…he 24952 entry

Restore .changeset/24808-user-field-foreign-reference-warning.md byte-identical
to origin/main. The 24952 entry now declares Metadata-protocol: narrowed, names
@objectstack/lint (minor) so the withdrawal of the advisory and of the
USER_FIELD_FOREIGN_REFERENCE export lands in the CHANGELOG the 24808 entry
writes to, and states that it supersedes that entry.

Claude-Session: https://claude.ai/code/session_01D6F9axfoPzR7t8G1J7Ytzz
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 1a4eb0cf80a72df05c8bde66858344a65de3ceda
Local-runs: none
Scope: packages/spec/src/data/field.zod.ts, packages/spec/src/data/field-value.zod.ts, packages/spec/src/data/*.test.ts, packages/spec/src/migrations/entries/semantic/18.user-field-foreign-reference-refused.ts, packages/lint/src/** (withdrawn advisory) + .changeset/24952-user-field-reference-refused.md

① Derived judgments

  • The refusal sits in FieldSchema's superRefine (field.zod.ts:2441-2475), the single schema every field door composes: ObjectSchema and ObjectExtensionSchema through the shared field map, defineStack objects, and the metadata save door (kernel/metadata-type-schemas.ts:91).

  • No false positive: an absent reference, '' and 'sys_user' all parse, and no other user-object alias exists (field-value.zod.ts:179-181).

  • Stored data survives:

    • the boot-time Registry.validate parse (objectql/src/registry.ts:5294) is a logged diagnostic, not a gate (:5107-5124);
    • rehydration does not parse (database-loader.ts:884).

    So a stored foreign-reference user field still boots and serves. Its next save is refused, with the issue located at the field. referenceTargetOf now resolves it to sys_user, a runtime change the changeset FROM/TO and the D3 acceptance criteria both declare.

  • The withdrawn lint advisory never shipped: there is no CHANGELOG hit, git tag --contains e7befa7700 is empty, and both packages are at 18.0.0. Deleting its pending note is therefore right.

  • No shipped producer authors the shape. The tests are real: the base pins that accepted the shape now assert the opposite.

  • Round 2 (1a4eb0cf80). origin/main is merged in. File by file, the PR's diff against its merge base is unchanged from the reviewed head bf738d1f99 in every packages/spec/src and packages/lint/src file. Only .changeset/24952-*.md differs, and the 24808 deletion is gone. Spec 21471 tests and test:repo 1247 passed; lint 7069 passed.

② Semver level

@objectstack/spec minor with the BREAKING banner and Clause-②: no (narrowing). The ADR-0087 disposition is registered on the new D3 entry user-field-foreign-reference-refused. That is the right arm, because no lossless conversion exists: re-targeting a foreign reference to sys_user would resolve another object's ids against sys_user, and a rewrite to lookup adds the referential delete walk. @objectstack/lint has no net change against 18.0.0, so no lint changeset is owed. Field.user's only public type change is the intended narrowing of reference to 'sys_user'.

③ Boundary flags

  • Landing (round 2, route B): the pending note .changeset/24808-user-field-foreign-reference-warning.md is now restored byte-identical to main (blob 5e599bf573), so check-empty-changeset is green. This PR's own changeset names @objectstack/lint beside @objectstack/spec, carries Metadata-protocol: narrowed, and has a Supersedes paragraph that withdraws the advisory, the export and the os explain entry 24808 announced. Both entries land in lint's CHANGELOG. In the lockstep fixed group, naming lint moves no version.
  • Cross-repo follow-up: objectui's userCell gates by the authored reference (packages/fields/src/__tests__/userCell.readGate-10535.test.tsx:154-164 at pin cf153eb2e5). This is not a pin-gate hazard, because objectui parses neither schema, but the follow-up is filed as fields: userCell gates by the authored reference of a user field, but objectstack now resolves every user field to sys_user (objectstack#24952) objectui#13305.
  • Optional: there is no refused-shapes.ts detector for os migrate meta --stored, matching the repo norm.
  • The form-field component props (ui/component.zod.ts:6723-6743) are a widget-prop surface outside this card.
  • No governed path. content/docs/releases/ is untouched.

Implemented-by: claude/issue-24952-user-field-reference-refused
Reviewed-by: session_01D6F9axfoPzR7t8G1J7Ytzz

VERDICT: PASS

Seat re-read of the check-runs at landing: all 49 runs on 1a4eb0cf80 have completed: 40 succeeded, the rest were skipped, and none is red.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review October 22, 2026 08:03
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge October 22, 2026 08:03
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Oct 22, 2026
Merged via the queue into main with commit 2069b81 Oct 22, 2026
50 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-24952-user-field-reference-refused branch October 22, 2026 08:40
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 protocol:data size/l tests tooling

Projects

None yet

2 participants