Skip to content

fix(mcp): expose recursion metadata in trace_path - #2842

Open
pcristin wants to merge 2 commits into
DeusData:mainfrom
pcristin:codex/fix-2816-trace-recursion
Open

pcristin wants to merge 2 commits into
DeusData:mainfrom
pcristin:codex/fix-2816-trace-recursion

Conversation

@pcristin

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #2816.

A directly recursive function can currently return callees_total: 0 with relation eq and no indication of recursion. Static indexing intentionally omits direct self-call edges, even when extraction correctly records recursion on the function node.

Expose the start nodes' stored self_recursive and recursive signals in tree and JSON traces. CALLS-inclusive traces also report self_call_policy: omitted. Reachability totals and indexed edges retain their existing meaning. Across matching definitions/stubs, any recorded true wins, all recorded false yields false, and missing or invalid metadata yields null. These fields remain visible on continuation pages and budget-floor responses.

For the issue's countdown example, the trace now includes:

self_recursive: true
recursive: true
self_call_policy: omitted
callees_total: 0
callees_total_relation: eq

Tests cover direct versus cycle recursion, legacy/invalid metadata, multiple roots, callee isolation, edge filters, output budgets, and cursor continuation. The README documents the contract. No reindex is required to expose flags already stored in an index.

Written with OpenAI Codex on behalf of the submitting contributor.

Validation

  • Full scripts/test.sh completed on Linux x86_64 using Clang 20 with ASan/UBSan: 10,026 passed, 0 failed, 10 skipped across 191 suites. All enabled final process guards passed. Compilation used a temporary external wrapper that caches preprocessed translation units and adds the C++ sanitizer runtime at link time; repository build files were unchanged.
  • Existing UBSan null-pointer-argument warnings were emitted in unchanged Perl/RST doc-link and callable-signature helpers; passing exit status does not imply a warning-free sanitizer run.
  • Four focused recursion/pagination regressions passed. The three new regressions were observed failing before the renderer change.
  • The built native binary passed 16 trace checks against fresh sequential and parallel TypeScript fixture indexes, in both tree and JSON formats, including the recursive and ordinary-call controls from the issue.
  • Full CI lint (make -f Makefile.cbm lint-ci) passed with cppcheck 2.20.0 and clang-format 20. Staged diff-scoped clang-tidy 20, whitespace, memory-core and no-suppression checks passed.
  • The full make -f Makefile.cbm security audit passed against the local test-seam binary, including source, binary strings, UI, installation, network egress, adversarial MCP inputs, and vendored integrity checks.

Checklist

  • Every commit is signed off (git commit -s); scripts/check-dco.sh HEAD^..HEAD passed
  • Tests pass locally (scripts/test.sh)
  • Lint passes (make -f Makefile.cbm lint-ci)
  • New behavior is covered by a test (reproduce-first for bug fixes)

Report stored recursion signals and the static self-call omission policy
alongside graph reachability totals. Preserve the metadata across cursor
pages and output-budget fallback responses, and document unknown legacy
metadata without changing CALLS indexing or traversal counts.

Fixes DeusData#2816

Signed-off-by: pcristin <xxxokzxxx@protonmail.com>
@pcristin
pcristin requested a review from DeusData as a code owner October 29, 2026 22:22
@github-actions

Copy link
Copy Markdown

Thanks for opening this — it has been seen, and it is queued.

This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence.

Current review status: working through a backlog. 0.9.1-rc.1 is out, so the release freeze that held reviews is over — but it left a large queue of open pull requests behind it, and we are reading through them oldest-first. The background is in discussion #1144.

What that means for this PR, concretely:

  • It will not be closed for inactivity. No stale bot touches pull requests here.
  • It may still sit a while before a human reads it. That is on us, not on you.
  • Older PRs are read first, so a recent one is not being skipped — it is behind a queue.

Things that will genuinely speed it up whenever review does happen:

  • Keep it rebased on main — the tree is moving quickly right now, and a conflicting branch cannot be reviewed as the diff you intended.
  • Get CI green, or say which failures you believe are pre-existing.
  • Keep the change to one claim. Bundled features and refactors get split before they get merged, which costs you a round trip.
  • Every commit needs a sign-off (git commit -s) — CI enforces DCO.

If this fixes a bug, a reproduction we can run is worth more than a description of the symptom.

Thanks for contributing, and sorry in advance for the wait.

This branch has not been deployed

No deployments
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.

trace_path: expose direct self-recursion instead of an unqualified zero-callee result

1 participant