Expose stable structured error codes - #38
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 41784d2ec7
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const normalized = normalizeSmartEditError(error); | ||
| if (normalized.code !== SmartEditErrorCode.StaleAnchor) throw normalized; | ||
| first = normalized.message; |
There was a problem hiding this comment.
Reject stale errors without parseable suggestions
When a PiClient throws the new structured SmartEditError with code === E_STALE_ANCHOR but a message that is not the legacy [E_STALE_ANCHOR] stale-suggestion payload, this catch path assigns the human message to first; parseStaleAnchorError(first) then reports stale: false, so replaceAnchoredWithRetry returns the error text as a successful edit result. This can silently swallow failures for custom adapters using the public structured error contract; if the stale payload cannot be parsed, the session should reject rather than treat it as success.
Useful? React with 👍 / 👎.
Summary
SmartEditErrorCodeandSmartEditErrorcontracts with redacted structured details[E_*]returns/throws, policy, filesystem, CLI/schema, and Pi mutation queue failuresValidation
npm ci --ignore-scriptsnpm run checknpm run buildnpm test(38 passed, 1 capability-based Windows permission skip)npm run coverage(98.44% lines, 100% functions, 90.91% branches)npm run benchmark(5.92 ms / 20,000 operations; 1000 ms budget)npm run verify:dependenciesnpm run verify:policynpm run verify:workflowsnpm run verify:release(27 package files)npm pack --dry-runnpm audit --omit=dev --audit-level=highnpm audit --audit-level=highgit diff --checkCloses #32