Skip to content

KB-01: add knowledge contracts and pure lifecycle core - #1

Merged
FlyOverCoderKY merged 6 commits into
mainfrom
claude/kb-01-contracts-core
Nov 7, 2026
Merged

FlyOverCoderKY merged 6 commits into
mainfrom
claude/kb-01-contracts-core

Conversation

@FlyOverCoderKY

@FlyOverCoderKY FlyOverCoderKY commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

KB-01 introduces the standalone Knowledge Base contracts and pure core. Collections default to private, independently configure portal/bot audiences, and require exact preview approval for anonymous access. Articles inherit collection policy, retain immutable hashed revisions, and bind publication to the reviewed content, applicability, policy, and verified evidence snapshots.

The core supports drafting/revision, article-appropriate checks, evidence replacement, review, publication, rejection, and retirement. Editing or changing authority invalidates pending approval while a previously approved revision remains a separate immutable snapshot.

Compatibility and authority

This is the first source implementation; both 0.1.0 packages are unpublished. No HTTP/MCP endpoint, persistence, retrieval service, model integration, or host deployment is enabled. The later KB-02/host boundary must authenticate/authorize actors and evidence receipts; identity claims in pure transition inputs are not authentication.

Added Node 22/24 CI, CodeQL, package-local docs/licenses, build-on-prepack, compiled-test exclusion, artifact integrity/inventory checks, and clean tarball-consumer imports. Release documentation keeps publication and trusted-publisher setup as separate maintainer operations.

Implements KB-01 from the approved plan, using the P-00 handoff.

Validation

  • pnpm run format:check
  • pnpm run check
  • pnpm test — 54 public-entry tests
  • pnpm run release:check
  • pnpm run release:pack — two verified artifacts and clean consumer imports
  • Independent core and contracts/documentation reviews; chronology regression reproduced and fixed
  • Whitespace and literal-control-byte checks
  • No private host internals or real customer data

Local gate ran on Node 24. Current-head Node 22/24 and security/review CI must finish before merge.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ❌ Failed 2026-11-06T22:23:02.115923Z
We couldn’t complete this review. Comment @codex security review to try again.
03c72be PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

OpenRouter review posted (clean). #1 (review)

@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenRouter pull-request review

Verdict: issues
Scope: full-pr (full-pr)
Mode: initial
Commit: 03c72be0ce5079b2db7400cfd894fe3e1cc61563
Judge: skipped (one successful review lane; no merge needed)
Cost: $0.32 + at least $0.0252 (incomplete)

Lanes

  • meta/muse-spark-1.2: ok (9 finding(s), 91.0s, 309973+15553 tokens (119221 cached), 4 tool round(s), via Meta, $0.32)
  • z-ai/glm-5.3-flash: failed-open (at least $0.0252 spent, incomplete) — OpenRouter lane wall-clock deadline exhausted; lane transport history (includes recovered errors): transport_timeouts=2, elapsed_deadlines=2

Findings

🔴 Issue 1 — Explicit undefined optional fields break canonical hashing

packages/core/src/validation.ts:270 · bug · identified by meta/muse-spark-1.2

Creating a draft with applicability like { productId: "x", productVersion: "1", buildId: undefined } (easy when spreading a DB row) throws KnowledgeBaseError("invalid","hash","Hash input must contain JSON values only") instead of succeeding or reporting the field.

validateApplicability allows buildId/locale to be undefined and keys allows the key, but canonical() calls JSON.stringify(undefined) for that property value and then invalid("hash",...). Callers createArticle/reviseArticle/digest in packages/core/src/articles.ts and verifyEvidence in packages/core/src/validation.ts:canonical propagate the wrong code/field. structuredClone preserves explicit undefined keys, so any host that builds Applicability with buildId: maybeBuildId where maybeBuildId is undefined hits this.

Checked packages/core/src/validation.ts canonical/digest/validateApplicability and packages/core/src/articles.ts createRevision; no stripping of undefined before hashing was found. Tests in packages/core/src/index.test.ts only use omitted optional fields, not explicit undefined.

🟠 Issue 2 — CI concurrency cancels in-progress pushes to main

.github/workflows/ci.yml:10 · risk · identified by meta/muse-spark-1.2

Pushing two commits to main close together aborts the earlier validate run due to cancel-in-progress: true.

.github/workflows/ci.yml uses group: ci-${{ github.workflow }}-${{ github.ref }} for all events, including push: branches: [main]. On refs/heads/main the second push cancels the first, so a broken commit can appear green because its required checks were cancelled rather than failed, and branch protection that requires the job may be satisfied by the later run only.

Inspected .github/workflows/ci.yml concurrency block and compared with .github/workflows/codeql.yml which uses the same pattern. No cancel-in-progress: false override for push was found.

🟠 Issue 3 — CodeQL concurrency cancels scheduled analyses

.github/workflows/codeql.yml:13 · risk · identified by meta/muse-spark-1.2

The weekly scheduled CodeQL scan can be cancelled by a concurrent PR or push.

.github/workflows/codeql.yml uses group: codeql-${{ github.workflow }}-${{ github.ref }} with cancel-in-progress: true for all triggers, including schedule: cron: "27 8 * * 1". github.ref for a schedule is the default branch, so a push at 08:27 UTC cancels the scheduled analyze job, creating gaps in security scanning and SARIF uploads.

Read .github/workflows/codeql.yml lines 1-16; no separate group for schedule was found. grep for codeql confirmed no docs inventory the workflow name.

🟠 Issue 4 — Draft applicability.buildId can make evidence permanently unsatisfiable

packages/core/src/articles.ts:88 · risk · identified by meta/muse-spark-1.2

Creating a draft with applicability.buildId = "staging-99" while the later ReviewContext.expectedStagingBuildId = "staging-42" makes every future recordEvidence fail.

verifyEvidence requires evidence.stagingBuildId === expectedStagingBuildId and, when revision.applicability.buildId is defined, also evidence.stagingBuildId === revision.applicability.buildId. createRevision in packages/core/src/articles.ts only checks createdAt >= collection.createdAt and never validates that an optional buildId aligns with any future staging expectation, so a draft can be created that can never collect the required content/workflow passing evidence and thus never pass submitForReview/publishArticle.

Checked packages/core/src/articles.ts createRevision and verifyEvidence binding checks; no early mismatch error is emitted. Tests in packages/core/src/index.test.ts always align the two values.

🟠 Issue 5 — retireArticle retains current evidence in the retired aggregate

packages/core/src/articles.ts:528 · risk · identified by meta/muse-spark-1.2

Retiring a published article leaves article.evidence populated in the returned value.

retireArticle does const {published: _published, ...rest} = withoutReview(structuredClone(article)) and returns {...rest, state: "retired"}. rest still contains current and evidence. The core README says retirement "removes the publication and pending review" but does not state evidence is retained; callers that expose the returned aggregate (e.g., logging) may leak private VerificationEvidence with steps, artifacts, and attestation that the contracts mark as staff-only and excluded from customer/bot DTOs.

Verified in packages/core/src/articles.ts lines 528-534 and contract comment /** Private verification material, excluded from later customer/bot DTOs. */ in packages/contracts/src/index.ts. Test "rejection and retirement clear authority" asserts not.toHaveProperty("published") but never asserts evidence is cleared.

🟠 Issue 6 — Collection preview hash is self-verified, not a capability

packages/core/src/collections.ts:170 · risk · identified by meta/muse-spark-1.2

An attacker can forge a valid CollectionPolicyPreview without calling previewCollectionPolicy.

applyCollectionPolicy checks preview.policyHash !== await digest(preview.policy) – the digest is recomputed from the supplied policy itself. Any caller can fabricate { version: current+1, portal/bot: any valid uses }, compute its SHA-256, and pass the check. The README/core docs claim previewCollectionPolicy binds proposed audiences to the exact current revision and applyCollectionPolicy rejects stale or changed previews, which overstates the guarantee: it only rejects mismatched hash/version, not unauthorized policy content.

Verified in packages/core/src/collections.ts applyCollectionPolicy lines 180-195 and previewCollectionPolicy lines 130-148. AGENTS.md correctly notes core is not an authorization boundary, but the preview narrative suggests otherwise.

🔵 Issue 7 — Duplicate workspace declaration (npm vs pnpm)

package.json:8 · nit · identified by meta/muse-spark-1.2

The repository declares workspaces in two places with the same glob.

Root package.json has "workspaces": ["packages/*"] (npm workspaces) and pnpm-workspace.yaml has packages: - "packages/*" with linkWorkspacePackages: true. npm and pnpm resolve workspace links differently; pnpm install --frozen-lockfile uses the YAML while npm pack (used by release-packages.mjs) reads package.json workspaces, risking divergent resolution of @​pegma/knowledge-base-contracts 0.1.0 during release:check vs consumer install.

Read package.json lines 8-10 and pnpm-workspace.yaml lines 1-4; no comment explains the duplication.

🔵 Issue 8 — Collection retains name revision without policy-version bump check

packages/core/src/collections.ts:165 · nit · identified by meta/muse-spark-1.2

Updating a collection's name is not a first-class transition but mutating collection.name before previewCollectionPolicy is undetected.

previewCollectionPolicy clones the source collection and builds a new policy with version: source.policy.version+1, but applyCollectionPolicy only checks preview.collectionId, expectedRevision, policy.version, and policyHash. It never verifies collection.name equality, so a compromised in-memory collection whose name was mutated between preview and apply will have that name persisted via ...source spread into next without bumping revision for the name change alone.

Inspected packages/core/src/collections.ts lines 122-210; createCollection sets name but no updateCollectionName exists, yet the spread allows silent name persistence.

🔵 Issue 9 — Unused import resolve in release script

scripts/release-packages.mjs:11 · nit · identified by meta/muse-spark-1.2

Running pnpm run release:check succeeds but scripts/release-packages.mjs imports resolve from node:path and never uses it.

The import on line 11 (import { basename, delimiter, dirname, join, resolve }) is dead code. It triggers lint unused-var warnings, bloats the maintainer script, and can hide a future resolve vs join path-traversal mistake because the wrong helper is already imported.

Verified by reading scripts/release-packages.mjs lines 1-11; resolve appears only in the import statement. Checked sibling scripts directory has no other consumer.

Workflow run

Comment thread packages/core/src/validation.ts Resolved
Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/codeql.yml Resolved
"Article revision has changed",
);
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Draft applicability.buildId can make evidence permanently unsatisfiable (risk)

Creating a draft with applicability.buildId = "staging-99" while the later ReviewContext.expectedStagingBuildId = "staging-42" makes every future recordEvidence fail.

verifyEvidence requires evidence.stagingBuildId === expectedStagingBuildId and, when revision.applicability.buildId is defined, also evidence.stagingBuildId === revision.applicability.buildId. createRevision in packages/core/src/articles.ts only checks createdAt >= collection.createdAt and never validates that an optional buildId aligns with any future staging expectation, so a draft can be created that can never collect the required content/workflow passing evidence and thus never pass submitForReview/publishArticle.

Checked packages/core/src/articles.ts createRevision and verifyEvidence binding checks; no early mismatch error is emitted. Tests in packages/core/src/index.test.ts always align the two values.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mismatch intentionally blocks publication until the selected build has matching verification. Drafts may describe a future build; the future ReviewContext is not known at draft creation and can later select that build. Alternatively reviseArticle creates a fresh applicable revision. It is not permanently unsatisfiable, and accepting evidence for a different build would weaken the exact-build requirement. The README now states this lifecycle.

Comment thread packages/core/src/articles.ts Resolved
Comment thread packages/core/src/collections.ts Resolved
Comment thread package.json Resolved
};
validateCollectionPolicy(policy);
return immutable({
collectionId: source.id,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Collection retains name revision without policy-version bump check (nit)

Updating a collection's name is not a first-class transition but mutating collection.name before previewCollectionPolicy is undetected.

previewCollectionPolicy clones the source collection and builds a new policy with version: source.policy.version+1, but applyCollectionPolicy only checks preview.collectionId, expectedRevision, policy.version, and policyHash. It never verifies collection.name equality, so a compromised in-memory collection whose name was mutated between preview and apply will have that name persisted via ...source spread into next without bumping revision for the name change alone.

Inspected packages/core/src/collections.ts lines 122-210; createCollection sets name but no updateCollectionName exists, yet the spread allows silent name persistence.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core consumes authoritative current state from the later application, not an aggregate supplied by an untrusted client. Returned collections are deeply frozen. A caller who fabricates/clones current state can also fabricate IDs/revisions; a pure transition cannot authenticate that input. KB-02 must load state and enforce optimistic writes. Names confer no authority, and applyCollectionPolicy does increment the returned revision. A separate rename use case is outside KB-01.

Comment thread scripts/release-packages.mjs Resolved

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenRouter pull-request review

Verdict: issues
Scope: latest-commit (commit-range)
Mode: verify
Commit: 69844be3eb45b1c0def878a191f5d2f57a47bb0a
Judge: openai/gpt-5.6-luna
Cost: $0.1904 (lanes $0.1902 + judge $0.0001)

Lanes

  • meta/muse-spark-1.2: ok (0 finding(s), 32.7s, 73130+4606 tokens (9555 cached), 3 tool round(s), via Meta, $0.10)
  • z-ai/glm-5.3-flash: ok (0 finding(s), 679.2s, 1096217+54817 tokens (700193 cached), 21 tool round(s), via OpenInference, $0.0898)

Round 2 resolution

  • ⚠️ r1-1 fixed incorrectly — Explicit undefined optional fields break canonical hashing: Partially fixed. validateApplicability (packages/core/src/validation.ts:122-128) now rejects an own-property buildId/locale of undefined, and on the draft paths it runs before hashing (createRevision calls validateRevisionFields before digest(fields); verifyRevision likewise), so createArticle/reviseArticle and revision rehydration now report the field — covered by the new `it.each…
  • ✅ r1-2 fixed correctly — CI concurrency cancels in-progress pushes to main: .github/workflows/ci.yml concurrency now group: ci-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }} with cancel-in-progress: ${{ github.event_name == 'pull_request' }}. Pushes to refs/heads/main no longer cancel each other; only PR runs cancel. Verified file lines 11-13.
  • ✅ r1-3 fixed correctly — CodeQL concurrency cancels scheduled analyses: .github/workflows/codeql.yml same fix: group includes event_name and cancel-in-progress only for pull_request. Scheduled schedule runs (ref = default branch, event_name=schedule) get distinct group and are not cancelled by pushes/PRs. Verified file lines 15-17.
  • 🤝 r1-4 disputed — Draft applicability.buildId can make evidence permanently unsatisfiable: The premise that the draft is permanently unsatisfiable overstates the design. expectedStagingBuildId is a per-operation ReviewContext input supplied by the trusted host (not a global constant), so a draft targeting staging-99 is verifiable whenever the host verifies against that build; alternatively reviseArticle replaces the draft and clears evidence. Requiring evidence.stagingBuildId to e…
  • ✅ r1-5 fixed correctly — retireArticle retains current evidence in the retired aggregate: retireArticle still returns staff aggregate with evidence retained (packages/core/src/articles.ts:488 via {...rest, state:"retired"}), but docs/test now make retention explicit: packages/core/README.md says retirement retains current private revision and evidence, not deletion, and packages/core/src/index.test.ts asserts expect(retired.evidence).toEqual(inReview.evidence) plus warnin…
  • ✅ r1-6 fixed correctly — Collection preview hash is self-verified, not a capability: applyCollectionPolicy still self-verifies policyHash === digest(policy) — no signature/capability added. Fix is documentation: CollectionPolicyPreview.policyHash comment, previewCollectionPolicy/applyCollectionPolicy docstrings, and packages/core/README.md now state hash is deterministic snapshot binding, not signature/capability/proof of preview call, and that application must load tr…
  • 3 nit finding(s) from earlier rounds retired (severity floor for follow-up rounds is risk).
  • Open findings after this round: 1 (1 bug-severity).

No structured findings from the successful lane(s).

Workflow run

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenRouter pull-request review

Verdict: issues
Scope: latest-commit (commit-range)
Mode: verify
Commit: f9542908a8cbd47910bcdfc7091a75380660e88d
Judge: openai/gpt-5.6-luna
Cost: $0.1000 (lanes $0.0991 + judge $0.0009)

Lanes

  • meta/muse-spark-1.2: ok (0 finding(s), 23.5s, 69527+3085 tokens (27332 cached), 3 tool round(s), via Meta, $0.0700)
  • z-ai/glm-5.3-flash: ok (1 finding(s), 116.8s, 502637+24344 tokens (445696 cached), 17 tool round(s), via DigitalOcean, $0.0292)

Round 3 resolution

  • ✅ r1-1 fixed correctly — Explicit undefined optional fields break canonical hashing: Explicit undefined now fails at the named field instead of hash. validation.ts:123-136 rejects Object.hasOwn buildId/locale === undefined with invalid('applicability.buildId/locale','Omit...'). articles.ts validates before any canonical/digest: verifyEvidence:236, recordEvidence:396, publishArticle:511-512 (both stored review and supplied binding), isPublicationBoundToCurrentPolicies:580. createAr…
  • Open findings after this round: 1 (0 bug-severity).

Findings

🟠 Issue 1 — publishArticle now throws a raw TypeError for a null review or null/undefined binding

packages/core/src/articles.ts:511 · risk · identified by z-ai/glm-5.3-flash

The new early applicability checks dereference caller-supplied parents before any structural guard, so two rejections that previously produced clean KnowledgeBaseErrors now escape as uncaught TypeErrors:

  • article.review === null while state === "in-review": the guard source.review === undefined does not catch null, and source.review.applicability throws TypeError: Cannot read properties of null. Previously this fell through to canonical(binding) !== canonical(source.review) (canonical(null) is the string "null") and failed with KnowledgeBaseError("conflict", "approval", ...).
  • request.binding of null or undefined (realistic for a JavaScript consumer of the compiled package, or a binding rebuilt from JSON.parsed storage): request.binding.applicability throws TypeError. Previously canonical(undefined) produced KnowledgeBaseError("invalid", "hash", ...).

packages/core/README.md documents "Domain failures are KnowledgeBaseError with code and field", and the codebase otherwise rejects malformed stored or caller-supplied state with named errors (every keys() call rejects null/non-objects, e.g. validateApplicability(undefined) cleanly yields invalid("applicability", ...)), so an escaping TypeError breaks the documented error contract. The operation still fails closed; only the error type/label regresses.

Proof gap I could not close: with exactOptionalPropertyTypes and the non-optional binding: ApprovalBinding, typed TS callers cannot produce these shapes, so the trigger is limited to JS consumers of the compiled package or untyped data (as any, JSON.parse results). I checked isPublicationBoundToCurrentPolicies and verifyEvidence: their null-parent dereferences (published.approval.binding, the pre-digest attestation handling) predate this diff, so only the two new publishArticle lines are newly introduced. A null guard or a keys() check on source.review/request.binding before the new lines restores the documented behavior.

Workflow run

Comment thread packages/core/src/articles.ts Resolved

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenRouter pull-request review

Verdict: issues
Scope: latest-commit (commit-range)
Mode: verify
Commit: b5fd5988f1b1d9fd4b3c80c4a1d66ae2679ec75f
Judge: openai/gpt-5.6-luna
Cost: $0.1056 (lanes $0.1043 + judge $0.0013)

Lanes

  • meta/muse-spark-1.2: ok (0 finding(s), 27.8s, 82157+3402 tokens (37188 cached), 4 tool round(s), via Meta, $0.0762)
  • z-ai/glm-5.3-flash: ok (1 finding(s), 112.8s, 266913+21933 tokens (188928 cached), 9 tool round(s), via PrimeIntellect, $0.0280)

Round 4 resolution

  • ✅ r3-1 fixed correctly — publishArticle now throws a raw TypeError for a null review or null/undefined binding: publishArticle now guards null/undefined/malformed review and binding before dereference. source.review === undefined throws invalid('review'), otherwise validateBindingApplicability calls keys() which rejects null/non-object/array with KnowledgeBaseError field 'review'/'binding', then checks required snapshot fields and validateApplicability. isPublicationBoundToCurrentPolicies similarly guards p…
  • Open findings after this round: 1 (0 bug-severity).

Findings

🟠 Issue 1 — isPublicationBoundToCurrentPolicies still escapes as a raw TypeError when published.revision is explicitly null

packages/core/src/articles.ts:627 · risk · identified by z-ai/glm-5.3-flash

The new published-snapshot guard set leaves exactly one malformed-parent shape unguarded. Given a loaded or hand-assembled article whose published is { revision: null, approval: <genuine approval> }, isPublicationBoundToCurrentPolicies rejects published: null, malformed approval, and malformed binding with named KnowledgeBaseErrors (as the new tests assert), but for revision: null it reaches await verifyRevision(published.revision) and dies with TypeError: Cannot destructure property 'contentHash' of 'null' instead of a domain error.

Mechanism: the guard sequence only checks key presence. keys(published, ["revision", "approval"], "published") passes because there are no extra keys, and Object.hasOwn({ revision: null }, "revision") returns true, so the null value slips past the completeness check; validateBindingApplicability(binding, "binding") never touches the revision. The crash happens at packages/core/src/validation.ts:352 (const { contentHash, ...fields } = revision), reached from packages/core/src/articles.ts:627.

For contrast, every sibling shape is covered:

  • published null/undefined/{}/[]/"invalid" — keys rejects null, non-objects, and arrays; undefined is caught earlier by the published === undefined short-circuit
  • published.approval null/undefined/{}/[]/"invalid" — same keys guard, plus the Object.hasOwn(…, "binding") check for {}
  • published.approval.binding null/undefined/{}/[]/"invalid" — validateBindingApplicability
  • published.revision: undefined — caught by the hasOwn check
  • published.revision: []/number/{} — destructures safely and then fails with typed errors in validateRevisionFields

Only revision: null falls through, and the new test loops exercise null/undefined/{}/[]/"invalid" for the other three parents but not for revision, so nothing pins this shape.

I tried to falsify it: core itself never produces this shape (publishArticle stores revision: source.current, a verified frozen object), PublishedArticle.revision is non-optional in the contracts, and structuredClone happily clones explicit nulls, so the shape reaches the dereference intact. TypeScript typing does not defend this boundary — the new tests themselves cast hostile inputs as unknown as Article, and packages/core/README.md promises "Domain failures are KnowledgeBaseError with code and field". So this is the same residual risk class r3-1 flagged, now isolated to one shape: the failure still fails closed, but as an uncaught TypeError rather than a typed domain error.

Repair: extend the guard to reject a null/non-object published.revision the same way the other parents are checked (e.g. a type check before verifyRevision, mirroring the keys/hasOwn pattern), and add revision to the malformed-shape test loop. Adjacent, unchanged code I checked and am not raising separately: expectedRevision still throws a raw TypeError for current: null, but that path predates this commit and was not touched by it.

Workflow run

Comment thread packages/core/src/articles.ts Resolved

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenRouter pull-request review

Verdict: clean
Scope: latest-commit (commit-range)
Mode: verify
Commit: b3fa7bb48f0fd235ec2627e56ed475f34f3dd0a6
Judge: openai/gpt-5.6-luna
Cost: $0.0679 (lanes $0.0678 + judge $0.0001)

Lanes

  • meta/muse-spark-1.2: ok (0 finding(s), 11.2s, 67170+1540 tokens (23620 cached), 3 tool round(s), via Meta, $0.0645)
  • z-ai/glm-5.3-flash: ok (0 finding(s), 21.6s, 51112+2415 tokens (39872 cached), 7 tool round(s), via Particle AI, $0.0033)

Round 5 resolution

  • ✅ r4-1 fixed correctly — isPublicationBoundToCurrentPolicies still escapes as a raw TypeError when published.revision is explicitly null: verifyRevision now guards null/non-object/array before destructuring and throws KnowledgeBaseError via invalid('articleRevision',...). isPublicationBoundToCurrentPolicies calls verifyRevision, so published.revision=null (and undefined/{}/[]/string) now yields a domain error instead of TypeError. New test guards malformed published revision parents covers the exact shape from the finding.
  • Open findings after this round: 0 (0 bug-severity).

No structured findings from the successful lane(s).

Workflow run

@FlyOverCoderKY
FlyOverCoderKY merged commit 2830be7 into main Nov 7, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants