Skip to content

fix(kuna): report document failures as typed codes - #8064

Merged
morluto merged 2 commits into
mainfrom
cursor/kuna-document-error-codes-168f
Oct 29, 2026
Merged

morluto merged 2 commits into
mainfrom
cursor/kuna-document-error-codes-168f

Conversation

@morluto

@morluto morluto commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

Kuna document, reference, string-inventory, and command admission still threw Error and treated the English sentence as the failure identity. Callers that wrap those failures now keep a stable code and the structured fields that identify the row, field, or address.

Problem and expected behavior

KunaJsonStream, reference-file checks, string inventory, project reads, and target commands threw messages such as "functions row codeC must be null" and "shorter than its recorded span". A short span or a non-numeric count was identifiable only by matching that sentence.

Those failures now throw KunaDocumentError. Its code is the stable identity, and optional detail holds member, field, and similar facts. The JSON stream maps that error to AnalysisOutputError with reason set to the code and the same facts in diagnostics. The user message stays ${label} cannot be used and no longer copies the code into prose.

Incoming-reference parsing returns { code, field } when an address field fails. field is the JSON key from KunaDocumentError.detail, and the reference adapter copies both into ProviderAdapterError diagnostics.

Change and scope

KunaDocumentError owns document and command admission. KunaJsonStream.#reject still passes AnalysisResourceConstraintError through and still wraps unexpected causes with unusable. Reference-file Result errors now carry the code, and incoming-reference address failures also carry field.

No hardcoded limit was changed, so no new REA_ setting. The 64-code-unit Kuna number bound stays a format constant. No provider code moved into the application layer. Ghidra, Wasm, process, EVM, and filesystem throws are a separate change.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Kuna document parsing owns the refusal. AnalysisOutputError.reason and diagnostics.code are the code. Incoming-reference address failures also report diagnostics.field. Consumers that matched Error.message sentences now match code.
  • Contribution scope fit and linked maintainer decision: not applicable. Existing Kuna admission; no new provider, execution, injection, or mutation.
  • CLI and MCP/tool-catalog contract: a Kuna document failure that reaches a provider adapter reports the code as the output reason. Tool names are unchanged.
  • Provider, bridge, target-format, or platform compatibility: Kuna JSON documents, reference files, string inventory, and target commands.
  • Evidence, artifact, provenance, or reconstruction contract: accepted documents are unchanged. Refusals identify themselves by code and diagnostics.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): a short span still fails cleanup ownership; the cause is KunaDocumentError with code span_short.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: kunaStringInventory.test.ts asserts AnalysisOutputError reason not_kuna_number and diagnostics { code, field: "count" }. kunaSpanCloseOwnership.test.ts asserts cause _tag KunaDocumentError and code span_short. kunaReferenceFiles.test.ts asserts reason row_must_be_null and diagnostics { member: "functions", field: "codeC" }, and incoming-reference address failures assert { code, field: "from_address" } for invalid_address and address_exceeds_u64.
  • Base reproduction or other evidence: executed. Focused Kuna boundary tests pass on this branch.
  • User-visible CLI/MCP output (if applicable): adapter text stays Kuna's ${label} cannot be used plus the code. The reason field is the code. Incoming-reference diagnostics include field when an address field failed.
  • Remaining proof gaps: no live Kuna project was opened. Resource-constraint failures were not re-run beyond the existing query-error tests.

For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.

Kuna document admission and span-close ownership are the boundaries covered. The span-short path still fails closed during cleanup. No new lifecycle stage was added.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:focused -- tests/boundary/providers/kuna/kunaStringInventory.test.ts — 41 passed.
  • npm run test:focused -- tests/boundary/providers/kuna/kunaSpanCloseOwnership.test.ts — 20 passed.
  • npm run test:focused -- tests/boundary/providers/kuna/kunaReferenceFiles.test.ts — 21 passed, including the address-field cases.
  • npm run test:focused -- tests/boundary/providers/kuna/kunaReferences.test.ts — 17 passed.
  • npm run test:focused -- tests/boundary/providers/kuna/kunaQueryErrors.test.ts — 10 passed.
  • npm run format:check — passed.
  • npm run check:fast — typecheck and lint passed. The pre-push hook ran check:fast again and it passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: callers that matched Kuna Error.message text need to switch on KunaDocumentError.code or AnalysisOutputError.reason and diagnostics. Incoming-reference failures are { code, field? } instead of a sentence. Accepted documents are unchanged.
  • Real Hopper/Ghidra, browser, or OS coverage: not run. Fixture tests only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new process, network, or file write. Failure identity no longer depends on an English sentence.

Author readiness

Human owner: @morluto

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.
Open in Web Open in Cursor 

Kuna JSON, graphs, xrefs, spans, and command checks threw Error and
published the sentence. Those refusals are now KunaDocumentError codes
with the field or path that failed. Output errors keep the code as
reason and the same facts in diagnostics.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-29T21:45:27.688184Z
We couldn’t complete this review. Comment @codex review to try again.
29e4173 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cursor

cursor Bot commented Oct 29, 2026

Copy link
Copy Markdown

@gensokyo-dev @dandgabr Kuna document admission now uses KunaDocumentError codes. Please review when you can. Ghidra, Wasm, process, EVM, and filesystem throws are a separate PR.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issue was found.

Summary

The PR gives Kuna document failures stable codes. The latest changes also preserve the failed address field through incoming-reference errors.

  • Kuna document failures reach callers with stable codes and useful details.
  • Incoming-reference failures keep their codes and failed address fields.
  • Kuna span and command boundaries use named failure codes.

Reviews (2) · Last reviewed commit: "fix(kuna): keep incoming-reference addre..." · Reviewed by Greptile

Comment thread src/kuna/KunaJson.ts Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@morluto
morluto merged commit 3b64713 into main Oct 29, 2026
43 checks passed
@morluto
morluto deleted the cursor/kuna-document-error-codes-168f branch October 29, 2026 22:07
@morluto morluto added bug Something isn't working provider: kuna Analysis provider / engine: kuna labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working provider: kuna Analysis provider / engine: kuna

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants