Skip to content

Expose stable structured error codes - #38

Merged
cervantesh merged 1 commit into
mainfrom
issue-32-structured-error-codes
Jul 16, 2026
Merged

Expose stable structured error codes#38
cervantesh merged 1 commit into
mainfrom
issue-32-structured-error-codes

Conversation

@cervantesh

Copy link
Copy Markdown
Contributor

Summary

  • export stable SmartEditErrorCode and SmartEditError contracts with redacted structured details
  • centralize normalization for core [E_*] returns/throws, policy, filesystem, CLI/schema, and Pi mutation queue failures
  • preserve readable diagnostics and the existing single stale-anchor retry while making library failures reject and CLI failures deterministic
  • document the public taxonomy, redaction decision, and compatibility migration from resolved error strings
  • add cross-surface parity and failure nonmutation coverage

Validation

  • npm ci --ignore-scripts
  • npm run check
  • npm run build
  • npm 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:dependencies
  • npm run verify:policy
  • npm run verify:workflows
  • npm run verify:release (27 package files)
  • npm pack --dry-run
  • npm audit --omit=dev --audit-level=high
  • npm audit --audit-level=high
  • git diff --check

Closes #32

@cervantesh
cervantesh merged commit 3e7f96e into main Jul 16, 2026
6 checks passed
@cervantesh
cervantesh deleted the issue-32-structured-error-codes branch July 16, 2026 00:14

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/smart-edit.ts
Comment on lines +46 to +48
const normalized = normalizeSmartEditError(error);
if (normalized.code !== SmartEditErrorCode.StaleAnchor) throw normalized;
first = normalized.message;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose stable structured error codes across adapters

1 participant