Skip to content

fix(lint)!: four authoring rules now fire on the sibling spelling of a defect they already caught - #22281

Merged
objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-22212-lint-sibling-spellings
Oct 8, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-22212-lint-sibling-spellings

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Part of #22212
Clause-②: no (narrowing: each fix makes an existing rule fire on a sibling spelling)

Four of the card's six members are closed here: items 1, 3, 4 and 6. Items 2 and 5 are left out because each needs a new rule id. Details are in "Left out" below. No rule id is added, and no file outside packages/lint/src or .changeset/ is touched.

There is one commit per item, item 1 first, each carrying its own pins, plus one changeset commit. Every pin keeps the card's firing control beside the probe that now fires.

What changes

Item 1: hook-api-update-readonly-field / hook-body-write-unknown-field and an aliased ctx.api

  • Mechanism (H1 confirmed). Both rules read writes from extractHookBodyWriteSet in validate-hook-body-writes.ts. validate-readonly-hook-writes.ts imports it and has no extractor of its own. The api-crud-literal matcher required isCtxDot(receiver, 'api'), so only the literal ctx.api.object(...) matched.
  • Fix. The receiver can now be ctx.api or a local bound to it. A new collectCtxApiAliases pre-pass finds these locals. Type-only and non-null wrappers are seen through: as T, a type assertion, satisfies T, x! and parentheses.
  • Followed: const|let|var api = ctx.api (including the mandated as HookApi | undefined spelling), const { api } = ctx, const { api: db } = ctx, and an optional call api?.object(...).
  • Left opaque, deliberately. The card left open whether a reassigned or shadowed api must stay opaque. It does, and so do these:
    • a name declared more than once anywhere in the body, such as a nested parameter or a second const;
    • any assignment to the name;
    • a reference outside the declaring block, or outside the declaring function for var;
    • a non-alias initializer such as ctx.api ?? x;
    • an alias of an alias;
    • a destructure with a default;
    • const api = ctx.api.sudo(). The elevated channel stays invisible, as the readonly rule's header requires.
  • Ledger. HOOK_BODY_WRITE_PATTERNS api-crud-literal now states the receiver in its syntax line, and its reconciliation example includes the aliased spelling. The action-body write rules share the extractor and consume api-crud-literal, so they read the same receivers. The action ledger's end-to-end test pins that through the updated example.

Item 3: visibility-bare-identifier and an unbound namespace root

  • Mechanism. firstBareIdentifier declared every receiver-position name (namespaceRoots) before the strict check. foo.duplicate_of_type therefore always passed. The module note justified this with "the set of legal roots is not yet trustworthy enough to gate on (FormField/FormSection visibleWhen describe 宣称 runtime 表单绑定 current_user,但字段级条件规则的求值面从未绑过它——按文档写的谓词必然 fault 并 fail-open #6146)".

  • H3, measured. That doubt concerns members of the root set, and the rule still judges none of them. What it judges now is the complement of a set that is generous by contract. The checker already declares @objectstack/formula SCOPE_ROOTS, whose published contract is that a missing root is a false build error. VIEW_PAGE_EXTRA_ROOTS (current_user, page) is added to that.

  • What the renderers bind (objectui main f3a0488, read at buildExpressionScope, SchemaRenderer, the form renderer and the metadata-admin predicate.ts):

    • form field: record, previous, current_user, user, ctx, os, features;
    • page component: those plus page and the adapter data;
    • metadata form: data plus the identity roots.

    Every one of these is in the union.

  • Fix. The verdict is now the checker's alone. The receiver walk only classifies how the name was written, so an unbound namespace gets its own sentence and hint under the same id.

  • One stand-down. On a metadata-editing form, a dotted chain on the right of == / != stays predicate-rhs-path-shaped's, which is [finding] Two publish-time rules give an author contradictory fixes for the same bare unquoted word — visibility-bare-identifier (error) says data.active, predicate-rhs-path-shaped (warning) says 'active' #7696's single-voice rule one step further (rhsChainRoots).

  • Three pins changed. They encoded the old exclusion:

    • my_record.x on the metadata layer: still no mis-layer advisory, and now an unbound-root finding;
    • "an UNKNOWN root is left to the wrong-root rules": rewritten to its surviving half, which is that a wrong-but-bound root stays the ADR-0089 rules';
    • "an unknown root does not mask a bare identifier": both are now defects, the first is reported, and fixing it reveals the next.

Item 4: security-master-detail-ungranted and a lookup-bound child

  • H4 measured. SecurityPlugin.resolveCbpRelation (plugin-security/src/security-plugin.ts) resolves a controlled_by_parent object's master in this order: required master_detail, then any master_detail, then a required lookup. Lint's resolveCbpRelation / CBP_TIERS mirror it point for point. On the card's shape (a cbp object with a lookup and no master_detail), the runtime's parent is that lookup. An optional lookup resolves nothing, and security-controlled-by-parent-no-relation already reports that.
  • Fix. The new derivedAccessParent answers a cbp object through resolveCbpRelation. Every other object keeps the firstMasterDetailField reading. A child with two master_detail fields is now reported against the master the runtime picks. The message names the relation type.

Item 6: component-props-* and a nested component with no properties

Left out, and why (Part of)

  • Item 2 (an action body referencing an undeclared identifier). No existing rule judges it. action-body-source-unparseable answers a body that does not parse, and this body parses. The os lint hook-body/* rules answer a handler refused at lowering, not an authored body.source.
    • H2: the sandbox's globals DO have one declared, measured source. That is SANDBOX_GLOBALS in packages/cli/src/utils/detect-free-identifiers.ts, pinned by sandbox-globals-probe.test.ts.
    • That source lives in @objectstack/cli, which depends on @objectstack/lint, so the lint package cannot read it without moving it.
    • Item 2 therefore needs a new rule id and an edit outside the surface. Both are stop conditions.
  • Item 5 (an empty record:details section, fields: []). H5 holds. page-section-group-unknown is a reference rule: it resolves a section's group key against the object's field groups. An empty fields array carries no reference to resolve. Firing that id on it would change what the id means, so item 5 needs a new rule id.

Measurements

Unit-door probe (validate* from the built @objectstack/lint dist).

  • Before: at the base 9f0de32a, every probe is silent and every control fires.
  • After: at 4ab0ff40, every probe fires beside its control:
item 1  control ctx.api.object(..).update        readonly-field(error) + unknown-field(warning)
        probe   const api = ctx.api               before: silent  after: same two findings
        probe   ... as HookApi | undefined        before: silent  after: same two findings
        probe   api?.object(..)                   before: silent  after: same two findings
        probe   const api = ctx.api!              before: silent  after: same two findings
        opaque  reassigned / shadowed             silent before and after
item 3  control bare duplicate_of_type == ...     visibility-bare-identifier(error)
        probe   foo.duplicate_of_type             before: silent  after: visibility-bare-identifier(error)
item 4  control master_detail child ungranted     security-master-detail-ungranted(warning)
        probe   required-lookup cbp child         before: silent  after: security-master-detail-ungranted(warning)
item 6  control top-level, properties {}          component-props-invalid(warning)
        probe   nested, properties absent         before: silent  after: component-props-invalid(warning)

Public door, os lint --strict at 4ab0ff40. These are scratch configs inside examples/app-todo, removed afterwards (git status clean).

  • The control config fires all four rules: hook-api-update-readonly-field at hooks[0].handler, visibility-bare-identifier, security-master-detail-ungranted at objects[2].fields.campaign, and component-props-invalid.
  • The probe config, with each item's sibling spelling, fires the same four rules, with the nested path ...components[0].properties.children[0].properties.relationshipField.
  • Both exit 1.

Fixture sweep.

Tests and typecheck.

  • pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2: 126 files and 5793 tests passed.
  • pnpm --filter @objectstack/lint typecheck (tsc plus check:test-typecheck): exit 0.

ESLint, narrowed and proven.

  • The command was eslint --no-inline-config --format json on the 10 changed .ts files. The JSON output lists 10 files linted, with 0 errors and 0 warnings. None was ignored.
  • eslint.config.mjs never enables type-aware linting (no parserOptions.project; its own note at the QUERY_OPTIONS_TEST_GLOBS block says so). So this diff cannot move any untouched file's verdict.

Gates. The derived gate list (dispatch-gates --commands, 62 families at 4ab0ff40) was run, and --ran was reconciled. The results are in the report comment on the card.

Acceptance notes

  • Message wording. The readonly and unknown-field messages still quote the receiver as ctx.api.object('X')... when the author wrote api.object('X').... That is true of the call, because api is ctx.api, but an author grepping for it will not find it. The location path points at the body or handler. Not filed.
  • Over-approximate stand-down. rhsChainRoots stands down a root that appears anywhere on the right of a metadata form's == / !=, including inside a macro body. That direction can only remove a finding.
  • Changeset level: minor, not patch. The PR declares Clause-②: no (narrowing). check-changeset-no-major enforces at least minor on a package whose src this PR grows when the arm is narrowing, and AGENTS.md reads that arm as BREAKING. The changeset therefore carries the **BREAKING** banner and an ADR-0087 not-required (no-migration-prescription) disposition. That gate passes locally.

Generated by Claude Code

claude added 5 commits October 8, 2026 10:48
…tractor

`hook-api-update-readonly-field` and `hook-body-write-unknown-field` read their
writes from one extractor whose `api-crud-literal` matcher accepted only the
literal `ctx.api.object(...)` receiver. A body that binds the handle first --
`const api = ctx.api as HookApi | undefined`, an app convention -- had every
write invisible to both rules while the byte-identical `ctx.api.object(...)`
statement fired both.

The receiver is now `ctx.api` or a never-reassigned, singly-declared local
bound to it (`const|let|var x = ctx.api` through type-only and non-null
wrappers, `const { api } = ctx`, `const { api: x } = ctx`), within the block
that declares it. Reassigned, shadowed, defaulted, out-of-scope and
alias-of-alias bindings stay opaque, and `ctx.api.sudo()` stays invisible.
The action-body rules share the extractor and gain the same receiver.

Claude-Session: https://claude.ai/code/session_01DhTqaEHqPVSVnAkjG3jywn
Co-authored-by: Claude <noreply@anthropic.com>
`visibility-bare-identifier` declared every receiver-position name before the
strict check, so `has(record.x) && foo.x == 'crm_lead'` published clean while
the console's engine answered `Unknown variable: foo` and fell open -- the
failure the bare spelling of the same predicate gates on.

The verdict is now the checker's alone, against the roots it already declares
(`@objectstack/formula` SCOPE_ROOTS, a generous-by-contract baseline) plus
`current_user` / `page`. The receiver walk only classifies how the name was
written, so an unbound namespace gets its own sentence and fix under the same
id. Every root a renderer binds (record, previous, parent, current_user, user,
ctx, os, features, page, data) is in that union and stays clean; a dotted chain
on the right of a metadata-editing form stands down for
`predicate-rhs-path-shaped`, as a bare word there already did.

Claude-Session: https://claude.ai/code/session_01DhTqaEHqPVSVnAkjG3jywn
Co-authored-by: Claude <noreply@anthropic.com>
…nted

The rule keyed on `firstMasterDetailField`, so a `controlled_by_parent` object
bound to its master through a required lookup -- ADR-0055's third tier, which
the runtime resolves exactly like a master_detail -- was never a "detail" here.
Granted in no permission set, it hits the same never-derived object-level CRUD
gate (a role-bound 403) and the rule stayed silent.

A `controlled_by_parent` object now answers through `resolveCbpRelation`, the
mirror of the runtime's precedence, so the lookup-bound child is judged and a
child with two master_detail fields names the master the runtime picks. Every
other object keeps the master_detail reading; an optional lookup still resolves
nothing and is left to the no-relation error.

Claude-Session: https://claude.ai/code/session_01DhTqaEHqPVSVnAkjG3jywn
Co-authored-by: Claude <noreply@anthropic.com>
`validateComponentProps` skipped any component whose `properties` was not an
object. A top-level node never arrives that way on the parsed door --
`PageComponentSchema` defaults the bag to `{}` -- but a NESTED node sits in an
untyped slot (`children`, `items[].children`, `footer`) that the schema never
parses, so its absent bag stayed `undefined` and every required prop it
omitted went unreported while the same node one level up drew
`component-props-invalid`.

An absent bag is now judged as `{}`; a present non-object bag is still left to
the parse that owns its shape. The #5775 container fixture's filler children
now carry the one prop `element:text` requires.

Claude-Session: https://claude.ai/code/session_01DhTqaEHqPVSVnAkjG3jywn
Co-authored-by: Claude <noreply@anthropic.com>
… they already caught

Claude-Session: https://claude.ai/code/session_01DhTqaEHqPVSVnAkjG3jywn
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added the size/l label Oct 8, 2026
@github-actions github-actions Bot added 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 Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

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

18 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 c8bb3c8d9cdae41c51b72f1cb3cb5028988e1fe4.

⛔ 8 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/validate-readonly-hook-writes.ts) — pages documenting those are invisible to this run
  • 1 anchor(s) matched too much of the corpus to be a work list: master_detail (literal, 31 pages)
  • 5 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 — 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 c8bb3c8d9cdae41c51b72f1cb3cb5028988e1fe4 → packageMentionDocs.

Which tree this was computed on

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

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

⚠️ 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 c8bb3c8d9cdae41c51b72f1cb3cb5028988e1fe4 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

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/l 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.

2 participants