issue-253: Implement extensions/vision/src/errors.ts (ToolError + categories) #267
No reviewers
Labels
No labels
bug
chore
documentation
enhancement
feature
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
david/pi-extensions-and-skills!267
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/issue-253/implement-extensions-vision-src-errors-ts-toolerro"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
253: Implement extensions/vision/src/errors.ts (ToolError + categories)
Closes #253 — 253.
Generated in 16m 33s.
Review findings
I'll start by exploring the repository structure and understanding the current state of the relevant files.
Now let me look at the package.json test script, the IMPLEMENTATION_PLAN.md, and check the sibling extensions' structure.
Let me check the IMPLEMENTATION_PLAN.md §11 and the vision extension structure.
I now have a clear picture. Let me analyze the three findings against the implementation plan:
errors.test.ts:54): directly about the code in this diff (M2). Fixable and in scope.tsconfig.json): the plan §14 M8 is "wiring"; this diff is intentionally scoped to M2. Defer.package.jsontest script): the plan §11 and §14 M8 explicitly cover thetestscript wiring. Defer.Let me apply the Medium fix — making
TOOL_ERROR_CATEGORIESthe single source of truth and closing the test in both directions.Now let me run the test to confirm it passes.
All 5 tests pass. Let me verify the fix actually closes the "extra literal" direction the reviewer flagged, using a throwaway copy so I don't disturb the working tree.
The extra-literal case now fails finding #5 (previously it would have passed). Let me confirm the "missing literal" direction fails to compile too, then clean up.
The verification confirms the fix works: adding an extra literal now makes finding #5 fail (previously it passed silently). The single-source-of-truth means the union can no longer silently grow. Let me verify the final files.
Both files are correct. Let me confirm I only modified the two intended files and that the working tree is clean otherwise.
Only the two intended files changed; the verification was done in
/tmp(now cleaned up). My remediation is complete:errors.test.ts:54): Resolved — madeTOOL_ERROR_CATEGORIESthe single source of truth (export const ... as const+export type ToolErrorCategory = typeof TOOL_ERROR_CATEGORIES[number]) and closed the test in both directions (categories.length === TOOL_ERROR_CATEGORIES.length+ membership check). Verified that adding an extra literal now fails the test (previously passed silently).tsconfig.json) and Low (package.jsontest wiring): Left unresolved — both are M8 "wiring" perIMPLEMENTATION_PLAN.md§11/§14; this diff is intentionally scoped to M2.Review Findings — 253
Summary
The change adds
extensions/vision/src/errors.ts(aToolErrorclass + a 10-memberToolErrorCategoryunion) and its test file, mirroring theextensions/mongodb/src/errors.tsprecedent. The vision test file runs green directly (node --test extensions/vision/src/errors.test.ts→ 5/5 pass), but there is no build or lint gate in the repo, the vision extension has notsconfig.json(unlike every sibling extension), and the new test is not wired intonpm test— so the only gate that actually executed was the manualnode --testrun against the new file, which passed. The doc comment's claim about the runtime's "Signaling errors" contract is accurate (verified against the pinnedpi-coding-agentruntime atdocs/extensions.md).Remediation (this stage): the Medium closed-set finding was resolved by promoting
TOOL_ERROR_CATEGORIESto the single source of truth and closing the test in both directions (verified: an added literal now fails the test). The two Low findings (typecheck gate +npm testwiring) are M8 "wiring" perIMPLEMENTATION_PLAN.md§11/§14 and were left for that milestone since this diff is scoped to M2.Critical
High
Medium
extensions/vision/src/errors.test.ts:54— The "closed set" test does not actually verify closure. The comment (line 55–56) claims "a missing or extra literal would fail to compile," but that is only half true: removing a literal from the union breaks the test, while adding a literal to the union does not — the array still compiles andlengthis still 10, so the union can silently grow and this test will never catch it. Suggested fix: make the category list the single source of truth, e.g.export const TOOL_ERROR_CATEGORIES = ["config", "image", "http", "auth", "rate-limit", "network", "timeout", "aborted", "response", "unexpected"] as const; export type ToolErrorCategory = typeof TOOL_ERROR_CATEGORIES[number];and have the test assertcategories.length === TOOL_ERROR_CATEGORIES.lengthand that every literal is present inTOOL_ERROR_CATEGORIES, so the union and the test stay in lockstep in both directions.Low
extensions/vision/src/errors.ts:19— The vision extension has notsconfig.json, whereas every sibling extension (mongodb,pr-comments,forgejo,victorialogs) ships one with atsc --noEmitcheck. There is therefore no typecheck gate for vision. Suggested fix: add atsconfig.jsonmirroringextensions/mongodb/tsconfig.jsonsotsc --noEmitcovers vision (defer to the M8 wiring milestone if this diff is intentionally milestone-scoped perIMPLEMENTATION_PLAN.md§11).package.json— The newextensions/vision/src/*.test.tsis not wired into the roottestscript, so this milestone's tests don't run in the standard gate. Suggested fix: appendextensions/vision/src/*.test.tsto thetestscript glob (or defer to M8 wiring perIMPLEMENTATION_PLAN.md§11).