Repository navigation
fix(store): name an unreadable record instead of calling the package invalid - #254
Conversation
Review —
|
| Scenario | Result at 6702581 |
|---|---|
| Unverified package, record replaced by a directory | get → io_error: could not read <record>: EISDIR; list → 0 packages, one corrupt entry whose problem is that message |
| Verified package, record replaced by a directory | get succeeds; list returns the package — a strict package does not need the record, and the change does not make it need one |
Unverified package, record contents malformed ({ not json) |
invalid_package, as documented and unchanged |
| Unverified package, record unreadable and a file tampered | invalid_package — a real package fact is not masked by the record |
- The mapping is the narrow one it claims to be.
recordFailureOffires only forunreadable+invalid_package+ details that are all licence/provenance, so a digest mismatch, a missing README or an oversized file still reports as before.isTrustLocationis shared withonlyTrustProblems, so the import path and the read path cannot drift apart on what "trust" means. - Absence still fails closed. An unverified package whose record was deleted is refused, and the new case pins that.
- Gates at this head:
TemplateStore.test.ts20 passed;tsc --noEmit,oxfmt --check,lint,verify:test-discoveryclean. CI: every applicable check passes (the two skipped jobs are the libuvcpp/MSVC lanes selected off for this change).
Non-blocking (my judgement)
trustOnlyDetailsrebuilds a structured fact from rendered strings.problemsOfwrites${location}: ${message}and this function splits it back apart. It works today because locations are dotted paths without spaces, but a change toproblemsOf(or a location containing": ") would silently stop the mapping and quietly restore the oldinvalid_packageanswer. Carrying the structuredproblemsthrough torecordFailureOfwould make the coupling explicit.- The listing drops the package's own trust problems when it substitutes the record message. The
corruptentry now says only "could not read the record"; a caller can no longer see "license: is required" alongside it. That the package problems are conditional on the record is a reasonable argument for the current shape — just worth deciding deliberately rather than by consequence. - The malformed-record case is still read as absent — flagged as an open scope question in the body and on [Bug] An unreadable store metadata record is reported as an invalid template package #253, not claimed as fixed. I agree it is a separate decision; a record that parses but names the wrong id or schema is closer to corruption than absence, but nothing here depends on which way that goes.
I am marking this ready and approving it for the owner under today's standing authorization.
|
Owner approval. Approved at Reviewed in this comment. No blocking findings: the reader now distinguishes read/absent/unreadable, and the record name is substituted only when the package's sole problems are licence/provenance — a real package problem or a still-usable strict package is unaffected. I reproduced the changed behaviour independently with At this head: Merging as a merge commit at the exact reviewed head. Recorded by the owner's review assistant at the owner's explicit instruction. |
Summary
Fixes #253.
readStoreMetadatacaught every failure and returned "no record", so a store record that existed but could not be read (EACCES,EISDIR,EIO) was treated as absent. For a package imported withallowUnverified, that flipped the Q6 flag back to false and the store reported the package as invalid — a claim about manifest bytes that were never judged.The reader now answers three ways —
read,absent,unreadable. Absence stays an observation the callers act on (a strict package needs none; an unverified package without one fails closed). An unreadable record only changes the answer when the package's own validation failed solely on licence/provenance, which is the case the record decides; there the store reportsio_errornaming the record. Any genuine package problem (a digest mismatch, an oversized file) is reported as before.Problem and expected behavior
Observed on
mainatffa8350(Linux, uid 1000):allowUnverified: trueand nolicense/provenance.chmod 000 <root>/.meta/acme-dashboard/1.2.0.json.getTemplatePackage→invalid_package— "the package does not match uvp.template/1";listTemplatePackages→ 0 packages,corruptproblemslicense: is required,provenance: is required.The underlying failure is
EACCES: permission denied, open '<root>/.meta/acme-dashboard/1.2.0.json'. The package bytes were never the problem. Expected: name the record that could not be read, per the third-state rule inAGENTS.md; do not convert "could not look" into "the package is a no".Change and scope
readStoreMetadatareturnsread | absent | unreadableinstead ofStoreMetadata | undefined; onlyENOENTmaps toabsent.recordFailureOfmaps anunreadablerecord toio_erroronly when every validation problem is a licence/provenance location;isTrustLocationis extracted fromonlyTrustProblemsso the import path and this decision share one rule.getTemplatePackageandlistTemplatePackagesuse the record state; the listing records the message in that entry'scorrupt.problemsinstead of failing the whole store.invalid_package; an unverified package whose record was deleted is still refused.Contract and boundary impact
application(src/application/TemplateStore.ts).docs/public/tool-catalog.jsonwas regenerated: none.io_error(naming the path) fromgetTemplatePackageand acorruptentry with that reason fromlistTemplatePackages, where the package was previously called invalid.not_found,invalid_package,template_exists,store_lockedare unchanged.Expected effects:
Evidence and regression coverage
src/application/TemplateStore.test.ts(17 → 20 in that file).ffa8350— the first case reportsinvalid_packageand the two trust problems, as quoted above. The same case passes at6702581.getTemplatePackage→ 1 failed; (B) drop the trust-only gate → 1 failed; (C) treatENOENTasunreadable→ 1 failed; (D) ignore the record state in the listing → 1 failed. The pristine copy was restored and re-ran 20 passed.npm run test:local -- src/application/TemplateStore.test.tsgetuid?.() === 0covers root on POSIX.EIOis handled by the same branch but onlyEACCES/EISDIRwere exercised.For evidence-bearing changes:
unknown, notcomplete.undetermined, not a fabricated yes or no.Validation performed
All commands ran in
/tmp/wt-localeat6702581, on Linux.npm run test:local -- src/application/TemplateStore.test.ts— 20 passed (red before the change: 1 failed, 16 passed; the other two cases were added by this PR).npx tsc --noEmit— exit 0.npm run check:prwithLIBUVCPP_ROOT=/home/zwy/下载/libuvcpp-1.7.0-linux-x64,PKG_CONFIG_PATH=$LIBUVCPP_ROOT/lib/pkgconfig,LD_LIBRARY_PATH=$LIBUVCPP_ROOT/lib— exit 0; 78 files passed, 2 skipped; 1452 passed, 14 skipped (1466). The 14 skips are the same named lanes (native-probe build cache absent, opt-in published-package lane, Windows-only locators); none is claimed as covered.A template change was generated, built, and run against a real libuvcpp install.
Not applicable (no template or libuvcpp-facing change).
Compatibility, safety, and release
io_errorwhere the validation error was reported; no on-disk format change. The malformed-content reading is unchanged.Author readiness
Human owner: @Antruly
Before merge
type(scope): outcome.Fixes #253)