Repository navigation
[SD-03] Add atomic draft and private-source authoring - #9
Conversation
|
OpenRouter review posted ( |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex security review |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: issues
Scope: full-pr (full-pr)
Mode: initial
Commit: 54073e4db13a1cd5c13696f79b4616ee4c89fc76
Judge: openai/gpt-5.6-luna
Cost: $0.3250 (lanes $0.3227 + judge $0.0023)
Lanes
meta/muse-spark-1.2: ok (3 finding(s), 63.7s, 239489+5669 tokens (63812 cached), 4 tool round(s), via Meta, $0.25)z-ai/glm-5.3-flash: ok (4 finding(s), 339.8s, 1670262+44971 tokens (1465984 cached), 22 tool round(s), via Wafer, $0.0694)
Findings
🟠 Issue 1 — Source-set fingerprint is order-sensitive
packages/application/src/articles.ts:349 · risk · identified by meta/muse-spark-1.2
Failure scenario: two privileged host calls supply the same logical nonempty set of sourceReferences in different orders (e.g., [A,B] vs [B,A]). Because packages/application/src/articles.ts includes sourceReferences verbatim in the command fingerprint payload, the repository treats them as different semantic commands.
Evidence: execute() builds payload from Object.entries(request.input) without sorting/normalizing sourceReferences, then fingerprint(payload). validateReferences() only checks id uniqueness, not canonical order, and sourceSnapshot() preserves input order. Retry/replay therefore diverges instead of coalescing.
Impact is duplicate provenance/revision/audit/job rows, extra generation churn, and non-idempotent replay for the same ticket set. Documentation says the host must supply the "complete" set but does not state order is part of identity.
Checked current callers/tests: tests/atomic-draft-sources.test.ts always uses [firstSource, secondSource] in fixed order; no test asserts order-insensitivity. No normalization in sourceSnapshot or validateReferences.
🔵 Issue 2 — Restricted Omit type for recheck helper masks divergence
packages/application/src/articles.ts:308 · nit · identified by meta/muse-spark-1.2
Failure scenario: a future change adds a field to UpdateDraftInput that CreateDraftInput does not have (or vice-versa). recheckDraftSources(command: Pick<CreateDraftInput, "articleId" | "sourceReferences">) will still type-check for the updateDraft call site while silently dropping any new field from type checking.
Evidence: both createDraft and updateDraft pass recheckDraftSources as recheckCommand with T bound to their respective input types, but the helper is explicitly typed to CreateDraftInput only. The implementation only reads articleId and sourceReferences, so today it is compatible, but the narrowing hides divergence.
Fix is to type it as Pick<CreateDraftInput | UpdateDraftInput, "articleId" | "sourceReferences"> or generic Pick<T, ...>.
Checked callers: createDraft at line ~393 and updateDraft at ~431 both supply the same helper; packages/application/src/types.ts defines the two inputs separately.
🔵 Issue 3 — URL check rejects only :// substring
packages/application/src/articles.ts:197 · nit · identified by meta/muse-spark-1.2
Failure scenario: a caller supplies an opaque identifier that looks like a URL but avoids the :// substring, e.g., https:/evil or data:text/plain,secret, or a protocol-relative //host/path. validateReferences() uses value.includes("://") after boundedText, so such values pass and are stored as PrivateSourceReference fields.
Evidence: packages/application/src/articles.ts validateReferences() loop at line ~200 checks if (value.includes("://")) throw. Tests in tests/atomic-draft-sources.test.ts only assert rejection for https://fictional.invalid/private and do not cover other URL shapes. The doc contract says references must be "opaque identifiers" with no URL/source body.
Risk is persistence of URL-like identifiers that downstream hosts might later interpret as fetchable URLs, widening SSRF/phishing surface despite canRead gating.
No counterevidence found in current validators; requireIdentifier does not forbid : or / beyond boundedText.
🔵 Issue 4 — Explicit sourceReferences: undefined input throws TypeError instead of the documented legacy omission behavior
packages/application/src/types.ts:275 · nit · identified by z-ai/glm-5.3-flash
A plain-JavaScript host (or any caller that builds inputs by spreading, e.g. createDraft(ctx, { ...base, sourceReferences: maybeSources }) where maybeSources is undefined) gets TypeError: Expected bounded JSON data properties from commandSnapshot's canonicalJson(input) instead of the legacy draft-only behavior that the PR text, packages/application/README.md, and docs/COLLECTIONS.md all promise for "omission".
🔵 Issue 5 — Non-array sourceReferences is misclassified as RepositoryCapacityError("source_references") rather than a type error
packages/application/src/articles.ts:173 · nit · identified by z-ai/glm-5.3-flash
A host that sends sourceReferences: null, a string, or a plain object instead of an array receives RepositoryCapacityError("source_references") — the error class that signals a resource-limit condition — rather than a TypeError for malformed input.
🔵 Issue 6 — Docs list recheck points but omit the post-commit source recheck that can reject an already-committed command
docs/COLLECTIONS.md:172 · nit · identified by z-ai/glm-5.3-flash
A host integrator reading docs/COLLECTIONS.md, docs/HOST_COMPOSITION.md, or packages/application/README.md is told the per-reference canRead checks run "on the initial attempt, CAS retry, and exact replay" — but not that the repository also re-runs recheck after a successful commit (packages/application/src/repository.ts calls recheck(latest) after records.transact commits).
🔵 Issue 7 — Re-supplying an unchanged source set on every SD-03 update churns provenance generations, hashes, and immutable rows
packages/application/src/articles.ts:445 · nit · identified by z-ai/glm-5.3-flash
An SD-03-compliant host is instructed to "always supply the complete nonempty set" on each createDraft/updateDraft. When the source set is unchanged between updates, updateDraft still computes stored.provenance.generation + 1 and writes a new immutable provenance:<n> row — there is no short-circuit when the supplied set equals the current snapshot.
| readonly collectionId: string; | ||
| readonly draft: ArticleDraft; | ||
| /** Supplied references are committed with content and require provenanceWrite. */ | ||
| readonly sourceReferences?: readonly PrivateSourceReference[]; |
There was a problem hiding this comment.
🔵 Explicit sourceReferences: undefined input throws TypeError instead of the documented legacy omission behavior (nit)
A plain-JavaScript host (or any caller that builds inputs by spreading, e.g. createDraft(ctx, { ...base, sourceReferences: maybeSources }) where maybeSources is undefined) gets TypeError: Expected bounded JSON data properties from commandSnapshot's canonicalJson(input) instead of the legacy draft-only behavior that the PR text, packages/application/README.md, and docs/COLLECTIONS.md all promise for "omission".
There was a problem hiding this comment.
r1-4: Omission means the property is absent from the command object. Explicit undefined is not JSON data and is deliberately rejected by the shared canonical command-snapshot boundary, as with other command fields. We will preserve that boundary rather than silently discard one field before fingerprinting. JavaScript callers should omit it, for example with a conditional spread. We are making this explicit in the API docs and adding a no-mutation regression; this is documentation clarification, not a change to the runtime omission contract.
| context: { ...governance.context, actorId: caller.principalId }, | ||
| }); | ||
| return { next: { ...withoutPendingReview(stored), article } }; | ||
| const provenance = |
There was a problem hiding this comment.
🔵 Re-supplying an unchanged source set on every SD-03 update churns provenance generations, hashes, and immutable rows (nit)
An SD-03-compliant host is instructed to "always supply the complete nonempty set" on each createDraft/updateDraft. When the source set is unchanged between updates, updateDraft still computes stored.provenance.generation + 1 and writes a new immutable provenance:<n> row — there is no short-circuit when the supplied set equals the current snapshot.
There was a problem hiding this comment.
r1-7: This is intentional and matches setProvenance: explicitly supplying references records a fresh current source snapshot for a NEW accepted mutation, even when its values are unchanged. An exact command replay appends no snapshot/history/Audit/jobs; omission preserves current provenance. The caller's expected application generation fences new commands, and normal history/row/byte admission bounds retained work. Local-agent edits omit this privileged field. SD-03 delivery will persist and retry one exact prepared operation, so duplicate worker delivery does not repeatedly advance generations. We will clarify the explicit-snapshot contract and test replay/omission behavior; semantic source deduplication is a separate optimization, not required for atomic or idempotent delivery.
|
Body-only r1-1 triage: The actionable input-hygiene/error-classification and postcommit-recheck documentation findings are being fixed on this same branch. |
|
Body-only fixes in 639da5e:
Final compatibility review caught and fixed reuse of the stronger write rule during historical snapshot verification. Historical snapshots retain the original structural rules and exact hash checks; source currentness/publication gates remain mandatory. An exact dev-only alias to the published 0.1.1 application writes real legacy data for upgrade tests. The candidate then reviews/publishes that data, rejects withdrawn eligibility, and rejects those URL-like forms in new writes. No historic rows or old implementation are synthesized/copied. All 12 changed cases passed on real memory/Azurite/D1; types, formatting, four-package clean pack/import, and authenticated SDK proof passed. New-head CI must run the full 439 runtime and 128 release cases. Intentional exact-order, absent-property, and explicit-snapshot semantics retain their earlier written justifications. |
|
@codex security review |
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: clean
Scope: latest-commit (commit-range)
Mode: verify
Commit: 639da5edec3fcae50911c40bac55b4764b0b330c
Judge: openai/gpt-5.6-luna
Cost: $0.1357 (lanes $0.1356 + judge $0.0001)
Lanes
meta/muse-spark-1.2: ok (0 finding(s), 33.8s, 70640+3113 tokens (339 cached), 2 tool round(s), via Meta, $0.10)z-ai/glm-5.3-flash: ok (0 finding(s), 177.7s, 365774+31294 tokens (300864 cached), 9 tool round(s), via Together, $0.0344)
Round 2 resolution
- 🤝
r1-1disputed — Source-set fingerprint is order-sensitive: Agent rebuttal is justified and is now codified:sourceReferencesis defined as an exact ordered array participating in both command fingerprint and source-snapshot hash. Current code inpackages/application/src/articles.tsfingerprints the verbatim payload (no sorting) andsourceSnapshothashes ordered references;verifySourceSnapshotuses historical lexical rules. Docs updated in `docs/C… - 6 nit finding(s) from earlier rounds retired (severity floor for follow-up rounds is
risk). - Open findings after this round: 0 (0 bug-severity).
No structured findings from the successful lane(s).
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
Final gate record for 639da5e:
Source merge only. Protected signed-tag publication and complete registry/signature/provenance verification remain required before consuming the new API. Host/client/privacy/pilot gates remain open. |
A resolved-ticket learning worker must save derived draft content with its intended private sources. Separate draft and provenance commands leave an interruption window where new text can retain empty or stale source bindings.
Adds optional
sourceReferencesto direct applicationcreateDraftandupdateDraft. Supplied references require draft-write and provenance-write authority, bounded validation, and per-reference source access on retries, receipt replay, and postcommit checks. Content and current provenance commit in one existing article transaction. Omitted fields preserve legacy behavior; older publication provenance stays separate. Exact array order participates in command identity, and unknown outcomes retry the original prepared input.New writes reject malformed/reference URL forms, while historical snapshots retain their original structural and hash verification rules plus current source eligibility gates. Upgrade tests use an exact dev-only registry 0.1.1 application alias to write real old data. The five-operation agent interface keeps its current consent/scopes, omits the new privileged field from public input types, and rejects it through dispatcher, HTTP, and SDK MCP schemas before mutation.
Prepares synchronized candidate
0.1.2and reconciles verified0.1.1publication receipts. Four candidate runtime packages remain exact0.1.2; Agent Access protocol proof remains exact registry0.1.1. Reviewed merge, signed-tag publication, and strict released-consumer verification precede SD-03 consumption. Actual host/client/privacy/pilot acceptance stays open.Validation:
connect EADDRINUSE, then passed on all three backends in isolation.