Repository navigation
fix(apple): preserve Interface Builder read failures instead of invalid archives - #6074
XiaoBinGan wants to merge 4 commits into
Conversation
…id archives decode_interface_builder reported a selected document that could not be read, or whose identity changed before open, as a successful partial graph with archive coverage reason one_or_more_archives_invalid. The per-document catch only separated aborted signals and decode-budget exceptions, so every remaining reader failure was consumed as malformed content. Keep an ArtifactReaderFailure out of the malformed-content classification so the artifact boundary preserves its typed reason. Genuine decode failures, decode-budget omissions and cancellation reporting are unchanged. Adds a regression covering a changed inode and a real io refusal through the production reader, plus readable, malformed and restored controls.
[Medium impact] The PR appears safe to merge; no blocking issues remain. SummaryThe PR preserves typed Interface Builder read failures instead of labeling unread documents as invalid archives.
Reviews (2) · Last reviewed commit: "chore: integrate Interface Builder read-..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dc2eb7c08f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // established, so it is not evidence of malformed archive content: | ||
| // preserve its typed reason for the artifact boundary instead of | ||
| // reporting the document as invalid. | ||
| if (cause instanceof ArtifactReaderFailure) throw cause; |
There was a problem hiding this comment.
Retain earlier decoded documents with the read failure
When a bundle has a readable lexically earlier archive and a later archive whose open/read fails, documents already contains a completed decode here, but the unconditional rethrow carries no partialObservation; ArtifactProvider consequently returns only the ArtifactOperationError, discarding the earlier graph and its source hashes. Keep the typed reader failure but attach the accumulated analysis as partial evidence so one unreadable .nib does not erase already established facts.
AGENTS.md reference: AGENTS.md:L31-L31
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this in this PR — the report that scopes the fix explicitly excludes it. #6066 states: "A read or identity-validation failure should preserve its typed failure... It is sufficient to propagate the typed read failure; this report does not require a new partial-result schema."
Surfacing the already-decoded graph beside a typed read failure needs a new member of AnalysisPartialObservation (there is no Interface Builder variant today) plus a producer/consumer contract for it. That is a public contract change, and the report says it is not required. If you want it, I am glad to do it as a separate change with its own contract review rather than adding a schema member inside a misclassification fix.
The earlier-decoded documents are still built and passed to buildInterfaceBuilderAnalysis; they are discarded only at the throw boundary, exactly as the report accepted.
| // established, so it is not evidence of malformed archive content: | ||
| // preserve its typed reason for the artifact boundary instead of | ||
| // reporting the document as invalid. | ||
| if (cause instanceof ArtifactReaderFailure) throw cause; |
There was a problem hiding this comment.
Preserve the primary read failure through final cleanup
When an identity/read failure is accompanied by a descriptor close failure, this rethrow is followed by the outer finally's await reader.close(), and a rejection there replaces the original error under JavaScript finally semantics. The provider then sees only cleanup io instead of the original integrity/io reason, so compose the close outcome with the primary and retain retry ownership rather than allowing final cleanup to overwrite the reason this change is intended to preserve.
AGENTS.md reference: AGENTS.md:L23-L23
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 6119bc5. The finally now composes rather than replaces: the catch records the typed primary, the close attempt gets its own try, and on failure it becomes ArtifactReaderFailure.withCleanup(primary, cleanupObservation(closeCause, ...)) — the same pattern src/artifacts/inventory/scanReader.ts and src/artifacts/javascript/JavaScriptArtifactFiles.ts already use for owned-reader cleanup. The provider therefore still sees integrity/io with the close failure attached as cleanup ownership.
Covered by a new case, keeps the read failure when final cleanup also fails, asserting the reason and message survive and cleanup is set. Verified red → green: restoring the bare finally { await reader.close(); } makes it fail.
One remaining cleanup is unchanged and pre-existing: a close-only failure with no document failure was never surfaced as its own result, and this change does not alter that.
Codex Review SummaryThis 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. |
Addresses the two review findings on this change: - Final cleanup no longer replaces the typed primary: a close failure after a read/identity failure is composed as cleanup ownership through ArtifactReaderFailure.withCleanup, so the provider still sees integrity/io rather than cleanup io. - The unreadable-document control forwards the real reader instance instead of its prototype, so the continuation branch works for any document rather than relying on a single-document fixture.
CassieFox23
left a comment
There was a problem hiding this comment.
Thanks, XiaoBinGan, for the fix and the tests.
Main fixed the core of this in 78f8eca. It rethrows ArtifactReaderFailure in the same place, with a test. So this PR now conflicts with main.
The PR still adds the close-failure wrapping and its test. Main still does a plain reader.close(). Issue #6066 is still open.
Static read only. I ran nothing.
🤖 Written with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊
|
Closing as superseded — main now covers both parts of this change, with tests.
Verified rather than assumed: I applied this PR's five test cases to a clean Thanks for the review, @CassieFox23 — the body-template findings were valid and I have kept them in mind for the follow-up. |
Summary
decode_interface_builderreports a selected document that was never read as a successful partial graph. When a readable-format nib cannot be opened (EACCES), or the selected name is replaced by byte-identical content on a new inode, the tool exits 0 withdocuments: [],graph.truncated: trueand archive coverage reasonone_or_more_archives_invalid. The typed read outcome survives only as a human-readable limitation, so an automated caller cannot branch on unavailable access versus malformed content.Fixes #6066.
Problem and expected behavior
The per-document
catchinanalyzeInterfaceBuilderBundleonly separates an aborted caller signal andInterfaceBuilderDecodeBudgetExceeded; every remaining exception is pushed ontoinvalid, which the coverage projection turns intoone_or_more_archives_invalid. A read failure occurs before any decode, so calling those bytes "invalid archives" misstates what was established.Expected: preserve the typed reader outcome (
integrityfor a changed entry,iofor a refused open) for the artifact boundary, and keep describing only bytes that were actually read and rejected as invalid archives. Genuine decode failures, budget omissions and cancellation reporting stay as they are.Change and scope
The catch rethrows an
ArtifactReaderFailurebefore the decode-failure classification. The existing shared translation (ArtifactOperationFailure.ts) already maps a reader reason ontoArtifactOperationErrorwith matching recovery, so no new schema or consumer is needed. This mirrors the existing convention for other artifact producers, which rethrow reader failures rather than reinterpreting them.Intentionally not included: permission classification inside the shared directory reader, which is independently needed and cannot repair this catch by itself.
Contract and boundary impact
analyzeInterfaceBuilderBundleper-document classification; earliest stage is the artifact read boundary.ArtifactOperationErrorinstead of successful partial Evidence. No tool was added or renamed.Expected effects:
Evidence and regression coverage
src/artifacts/apple/InterfaceBuilderReadFailure.test.ts— four cases: a readable document control, a changed-inode document, a refused open, and a genuinely malformed document.documents: []andreason: one_or_more_archives_invalid.EACCES; the changed-entry case previously returned success plus a limitation naming the changed entry. Both now surface the typed failure.DirectoryArtifactReaderand the analysis entry point, not through an end-to-end MCP session. Natural incidence and other platforms were not measured. No repaired software or known-good revision is established.Evidence-bearing checks:
Validation performed
node node_modules/vitest/vitest.mjs run src/artifacts/apple/InterfaceBuilderReadFailure.test.ts src/artifacts/apple/InterfaceBuilderDecodeBudget.test.ts --maxWorkers=1— 19 passed (4 new, 15 existing).npx tsc --noEmit -p .— no errors.npx oxfmt --check <changed files>— formatted.npm run verify:module-boundaries— 2481 source files checked, no violations.node node_modules/vitest/vitest.mjs run src/artifacts/apple --maxWorkers=1— 6 pre-existing failures on macOS-only/symlink fixtures reproduce identically on the unmodified base revision; the new file adds 4 passing tests and changes none of them.Compatibility, safety, and release
Author readiness
Human owner: @XiaoBinGan
Before merge
type(scope): outcome.