Repository navigation
fix(lint)!: four authoring rules now fire on the sibling spelling of a defect they already caught - #22281
Conversation
…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>
📓 Docs Drift CheckThis PR changes 1 package(s): 18 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 8 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. 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 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
|
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/srcor.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-fieldand an aliasedctx.apiextractHookBodyWriteSetinvalidate-hook-body-writes.ts.validate-readonly-hook-writes.tsimports it and has no extractor of its own. Theapi-crud-literalmatcher requiredisCtxDot(receiver, 'api'), so only the literalctx.api.object(...)matched.ctx.apior a local bound to it. A newcollectCtxApiAliasespre-pass finds these locals. Type-only and non-null wrappers are seen through:as T, a type assertion,satisfies T,x!and parentheses.const|let|var api = ctx.api(including the mandatedas HookApi | undefinedspelling),const { api } = ctx,const { api: db } = ctx, and an optional callapi?.object(...).apimust stay opaque. It does, and so do these:const;var;ctx.api ?? x;const api = ctx.api.sudo(). The elevated channel stays invisible, as the readonly rule's header requires.HOOK_BODY_WRITE_PATTERNSapi-crud-literalnow states the receiver in its syntax line, and its reconciliation example includes the aliased spelling. The action-body write rules share the extractor and consumeapi-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-identifierand an unbound namespace rootMechanism.
firstBareIdentifierdeclared every receiver-position name (namespaceRoots) before the strict check.foo.duplicate_of_typetherefore always passed. The module note justified this with "the set of legal roots is not yet trustworthy enough to gate on (FormField/FormSectionvisibleWhendescribe 宣称 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/formulaSCOPE_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
mainf3a0488, read atbuildExpressionScope,SchemaRenderer, the form renderer and the metadata-adminpredicate.ts):record,previous,current_user,user,ctx,os,features;pageand the adapterdata;dataplus 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
==/!=stayspredicate-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) saysdata.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.xon the metadata layer: still no mis-layer advisory, and now an unbound-root finding;Item 4:
security-master-detail-ungrantedand a lookup-bound childSecurityPlugin.resolveCbpRelation(plugin-security/src/security-plugin.ts) resolves acontrolled_by_parentobject's master in this order: requiredmaster_detail, then anymaster_detail, then a requiredlookup. Lint'sresolveCbpRelation/CBP_TIERSmirror it point for point. On the card's shape (a cbp object with a lookup and nomaster_detail), the runtime's parent is that lookup. An optional lookup resolves nothing, andsecurity-controlled-by-parent-no-relationalready reports that.derivedAccessParentanswers a cbp object throughresolveCbpRelation. Every other object keeps thefirstMasterDetailFieldreading. A child with twomaster_detailfields is now reported against the master the runtime picks. The message names the relation type.Item 6:
component-props-*and a nested component with nopropertiesvalidateComponentPropsranif (!props) continueonisRec(component.properties).{}, which is the valuePageComponentSchema's default gives a top-level node. A present non-object bag is still skipped.{ type: 'element:text' }as filler children. The fix updated the filler (it now carries the one required prop). The test's subject, the container keys, is unchanged.Left out, and why (
Part of)action-body-source-unparseableanswers a body that does not parse, and this body parses. Theos linthook-body/*rules answer a handler refused at lowering, not an authoredbody.source.SANDBOX_GLOBALSinpackages/cli/src/utils/detect-free-identifiers.ts, pinned bysandbox-globals-probe.test.ts.@objectstack/cli, which depends on@objectstack/lint, so the lint package cannot read it without moving it.record:detailssection,fields: []). H5 holds.page-section-group-unknownis a reference rule: it resolves a section'sgroupkey against the object's field groups. An emptyfieldsarray 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/lintdist).9f0de32a, every probe is silent and every control fires.4ab0ff40, every probe fires beside its control:Public door,
os lint --strictat4ab0ff40. These are scratch configs insideexamples/app-todo, removed afterwards (git statusclean).hook-api-update-readonly-fieldathooks[0].handler,visibility-bare-identifier,security-master-detail-ungrantedatobjects[2].fields.campaign, andcomponent-props-invalid....components[0].properties.children[0].properties.relationshipField.Fixture sweep.
os lint --json --skip-i18nat4ab0ff40onexamples/app-crm,app-todo,app-showcaseandapp-multi-packagereports 0 findings from any affected rule id. The registry runs on that door:security-private-no-readscopeandapproval-approvers-may-resolve-emptyboth appear.Tests and typecheck.
pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2: 126 files and 5793 tests passed.pnpm --filter @objectstack/lint typecheck(tsc pluscheck:test-typecheck): exit 0.ESLint, narrowed and proven.
eslint --no-inline-config --format jsonon the 10 changed.tsfiles. The JSON output lists 10 files linted, with 0 errors and 0 warnings. None was ignored.eslint.config.mjsnever enables type-aware linting (noparserOptions.project; its own note at theQUERY_OPTIONS_TEST_GLOBSblock says so). So this diff cannot move any untouched file's verdict.Gates. The derived gate list (
dispatch-gates --commands, 62 families at4ab0ff40) was run, and--ranwas reconciled. The results are in the report comment on the card.Acceptance notes
ctx.api.object('X')...when the author wroteapi.object('X').... That is true of the call, becauseapiisctx.api, but an author grepping for it will not find it. The location path points at the body or handler. Not filed.rhsChainRootsstands 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.minor, notpatch. The PR declaresClause-②: no (narrowing).check-changeset-no-majorenforces at leastminoron a package whosesrcthis PR grows when the arm isnarrowing, and AGENTS.md reads that arm as BREAKING. The changeset therefore carries the**BREAKING**banner and an ADR-0087not-required (no-migration-prescription)disposition. That gate passes locally.Generated by Claude Code