Bring mcp/cas to 100% line/branch/function coverage: 85.71% → 100% branch - #1583
Conversation
85.71% branch coverage (5 uncovered branches), the lowest of the remaining modules: - Two were provably unreachable defensive guards: cas_get's content:true path re-derives type/mimeType via the dialect-aware detector, then checks fromVec/base64Encode for null before encoding the payload. media/type's own finish() only ever classifies a blob as 'text' when its bit length is byte-aligned (the same condition fromVec checks), and every byte ever written through cas_add/the CAS store is whole chunks, so base64Encode's only failure mode (non-byte-aligned input) can't occur either. Replaced both with assertNotNullish, mirroring the identical assertNotNullish media/module.f.mjs's own detect() already uses for the same invariant. - The other three (a writeBytes failure during cas_add, and cas_get's hash-vanished-between-reads races on both the metadata-refine and content-fetch paths) are real only under an actual race or failing disk, so proof.f.mjs (new file) reaches them the same way fjs/cas/proof.f.mjs does: a synthetic effect driver that succeeds by default except for the one call under test. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BmWCv5YGRXToq26xPoSXjX
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BmWCv5YGRXToq26xPoSXjX
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
functionalscript | 54749c3 | Commit Preview URL Branch Preview URL |
Aug 15 2026, 07:39 AM |
o2alexanderfedin
left a comment
There was a problem hiding this comment.
Checked both guard removals independently rather than taking the comments' word for it — the unreachability arguments hold.
fromVec (module.f.mjs:280): the guard sits behind refined.type === 'text', and the dialect layer in fjs/media only ever rewrites mime_type, so type can only come from detectVec. finish emits 'text' only under utf8Text(s.utf8) && (s.length & 0b111n) === 0n, and push short-circuits only once the verdict is already base64 — so a 'text' verdict implies a complete byte fold, which is exactly what fromVec re-checks with the same decoder. No dialect branch or other caller reaches the encode path with an unclassified blob.
base64Encode (module.f.mjs:289): value is only ever collectRead(c.read(key)), built from Buffer chunks in the Node handler, so bit length is always a multiple of 8 and encode's sole null condition (len % 8n !== 0n) can't fire. cas_add likewise only stores byte-aligned Vecs.
Measured, not assumed: npx tsc clean, fjs test 2800/2800, and a scoped coverage run over fjs/mcp/cas/module.f.mjs reports 100.00 line / 100.00 branch / 100.00 funcs — matching the claim. New proof.f.mjs follows the co-located convention and reuses the drive technique from fjs/cas/proof.f.mjs.
Summary
fjs/mcp/cas/module.f.mjswas at 85.71% branch coverage (5 uncovered branches, noproof.f.mjsexisted yet). This brings it to 100% line/branch/function coverage:cas_get'scontent: truepath re-derivestype/mimeTypevia the dialect-aware detector, then checkedfromVec/base64Encodefornullbefore encoding the payload.media/type's ownfinish()only ever classifies a blob as'text'when its bit length is byte-aligned — the same conditionfromVecchecks — and every byte ever written throughcas_add/the CAS store is whole chunks, sobase64Encode's only failure mode (non-byte-aligned input) can't occur either. Both null-checks are replaced withassertNotNullish, mirroring the identical patternmedia/module.f.mjs's owndetect()already uses for the same invariant (down to the comment).proof.f.mjs: awriteBytesfailure duringcas_add, andcas_get's "hash vanished between reads" race on both the metadata-refine path (falls back to the streaming verdict) and the content-fetch path (returns an error — no fallback once inline content was promised). Each is real only under an actual race (a failing disk, a concurrent writer, a GC sweep) between two of the tool's own steps.proof.f.mjsreaches them the same wayfjs/cas/proof.f.mjsdoes (from PR Bring cas (top-level) to 100% line/branch/function coverage: 96.59% → 100% branch #1576): a synthetic effect driver that succeeds by default except for the one call under test.Test plan
npx tsc --noEmitnode --test --experimental-test-coverage --test-coverage-include='fjs/mcp/cas/module.f.mjs' fjs/emergent_testing/all.test.mjs→ 100.00% line/branch/funcnode ./fjs/module.mjs t→ 2800 pass, 0 fail🤖 Generated with Claude Code
Generated by Claude Code