Repository navigation
Return private typed Context errors (supersedes #1005; Docs held) - #1215
sidneyswift wants to merge 6 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Pre-merge checks:
|
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Solid & Clean Code | The prior FAIL still holds at head 46a0ae7. I re-read the current source and the claims check out. Main finding: formatContextOperationError (new in this PR). `lib/context/formatContextOperatio… |
1. Split formatContextOperationError (lib/context/formatContextOperationError.ts) so each function does one job: - Move the keyed-action list into a named constant or a predicate module, such as isKeyedContextAction.ts, that exports one… |
Full details: Solid & Clean Code
-
Explanation
The prior FAIL still holds at head 46a0ae7. I re-read the current source and the claims check out. Main finding:
formatContextOperationError(new in this PR).lib/context/formatContextOperationError.tslines 17–47 span 31 lines. The SRP rule sets a limit of 20 lines per function. The function also does several jobs: - Lines 18–33 build an inline 12-itemkeyedaction list. - Lines 34–38 pick retry guidance with a nested ternary, with the generic write guidance as an inline literal. - Lines 39–46 assemble the body and join the guidance strings. - Lines 4–14 hold the code-to-status map. The file's history points to commit5dc71fe8("Return privacy-preserving typed Context operation errors"), which matches this PR's purpose. Treat it as PR-introduced. Adding an action means editing this function andgetContextFailureMessage.ts. The guidance strings are split across both files. This conflicts with the DRY and OCP rules. Prior required fixes not applied: - NoisKeyedContextActionpredicate orgetRetryGuidancemodule exists (ripgrep returned no matches for either name). -lib/mcp/tools/context/getContextToolResultError.tsline 20 still callsformatContextOperationError(error, action).body.guidance. The MCP path therefore takes guidance from the HTTP formatter. Secondary concern (not relied on):lib/context/buildCatalogAuditPreparation.tsis about 48 lines. Its history shows it predates this PR (commitse165405eandb7bddd14). I did not confirm this PR changed it, so it does not support the FAIL. Strengths:classifyContextOperationError.tsis short, keeps its allowlists as data, and exports one matching function. File-name and function-name matching holds for the new context files. Nesting stays within 3 levels. Scope: static reading only. I did not run tests or lint.Resolution
- Split
formatContextOperationError(lib/context/formatContextOperationError.ts) so each function does one job: - Move the keyed-action list into a named constant or a predicate module, such asisKeyedContextAction.ts, that exports one function. - Move retry-guidance selection into its own function, such asgetRetryGuidance.ts. Keep all action-specific guidance in one place, not split between this file andgetContextFailureMessage.ts. - KeepformatContextOperationErrorto status lookup and body assembly, at 20 lines or fewer. 2. Pointlib/mcp/tools/context/getContextToolResultError.tsat the shared guidance function, not atformatContextOperationError(...).body.guidance. 3. Optional: move the action extraction inlib/mcp/tools/context/handleContextToolOperation.tsinto a small helper. 4. Optional: move the duplicated"fetch failed"mapping inlib/context/classifyContextOperationError.tsinto one shared constant. 5. Optional: if this PR changedbuildCatalogAuditPreparation.ts, split it into smaller builders, for example one for sources and one for assessments.
- Split
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Adds pending typed Context errors with nine codes, seven statuses and matching HTTP/MCP guidance. Head
46a0ae73cf6d96941394b45bc04bd572274ee665normally merges released accounting mainc37e7e4e29bd5418ae43399aa45457c5da4b6c1eintoa72b47b729c3876350d07d0cbdbaaa96bb65281e.All 18 contribution files and six pure modules remain byte-identical. All eight incoming accounting files match released main; no recovery feature imported. Unknown errors stay opaque/non-retryable, with existing exact classifications unchanged. Validation: 131 focused tests across five suites, production types, byte preservation and exact independent review passed. Unchanged broad local tests were not repeated; normal CI runs full checks.
Preserves the released accounting labels: amounts are customer charges, included services have no additional customer fee, provider costs are null/not_measured, and concepts/contingency/refinements are not budgeted. Pricing, quote fingerprints and legacy approval behavior are unchanged. Published API/Docs fixture is
7af66d00e0b6fcb7e5a2f27124d173273c973badd670430c0084809f21719458. Catalog preparation/freshness/standard-only OAuth, Context schema10b243 and valuation0e contracts remain intact.Keep draft. Root owns merge/release order and native/intended-account/save/denial/workspace/full-ingestion gates. No previous native acceptance applies to these new heads. No browser/JSON/download/hosting403/auth/provider/access retry, ingestion activation, data/schema/import/spend action or manual deployment. Required exact-head CI must pass; see checks. Local independent review is separate from Cubic's merge-only skipped status.
Summary by cubic
Replaces the blanket 409 and fixed-message Context failures with authored
code,retryable, andguidanceerrors that are identical across HTTP and MCP while preserving existing HTTPerror, MCPmessage/success: false, andisError: truefields. This source-only draft is held until the owning Docs contract is accepted; it supersedes the typed-error work in #1005.Error contract
budget_exhaustedis reserved with no spend-path producer.internal, unknown storage rejections are opaquestorage_failed, and disabled capabilities return 503unavailable.Written for commit 46a0ae7. Summary will update on new commits.