Repository navigation
fix(lint): os validate and the publish gate refuse a knowledge source whose documentBy is not a single-valued parent link - #38662
Conversation
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbWsSJprjGydwaCH1gD
📓 Docs Drift Check9 anchor(s) derived from 1 changed package(s); no hand-written page names any of them. 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 089dd061372012b4b8c519ab225f9026ba3691d1 && git checkout 089dd061372012b4b8c519ab225f9026ba3691d1
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 74a15cb73b878aa8095aab8472b8ca6f776ccb61 a082c9c5cf8713f24edfa9045554d6d4fa690656 && git checkout -B drift-repro 74a15cb73b878aa8095aab8472b8ca6f776ccb61 && git merge --no-ff a082c9c5cf8713f24edfa9045554d6d4fa690656
node scripts/docs-audit/affected-docs.mjs --json 74a15cb73b878aa8095aab8472b8ca6f776ccb61 |
…rving reference-target caller Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbWsSJprjGydwaCH1gD
|
repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu 2026-11-30T02:11Z · L1 ACCEPT at
|
|
repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu 维护者速读
席位核对ACCEPT · L1 · area o2-A · Head-sha
|
|
repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu 2026-11-30T07:08Z · Landing · seat ACCEPT 7266792463 at
|
Requested by Warren · project thread
Fixes #38537
Clause-②: no
Metadata-protocol: none
Lands after #38594 (merged 2026-11-30T01:10Z; main merged into this branch at
d1e1ba3f03). Both PRs are seat 2's. The overlap is two files (packages/lint/src/index.ts,packages/lint/src/rule-explanations.ts), in hunks far apart;overlap-checkreads both clean against each other and main.维护者速读
documentBy)如果填的不是指向父记录的单值查找字段,os validate/os build/os lint和发布时都会报错并说明怎么改。之前只有在 Studio / 元数据 API 保存时才会拒绝。source.documentBy); record search groups by it by default #38537 的第二个也是最后一个 PR。documentBy的知识源;规则误判会让正确的知识源发布失败,删掉documentBy即可绕开。What changes
knowledge-source-document-by-not-parent-link(error) invalidate-knowledge-source.ts. It refuses asource.documentBythatmetadataFieldslists and that is not a single-valued parent link of the indexed object. The checks run in the save door's order: declared by the object, neither credential-class norinternal, alookup/master_detailtype, a targetreferenceTargetOfcan read, and notmultiple: true. Each reason gets its own message, worded like the save door'sdocumentUnitRefusalText, naming the field and the fix. Path:knowledgeSources[i].source.documentBy.validateKnowledgeSourceregistry entry, so it reachesos validate/build/lintand the runtime publish gate (knowledge_sourcewrites) with no new wiring. This is what judges a source a package ships or code registers; until now only the metadata API's save door did (feat(knowledge): a knowledge source declares its document unit (source.documentBy); record search groups by it by default #38564).documentBythatmetadataFieldsdoes not list is left to the parse, which already names that fix. A member the object does not have is reported once, asknowledge-source-field-unknown. An object with no readable field map is not judged.index.ts, one line in the knowledge block).rule-explanations.tsgets itsos explainentry and table row beside the five sibling rules.packages/core/src/security/second-object-read-exposure.pin.test.ts): the newreferenceTargetOfimport makesvalidate-knowledge-source.tsa caller of the reference-target arbiter, so it is classifiednot-a-served-readbeside the other lint callers. It only asks whether a target is declared, and reads and serves nothing of the target. Admitted by the seat for this fix after CI's Test Core (8/12) flagged the unclassified caller. Locally: 1 failed / 3 passed before the entry, 4/4 after.patchfor@objectstack/lint.Route chosen for the parent-link rule (#38564's PR 2 question)
#38564 left PR 2 two ways to reach
parentLinkRule/documentUnitOf(service-knowledge'sknowledge-search-scope.ts). The seat accepted a third:@objectstack/service-knowledge. Not taken.@objectstack/lint's package description says it "Depends on @objectstack/spec; never on a runtime", and service-knowledge is a runtime service. It would also need a new line on service-knowledge'sexportssurface.@objectstack/core". Not taken. Lint does not depend on@objectstack/core; its workspace dependencies areformula,metadata-core,sdui-parserandspec. Moving it tospecwould put runtime-shaped logic into the protocol package and widen this PR well past its card.parentLinkRuleitself asks. Withheld =isMaskedOnReadFieldType(type, managedBy)orinternal === true. That is the reading this file already takes forknowledge-source-field-never-indexed, and the onecollectCredentialWriteResponseFields/collectInternalWriteResponseFieldscompute in core. Target =referenceTargetOf(@objectstack/spec/data). The type pairlookup/master_detailis spelled locally, as eight other lint rule files already spell it. Cost: the four-part rule now lives in two places. No test pins their agreement, because no package that depends on both can importdocumentUnitOfwithout one more barrel line in service-knowledge. The module header names the save door's function so a change to one points at the other.Why
ADR-0161 K4: "a packaged item meets the gates that need no principal in
os validateand at publish".documentByis such a gate: it reads only the object definition. #38564 left it judged at save only, and its body says "PR 2'sos validaterule covers packaged sources."Clause-② and Metadata-protocol, measured from the diff
Clause-②: no/Metadata-protocol: none, a judgement call stated here for review. The rule refuses values ofsource.documentBy, a key #38564 added in this same prerelease line. Its changeset.changeset/38537-knowledge-document-by.mdis still pending (not moved to.changeset/pre/), so no published version carries the key and nothing an author could write against a release is refused. The metadata API's save door already refuses the same values. Read againstmaininstead, a packaged source with a non-parent-linkdocumentBypassedos validatebefore this PR and fails it after. If review prefers that reading, the lines becomeClause-②: no (narrowing)/Metadata-protocol: narrowed(levelminorand an ADR-0087 disposition).Verification
Acceptance (the card's
os validatehalf)validate-knowledge-source.document-by.test.ts)userfield, aninternallookup and amultiplelookup, each naming the fixos explainAblation (
scripts/ablation-replace.mjs, each mutation verified on disk, each restore verified blob == HEADd9f63681062fwith an emptygit diff HEAD)Call site disabled (
const refusal = documentUnitRefusal(…)→undefined): 9 redvalidate-knowledge-source.document-by.test.ts: 9 failed / 8 passed. All seven refusal tests, "a fields array is read like a field map", and "refuses the publish with the words os validate prints". The controls stay green.multiplearm deleted: 1 red1 failed / 16 passed: "refuses a multiple lookup as the document unit…".
internalhalf of the withheld arm removed: 1 red1 failed / 16 passed: "refuses an internal lookup as the document unit…". (A first attempt was refused by the tool before running anything, because its replacement text already occurred in the file; it was re-run with a distinct replacement.)
Package suite and typecheck
pnpm --filter @objectstack/lint test: Test Files 248 passed (248), Tests 9989 passed / 5 skipped. Exit 0.pnpm --filter @objectstack/lint typecheck(tsc + test layer): exit 0.eslinton the four changed source files: exit 0.overlap-check: VERDICT clean exit 0. origin/main merges cleanly, and so do the 7 open PRs sharing a file (fix(lint)!: refuse a list view grouped by a field the engine does not group by #38651, feat(lint)!: refuse an action or hook body that calls a sandbox gate it was not granted #38650, fix(runtime,cli,lint,spec)!: a sandboxed body's ctx.api.object(X).updateById(id, patch) writes the row #38643, fix(lint)!: judge a tree field's dependsOn filter key like a lookup's #38605, fix(lint)!: the publish gate refuses a subflow or map step that calls a flow the deployment does not hold #38594, feat(spec)!: actions that act on many records are placed atselection; a list view'sbulkActionsis retired #38550, feat(objectql): a record in a closed state, and its lines, are closed to change (closedStates, ADR-0162) — trunk #38497).Derived gate families (
dispatch-gates.mjs --commands, 70)--ranreports "70 derived famil(ies) accounted for — 66 run, 4 NOT-MEASURED (4 DERIVED from a recorded exit 3)". All 66 that ran exited 0, includingcheck-changeset-no-major --base origin/main,check-adr-0087-registration --base origin/main,check:doc-authoring,check:issue-citationsandcheck:cross-package-test-inputs.check-plugin-teardown-shape --self-test(neededgit fetch --unshallow),check:docs-transcript-drift(needed the built lint) andcheck:lean-entry-closure(needed the built objectql). These re-runs were by hand, outside the--ranrecord.check:dual-build-cjs-loadswas not measured locally: it reads every package'sdist/, which needs a full build. CI'sBuild Corejob runs it on this PR.Human Minimum
packages/specholds no runtime logic. (spec untouched)pnpm lintpasses (eslint on the changed files).main, one pull request.packages/spectouched: n/a.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Read first
packages/lint/src/validate-knowledge-source.ts:documentUnitRefusaland the call site afterjudgeMembers('metadataFields').packages/services/service-knowledge/src/knowledge-search-scope.ts:parentLinkRule/documentUnitOf, the save door's rule this one restates.Two-minute check:
pnpm --filter @objectstack/lint exec vitest run src/validate-knowledge-source.document-by.test.ts. Expect 17 passed.Dogfood: n/a (no
!in the title, no(narrowing)arm).🤖 Generated with Claude Code
https://claude.ai/code/session_01JQwxbWsSJprjGydwaCH1gD