Repository navigation
KB-02: authorized knowledge application and bounded storage - #2
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. |
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: issues
Scope: full-pr (full-pr)
Mode: initial
Commit: e84b1216e79fbcd284b4bae08d70e9257e5d63f0
Judge: openai/gpt-5.6-luna
Cost: $0.4762 (lanes $0.4706 + judge $0.0056)
Lanes
meta/muse-spark-1.2: ok (8 finding(s), 57.4s, 385868+6521 tokens (146274 cached), 3 tool round(s), via Meta, $0.35)z-ai/glm-5.3-flash: ok (6 finding(s), 360.7s, 2329887+74829 tokens (1994880 cached), 22 tool round(s), via DigitalOcean, $0.12)
The diff is 386.7 KB against a 300 KB embed budget (max_diff_kb). Diff-budget triage embedded 250.2 KB; 1 file(s) kept only a stub — diff header, +/- counts, and a first-hunk reference, with no reviewable hunks:
pnpm-lock.yaml. Each stubbed file's current content is in the checkout for the read-only tools (deleted-line specifics exist only as counts), and each one still requires a full sweep and its own coverage entry. No changed file was dropped, so with the stub accounting this review still covers every changed file.
Findings
🔴 Issue 1 — Mismatched byte accounting between record codec and quota
packages/application/src/records.ts:115 · bug · identified by meta/muse-spark-1.2
Mutation can exceed the documented partition byte limit or be rejected incorrectly.
records.encodeKnowledgeRecord checks payload.length*2 > 900_000-4_096 (UTF-16 estimate) while repository.encodedBytes and quota arithmetic use TextEncoder.encode(canonicalJson(record)).length (UTF-8). For ASCII the UTF-16 check is 2× stricter; for non-BMP/ multi-byte UTF-8 the quota is larger than the encode gate. The documented limit in docs/COLLECTIONS.md is the TextEncoder UTF-8 length, so admission and the per-row native limit disagree on what counts as a byte.
Checked packages/application/src/records.ts:115,153 vs packages/application/src/repository.ts:149-150 and packages/application/src/storage-helpers.ts:154-155 and docs/COLLECTIONS.md physical-representation table.
🟠 Issue 2 — loadGovernanceContext does not re-validate validation-policy generation
packages/application/src/governance.ts:165 · risk · identified by meta/muse-spark-1.2
A concurrent validation-policy change can be returned as stale authoritative context.
loadGovernanceContext reads collection, validates its configuration, reads validation policy, then re-reads collection to fence governanceGeneration, but never re-reads the validation policy to confirm validationGeneration is still current. A caller that fetched governance between a putValidationPolicy and putGovernanceConfiguration race can get a ReviewContext whose validationPolicy is no longer the configured version, allowing createArticle/reviseArticle/recordEvidence/submitForReview to use the old policy until the next retry.
Checked packages/application/src/governance.ts:145-180 and its callers in articles.ts submitEvidence before/after fence and reads.ts:getValidationRequirements which does refetch both generations separately.
🟠 Issue 3 — Replay re-authorization uses stale snapshotted AccessContext
packages/application/src/articles.ts:285 · risk · identified by meta/muse-spark-1.2
A permission revocation between the original request and a retry/replay will not be enforced inside the storage retry loop.
articles.execute snapshots access once in commandSnapshot (caller = snapshotData(access)), stores request.access, and the recheck closure closes over that snapshot (requirePermission(request.access, permission)). repository.execute invokes recheck on every CAS attempt and again after finding a receipt, but always with the frozen snapshot. The host supplies a fresh AccessContext per call, but interior retries should re-resolve current authority; the current code can acknowledge a replayed command after the caller lost draftWrite/evidenceSubmit/etc.
Checked packages/application/src/articles.ts:76-89, 285-310 and packages/application/src/repository.ts:532-560.
🟠 Issue 4 — getPublishedArticle error masking omits RepositoryCapacityError
packages/application/src/reads.ts:462 · risk · identified by meta/muse-spark-1.2
A capacity/partition-limit condition surfaces as a raw error to callers instead of the uniform portal-not-found result, leaking internal limit details.
getPublishedArticle catches KnowledgeBaseError, KnowledgeBaseNotFoundError, KnowledgeBasePrerequisiteError, RepositoryConflictError, RepositoryIntegrityError and maps them to unavailable(), but RepositoryCapacityError (raised by getHead for stored_partition or by publishedEvidence quota checks) is not caught and bubbles directly. The documented contract says portal reads return the same unavailable result for absent and inaccessible content.
Checked packages/application/src/reads.ts:462-485 and packages/application/src/repository.ts:420-455 getHead capacity throw.
🔵 Issue 5 — Collection create replay bypasses existence check after deletion
packages/application/src/articles.ts:301 · nit · identified by meta/muse-spark-1.2
A deleted collection’s replay can still return success.
articles.execute recheck for non-control articles only verifies collection existence when current !== null. For createDraft (create=true, current===null) the recheck skips the collection check entirely, and repository.execute’s receipt path returns the historical pointer without ever invoking decide. If the collection was deleted between creation and a replay, the replay succeeds with a bounded acknowledgement while a fresh create would fail in loadGovernanceContext.
Checked packages/application/src/articles.ts:298-312 and packages/application/src/repository.ts:540-570.
🔵 Issue 6 — decodeKnowledgeRecord extra-field check conflates integrity and capacity
packages/application/src/records.ts:145 · nit · identified by meta/muse-spark-1.2
An oversized stored row is reported as integrity corruption rather than capacity, making operator diagnosis ambiguous.
encodeKnowledgeRecord throws RepositoryCapacityError('record_chunks'|'record_bytes') when parts.length > 15 or payload.length*2 too large, but decodeKnowledgeRecord throws RepositoryIntegrityError for partCount > 15 and for payload.length*2 > limit. A row that was admissible under UTF-8 quota but exceeds the UTF-16 decode gate will be treated as tampering rather than quota exhaustion, diverging from the documented admission metrics.
Checked packages/application/src/records.ts:119-165.
🔵 Issue 7 — Firestore/Azure native limit reservation double-counted
packages/application/src/repository.ts:930 · nit · identified by meta/muse-spark-1.2
Quota initialization slightly over-reserves on first write, shrinking usable capacity by one row’s bytes.
In repository.execute, priorQuota is {rows:0,bytes:0,…} for a new partition and baseBytes = priorQuota.bytes - 0 + sum(additions). The quota.rows already adds + (beforeRow===null?1:0) for the head, but baseBytes does not subtract the prior head (none) and then headRow bytes are added again in the convergence loop, counting the head twice in the convergence iteration. For large payloads near maxRetainedBytes - controlReserveBytes this can cause a spurious retained_bytes rejection one transaction early.
Checked packages/application/src/repository.ts:915-950.
🟠 Issue 8 — Stale head generation not validated against receipt result
packages/application/src/repository.ts:558 · risk · identified by meta/muse-spark-1.2
An old receipt can be returned as replayed even though its generation is behind the current head’s fork.
repository.execute receipt path checks receipt.result.generation > latest.value.generation and throws RepositoryConflictError only if the receipt is newer than current. If the current head has advanced on a different branch after the receipt’s generation (same commandId reused with same fingerprint but head moved), receipt.result.generation <= latest.generation passes and the old historical state is returned as if it were still the authoritative result, despite the head no longer pointing to that revision.
Checked packages/application/src/repository.ts:552-562 and final-retry receipt block 1000-1020.
🔵 Issue 9 — updateCollectionPolicy dereferences the untrusted preview payload before any shape validation
packages/application/src/governance.ts:298 · nit · identified by z-ai/glm-5.3-flash
A host that submits updateCollectionPolicy with a malformed nested preview — for example preview: {}, or a preview.policy missing portal/bot — gets an accidental TypeError: Cannot read properties of undefined (reading 'portal') instead of the controlled invalid-input errors ("Command contains unsupported fields"-style) this package produces for every other malformed field.
mutationInput validates only the top-level command fields; the nested preview is first dereferenced at anonymousUse(input.preview.policy) and again in the control: computation (!input.preview.policy.portal.enabled && !input.preview.policy.bot.enabled) before decide's canonical comparison could reject it. previewCollectionPolicy validates its nested uses with dataInput(input.uses, ["portal", "bot"]) before use, so this command is the outlier. docs/HOST_COMPOSITION.md tells hosts to map named "invalid-input" outcomes; a raw property-access TypeError is harder to map and can surface as an internal error.
Fix is to shape-validate input.preview (e.g. via dataInput on preview and its policy) before the first dereference. I checked packages/application/src/governance.ts in full and docs/HOST_COMPOSITION.md's error-mapping contract.
🟠 Issue 10 — Post-commit recheck can reject an already-committed mutation, leaving the outcome ambiguous
packages/application/src/repository.ts:1029 · risk · identified by z-ai/glm-5.3-flash
An actor whose effective permission is revoked between authorization and the storage commit receives an error from a command that actually committed: execute() runs records.transact successfully, then re-reads the head and calls recheck(latest) — if that recheck throws, the caller sees a failure even though the head change, immutable rows, Audit event, receipt, and causal jobs are durably committed. The host cannot distinguish this false failure from a clean refusal, so it may report "publish failed" while the article is in fact published; the committed state only becomes observable again when a later authorized retry of the same commandId replays with replayed: true.
Mechanism: after if (!outcome.committed) continue;, execute() runs const latest = await read<T>(...) followed by await recheck(latest?.value ?? null) before returning replayed: false. For non-control article commands recheck re-runs requirePermission(request.access, permission) plus a collection read, so a mid-call revocation is the realistic trigger; the mutation itself is already durable.
I checked the recheck bodies in packages/application/src/articles.ts (execute's recheck: permission, article existence, collection existence — collections are never deleted) and the post-loop receipt-recovery path; the ambiguity window is narrow but real, and the host has no committed-vs-refused signal for it.
🔵 Issue 11 — getPublishedArticle leak path: RepositoryCapacityError is missing from the unavailable-mapping catch list
packages/application/src/reads.ts:475 · nit · identified by z-ai/glm-5.3-flash
If an instance is constructed with limits smaller than data already in the partition (for example a host rollout that reduces maxPhysicalRows/maxRetainedBytes over an existing store), a portal customer calling getPublishedArticle receives RepositoryCapacityError ("Knowledge resource reached its configured stored_partition limit") instead of the uniform KnowledgeBaseNotFoundError("article") that every other failure in this method maps to — exposing an internal capacity detail to untrusted portal callers.
Mechanism: getHead throws RepositoryCapacityError("stored_partition") when the stored head's quota exceeds the instance limits. In getPublishedArticle this can surface both before the try (the initial requiredArticle) and inside it (loadGovernanceContext, the latest-collection re-read). The final catch whitelists KnowledgeBaseError, KnowledgeBaseNotFoundError, KnowledgeBasePrerequisiteError, RepositoryConflictError, and RepositoryIntegrityError, but not RepositoryCapacityError.
The trigger requires a limits/stored-data mismatch, so this is edge-case; the fix is to add RepositoryCapacityError to the catch's mapping (or map it at the same boundary). I verified the capacity throw sites in packages/application/src/repository.ts (getHead) and the full catch list in packages/application/src/reads.ts.
🔵 Issue 12 — Azurite global teardown kills the emulator without awaiting exit before deleting its workspace
test/azurite.ts:94 · nit · identified by z-ai/glm-5.3-flash
When the suite finishes, teardown() calls child?.kill() and immediately rm(absolute, { recursive: true, force: true }). kill() returns before the emulator process exits, so on platforms where Azurite still holds open handles in its data directory (notably Windows), the removal can fail with EBUSY/EPERM, failing vitest's global teardown and flaking an otherwise green run; the port 10212 listener can also briefly outlive teardown.
What I checked: test/azurite.ts teardown (lines ~92-99) has no await on process exit and no retry/backoff around rm; the failure path in setup removes the workspace only after child.kill() too, but there the process is known to have failed/exited, so the gap is specifically the success-path teardown. Consider awaiting an exit event (with a short grace timeout) before removing the workspace.
🔵 Issue 13 — Package README links internal docs and source via absolute main-branch GitHub URLs
packages/application/README.md:8 · nit · identified by z-ai/glm-5.3-flash
Readers of the future published @pegma/knowledge-base-application package follow links that always resolve to the tip of main, so a released README can describe a different layout than the released code — e.g. the docs/COLLECTIONS.md limits section or the packages/application/src/types.ts contract file it cites can change after publication. Sibling documentation for the same targets (docs/HOST_COMPOSITION.md links COLLECTIONS.md relatively; root README.md links package READMEs relatively) uses relative links, making this README the outlier.
Instances: the "declared layout" and "Host composition" links near the top (~lines 8-12), the "public types" link in Composition and commands, the "layout limits" anchor link in Storage and limits, and the "release operations" link near the bottom. No code impact; the cost is documentation drift for published-package consumers once the name is first published.
🔵 Issue 14 — No negative-authorization tests for the staff read services getCollection, getValidationPolicy, getGovernanceConfiguration, getReview
tests/application.test.ts · nit · identified by z-ai/glm-5.3-flash
A regression that drops the permission check from getCollection, getValidationPolicy, getGovernanceConfiguration, or getReview would not fail any test: both suites exercise denial paths for the write commands and for getDraft, getEvidence, getProvenance, getValidationRequirements, and getPublishedArticle, but no test ever calls those four staff reads with a caller lacking the required permission.
What I checked: I read tests/application.test.ts and tests/application-storage.test.ts in full — denials are pinned for createCollection (customer), getValidationRequirements (customer), the getDraft/getEvidence/getProvenance loop (customer), getEvidence (author), publishArticle (author without publish), publicCollectionApprove, and draftWrite (empty-permission context); the four reads above appear in the fixtures only as admin calls, so their requirePermission lines are currently unpinned. A one-line rejects.toMatchObject({ permission: ... }) case per read would close the gap.
| record.id.length > 300 || | ||
| /[^A-Za-z0-9|:._-]/u.test(record.id) | ||
| ) | ||
| throw new RepositoryIntegrityError(); |
There was a problem hiding this comment.
🔴 Mismatched byte accounting between record codec and quota (bug)
Mutation can exceed the documented partition byte limit or be rejected incorrectly.
records.encodeKnowledgeRecord checks payload.length*2 > 900_000-4_096 (UTF-16 estimate) while repository.encodedBytes and quota arithmetic use TextEncoder.encode(canonicalJson(record)).length (UTF-8). For ASCII the UTF-16 check is 2× stricter; for non-BMP/ multi-byte UTF-8 the quota is larger than the encode gate. The documented limit in docs/COLLECTIONS.md is the TextEncoder UTF-8 length, so admission and the per-row native limit disagree on what counts as a byte.
Checked packages/application/src/records.ts:115,153 vs packages/application/src/repository.ts:149-150 and packages/application/src/storage-helpers.ts:154-155 and docs/COLLECTIONS.md physical-representation table.
There was a problem hiding this comment.
These are two independent, documented admission bounds. The native entity/property budget measures UTF-16 strings (15 chunks of <=30,000 UTF-16 units, with a native-row reservation), while retained-partition and transaction estimates measure UTF-8 encoded canonical native records. Every planned encoded row is counted against the UTF-8 quota before transact, so passing the native gate cannot bypass that quota. docs/COLLECTIONS.md explicitly distinguishes these metrics and states that rows, properties, and transaction work have independent bounds. Replacing one with the other would weaken the adapter limit.
| references: readonly PrivateSourceReference[], | ||
| ): Promise<void> { | ||
| validateReferences(references); | ||
| if (references.length === 0) return; |
There was a problem hiding this comment.
🟠 Replay re-authorization uses stale snapshotted AccessContext (risk)
A permission revocation between the original request and a retry/replay will not be enforced inside the storage retry loop.
articles.execute snapshots access once in commandSnapshot (caller = snapshotData(access)), stores request.access, and the recheck closure closes over that snapshot (requirePermission(request.access, permission)). repository.execute invokes recheck on every CAS attempt and again after finding a receipt, but always with the frozen snapshot. The host supplies a fresh AccessContext per call, but interior retries should re-resolve current authority; the current code can acknowledge a replayed command after the caller lost draftWrite/evidenceSubmit/etc.
Checked packages/application/src/articles.ts:76-89, 285-310 and packages/application/src/repository.ts:532-560.
There was a problem hiding this comment.
This is the documented per-call trust boundary: the host authenticates and resolves current effective authority for every service call, including a later replay. The application snapshots that resolved context to prevent caller mutation during awaits; there is no authorization-resolver port inside KB. Retried CAS attempts recheck current KB resources against that same bounded context. An instantaneous external revocation fence would require a separate host credential/resolution contract, rather than rereading the mutable caller object. HOST_COMPOSITION.md makes the host freshness responsibility explicit; we are clarifying that wording.
| ) | ||
| throw new KnowledgeBasePrerequisiteError("source-access"); | ||
| } catch { | ||
| throw new KnowledgeBasePrerequisiteError("source-access"); |
There was a problem hiding this comment.
🔵 Collection create replay bypasses existence check after deletion (nit)
A deleted collection’s replay can still return success.
articles.execute recheck for non-control articles only verifies collection existence when current !== null. For createDraft (create=true, current===null) the recheck skips the collection check entirely, and repository.execute’s receipt path returns the historical pointer without ever invoking decide. If the collection was deleted between creation and a replay, the replay succeeds with a bounded acknowledgement while a fresh create would fail in loadGovernanceContext.
Checked packages/application/src/articles.ts:298-312 and packages/application/src/repository.ts:540-570.
There was a problem hiding this comment.
The create flag skips only requireArticle; it does not skip the collection check when current is non-null. Exact receipt replay loads the committed current article, runs recheck, and reads that article's current collection before returning. The fresh-state receipt path repeats this check. The public application also exposes no collection deletion command. Thus the claimed replay path with a null current article cannot return a successful receipt acknowledgement.
| const byteBudget = | ||
| limits.maxRetainedBytes - | ||
| (request.control ? 0 : limits.controlReserveBytes); | ||
| if (quota.rows > rowBudget) |
There was a problem hiding this comment.
🟠 Post-commit recheck can reject an already-committed mutation, leaving the outcome ambiguous (risk)
An actor whose effective permission is revoked between authorization and the storage commit receives an error from a command that actually committed: execute() runs records.transact successfully, then re-reads the head and calls recheck(latest) — if that recheck throws, the caller sees a failure even though the head change, immutable rows, Audit event, receipt, and causal jobs are durably committed. The host cannot distinguish this false failure from a clean refusal, so it may report "publish failed" while the article is in fact published; the committed state only becomes observable again when a later authorized retry of the same commandId replays with replayed: true.
Mechanism: after if (!outcome.committed) continue;, execute() runs const latest = await read<T>(...) followed by await recheck(latest?.value ?? null) before returning replayed: false. For non-control article commands recheck re-runs requirePermission(request.access, permission) plus a collection read, so a mid-call revocation is the realistic trigger; the mutation itself is already durable.
I checked the recheck bodies in packages/application/src/articles.ts (execute's recheck: permission, article existence, collection existence — collections are never deleted) and the post-loop receipt-recovery path; the ambiguity window is narrow but real, and the host has no committed-vs-refused signal for it.
There was a problem hiding this comment.
The claimed mid-call permission mutation does not apply: effective AccessContext is an immutable snapshot of authority freshly resolved by the host for this call. Postcommit resource checks deliberately do not promise a distributed authorization transaction. Storage/read failures after a durable commit can leave an ambiguous result, as with transport failure after commit; the same command ID and semantic payload, retried with freshly resolved authority, reconcile through the atomic receipt. We are documenting that recovery rule explicitly, while retaining current resource checks and content-free acknowledgements.
| implementation and repository gates determine KB-02 completion; neither this | ||
| package nor local tests establish a live host or production readiness. | ||
|
|
||
| The [declared layout](https://github.com/pegma-dev/knowledge-base/blob/main/docs/COLLECTIONS.md) records the agreement made |
There was a problem hiding this comment.
🔵 Package README links internal docs and source via absolute main-branch GitHub URLs (nit)
Readers of the future published @pegma/knowledge-base-application package follow links that always resolve to the tip of main, so a released README can describe a different layout than the released code — e.g. the docs/COLLECTIONS.md limits section or the packages/application/src/types.ts contract file it cites can change after publication. Sibling documentation for the same targets (docs/HOST_COMPOSITION.md links COLLECTIONS.md relatively; root README.md links package READMEs relatively) uses relative links, making this README the outlier.
Instances: the "declared layout" and "Host composition" links near the top (~lines 8-12), the "public types" link in Composition and commands, the "layout limits" anchor link in Storage and limits, and the "release operations" link near the bottom. No code impact; the cost is documentation drift for published-package consumers once the name is first published.
There was a problem hiding this comment.
These package names are still unpublished and the absolute GitHub links intentionally make repository documentation reachable from an npm README; relative links to files excluded from the tarball would break there. Added an explicit development-main notice and a KB-05 prerequisite to pin version documentation to verified release source before first publication. No release tag or version-frozen documentation exists yet, so we are retaining usable development links rather than inventing a release target.
|
Round-one follow-up is pushed in 6ed855b. Fixed findings 2, 4/11, 9, and 12; body-only finding 14 now has negative tests for all four staff reads on memory and real Azurite. All 140 tests plus format, type, and clean-consumer packaging checks pass locally. Findings 1/3/5/6/7/8/10 have code-specific explanations in their threads; the documented independent byte bounds, immutable host-resolved context, and historical replay contract remain intentional. Finding 13 has an explicit development-link notice and a KB-05 release-source pinning prerequisite; no unpublished release tag was invented. Current-head automated review and CI must complete before merge. |
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: clean
Scope: latest-commit (commit-range)
Mode: verify
Commit: 6ed855b130f2300914eb09e36f368c63eb5eb74f
Judge: openai/gpt-5.6-luna
Cost: $0.1587 (lanes $0.1585 + judge $0.0001)
Lanes
meta/muse-spark-1.2: ok (0 finding(s), 43.6s, 108720+4839 tokens (25713 cached), 3 tool round(s), via Meta, $0.13)z-ai/glm-5.3-flash: ok (0 finding(s), 527.4s, 686880+55437 tokens (545874 cached), 14 tool round(s), via OpenInference, $0.0304)
Round 2 resolution
- 🤝
r1-1disputed — Mismatched byte accounting between record codec and quota: No code change, but finding assumes single limit. Record codec intentionally enforces native UTF-16 budget (payload.length*2 <= 900_000-4_096, 15x30k chunk limit) while retained-partition/transaction quotas count UTF-8TextEncoder.encode(canonicalJson(nativeStoredRecord)).length. docs/COLLECTIONS.md#physical-representation-and-hard-bounds explicitly documents these as independent bounds: 'payl… - ✅
r1-2fixed correctly — loadGovernanceContext does not re-validate validation-policy generation: governance.ts loadGovernanceContext now re-reads both collection and validation policy:Promise.all([readCollectionVersioned, readValidationPolicyVersioned])and fencescurrentValidation.value.generation !== validation.value.generationthrowing RepositoryConflictError. New regressionrejects validation policy generation changed while governance was loadingexercises barrier between first val… - 🤝
r1-3disputed — Replay re-authorization uses stale snapshotted AccessContext: No code change to articles.ts execute. Design is intentional per updated docs/HOST_COMPOSITION.md: 'Each call snapshots its access context. Repeated permission checks use that immutable authority while reloading current KB resources; they do not poll the host's identity or policy system during an in-flight call. Resolve access anew for each call/replay.' KB has no authorization-resolver port; host… - ✅
r1-4fixed correctly — getPublishedArticle error masking omits RepositoryCapacityError: reads.ts getPublishedArticle now wrapsrequiredArticle+publication checks inside try and catchesRepositoryCapacityErrormapping to unavailable():error instanceof RepositoryCapacityErroradded to the catch that returnsKnowledgeBaseNotFoundError('article'). CoversgetHeadstored_partition and retained-history quota errors from both article and governance partitions. Regression `maps a s… - 🤝
r1-8disputed — Stale head generation not validated against receipt result: No code change to repository.ts execute receipt path. Returning historicalreceipt.resultwhenreceipt.result.generation <= latest.value.generationis intentional idempotency: receipt is bounded ack (id/generation/revision/hash) not current state, CAS is linear (no fork), replay requires exact actor/operation/fingerprint+commandId and fresh recheck. docs/HOST_COMPOSITION.md/MUTATION text: 'Ide… - 🤝
r1-10disputed — Post-commit recheck can reject an already-committed mutation, leaving the outcome ambiguous: No removal of post-commitawait recheck(latest?.value ?? null)afterrecords.transactin repository.ts. Behavior is documented as intentional ambiguous-commit pattern analogous to transport failure. docs/HOST_COMPOSITION.md now states: 'A storage or transport failure can leave the caller uncertain... Retry same command ID and exact semantic input, including original expectedGeneration, under f… - 8 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).
Summary
Implement KB-02's authorized authoring, evidence, review, publication, and private read services over the released Pegma Store, Authorization Core, and Audit packages. Exact review snapshots retain their own publication evidence and source references while new drafts evolve.
The declared layout uses normalized immutable history, keyed reads, application generations, and same-partition CAS for state, Audit, command receipts, and causal jobs. Explicit row/byte/history limits reserve retirement and revocation capacity. Identical command replay returns a bounded historical acknowledgement after current resource checks.
Compatibility and authority
Collection policy governs portal access; publication and private DTOs have separate permission boundaries. Host evidence verification and live source eligibility fail closed. Source-backed reads recheck both publication eligibility and currentness against the retained published snapshot. No private source material enters approved-content DTOs.
This adds the unpublished
@pegma/knowledge-base-application@0.1.0source package. Search, transport/client authentication, package publication, and live host integration remain their later tasks. No new identity system, provider, GitHub connection, or cross-partition transaction is introduced.Validation
pnpm run format:checkpnpm run checkpnpm test: 140 tests, including public-entry memory and real-Azurite conformancepnpm run release:check: all three packed packages import from a clean consumerIndependent reviews drove deterministic regressions for source-eligibility withdrawal and overlapping duplicate commands (including receipt arrival after a cached head read with a single allowed attempt). Final independent authority and storage re-reviews are clean.