Skip to content

fix(OMN-13521): batch doc-freshness resolver to O(repos) + time-budget guard - #2952

Merged
jonahgabriel merged 3 commits into
devfrom
jonah/omn-13521-doc-freshness-resolver
Jun 23, 2026
Merged

jonahgabriel merged 3 commits into
devfrom
jonah/omn-13521-doc-freshness-resolver

Conversation

@jonahgabriel

Copy link
Copy Markdown
Contributor

OMN-13521 — doc_freshness_sweep resolver: O(refs x repos) serial grep, non-terminating

Fixes the primary root cause of OMN-13521: the /onex:doc_freshness_sweep skill never completed (a background run was still grepping at >70 min wall time / ~28s CPU with no terminal result).

Root cause

doc_reference_resolver._resolve_class_or_function ran one grep -r -l subprocess per class/function reference per repo-root — O(total_refs × repo_roots) serial subprocess spawns, each scanning entire src/ trees, each with a 10s timeout. With tens of thousands of references across the repo set, wall time was dominated by subprocess + filesystem latency.

Fix

  • Batch the resolver. Build an in-memory symbol index once per repo-root (single os.walk over each src/ tree, nested-worktree / .venv / generated dirs pruned in place), then resolve every class/function reference in pure Python against the prebuilt index. No subprocess is spawned during resolution. Cost drops from O(refs × roots) subprocess spawns to O(roots) tree walks + O(refs) dict lookups.
  • Time-budget guard. New time_budget_seconds parameter (default 120s); once the wall-clock budget is exhausted, remaining references are returned exists=None (fail-loud, bounded) rather than running unbounded. Backward-compatible signature: resolve_references(references, repo_roots, env_file=None, time_budget_seconds=120.0).

The nested-worktree exclusion that amplified this is fixed in the paired omnimarket PR.

Evidence (dod_evidence — verified)

  • dod-001: tests/unit/test_doc_reference_resolver.py 10/10 — including a no-subprocess guard (patches stdlib subprocess.run to raise), single-index-build-per-root, and the budget guard. test_doc_freshness.py 42/42 unchanged; full unit suite 910 passed / 32 skipped. ruff + mypy --strict clean.
  • dod-002 (benchmark on the real canonical clones): batched resolver resolves 22,062 references (3,588 class/function) in 4.1s; collect+extract+resolve total 12.0s (was >70 min with no result). 3,045/3,588 class/func refs resolve exists=True via the index.

OCC contract + PASS receipts carried in this PR: contracts/OMN-13521.yaml + drift/dod_receipts/OMN-13521/.

Ticket: OMN-13521
Evidence-Ticket: OMN-13521

jonahgabriel added 2 commits June 22, 2026 22:27
…guard

The doc_freshness_sweep resolver ran one grep -r subprocess per class/function
reference per repo-root (O(refs x roots)). On the real 11-repo set that is tens
of thousands of serial greps; a live sweep was still grepping at >70 min wall
time with no terminal result.

Batch class/function resolution: build an in-memory symbol index once per
repo-root (one os.walk over each src/ tree, nested worktrees / .venv pruned in
place) and resolve every reference against the prebuilt index in pure Python.
No subprocess is spawned during resolution.

Add a wall-clock time_budget_seconds guard (default 120s): once exhausted the
resolver returns the remaining references marked exists=None (fail-loud,
bounded) instead of running unbounded.

Backward-compatible signature: resolve_references(references, repo_roots,
env_file=None, time_budget_seconds=120.0).

Benchmark on the real 10-repo set: 22,062 refs (3,588 class/func) resolved in
4.1s; collect+extract+resolve total 12.0s (was >70 min with no result).

TDD: tests/unit/test_doc_reference_resolver.py pins index-backed resolution,
no-subprocess guard, single-index-build-per-root, and the budget guard.
…-ref resolver

contracts/OMN-13521.yaml + drift/dod_receipts/OMN-13521/ (dod-001 resolver unit
tests + lint/mypy, dod-002 real-repo benchmark, dod-occ-pr contract presence).
Receipt Honesty + Hardening gates pass; receipts bind the current contract
hash; verifier (claude-code-review) distinct from runner (claude-code).
@coderabbitai

coderabbitai Bot commented Jun 23, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@jonahgabriel, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 2 minutes and 30 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d3817921-979d-42a4-b738-4f818165d250

📥 Commits

Reviewing files that changed from the base of the PR and between 6631669 and 4df0535.

📒 Files selected for processing (7)
  • contracts/OMN-13521.yaml
  • drift/dod_receipts/OMN-13521/dod-001/command.yaml
  • drift/dod_receipts/OMN-13521/dod-002/command.yaml
  • drift/dod_receipts/OMN-13521/dod-deploy-assessment/command.yaml
  • drift/dod_receipts/OMN-13521/dod-occ-pr/command.yaml
  • src/onex_change_control/scanners/doc_reference_resolver.py
  • tests/unit/test_doc_reference_resolver.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jonah/omn-13521-doc-freshness-resolver

Comment @coderabbitai help to get the list of available commands.

@jonahgabriel
jonahgabriel added this pull request to the merge queue Jun 23, 2026
…y) for omnimarket deploy-gate

The omnimarket PR touches a runtime path (handler_doc_freshness_sweep.py); the
deploy-gate requires the cited ticket's OCC contract to carry a deploy-flavored
dod_evidence item. doc_freshness_sweep is a COMPUTE-only skill run in-process
via 'onex skill' — no live deploy/restart/docker-exec/rpk needed before merge.
Add dod-deploy-assessment + matching PASS receipt; rebind all receipts to the
updated contract hash.
@jonahgabriel
jonahgabriel removed this pull request from the merge queue due to a manual request Jun 23, 2026
@jonahgabriel
jonahgabriel enabled auto-merge June 23, 2026 02:41
@jonahgabriel
jonahgabriel added this pull request to the merge queue Jun 23, 2026
@jonahgabriel
jonahgabriel removed this pull request from the merge queue due to a manual request Jun 23, 2026
@jonahgabriel
jonahgabriel added this pull request to the merge queue Jun 23, 2026
Merged via the queue into dev with commit 4da2042 Jun 23, 2026
38 checks passed
@jonahgabriel
jonahgabriel deleted the jonah/omn-13521-doc-freshness-resolver branch June 23, 2026 02:50
jonahgabriel added a commit that referenced this pull request Aug 28, 2026
…MN-16755 binding

Two corrections to the autobind output on this companion.

1. DROPPED contracts/OMN-16755.yaml and its three receipts.

The autobind bound OMN-16755 because that ticket id appears in omnibase_infra#2952's
prose -- the PR cites it as the SOURCE of the finding, not as work it closes.
OMN-16755's own ACs are about a gateway link-health bus hop, and its premise was
falsified on 2026-08-27T20:21Z (the chain routes in-process and is alive). #2952
satisfies none of them.

Left in place, that contract is a live false-autoclose hazard: the
evidence-autoclose sweep would have read three passing surrogates against
OMN-16755 and had grounds to flip a ticket whose real work is untouched. Removing
the binding is the honest state; OMN-16755 keeps its own separate disposition.

2. ADDED a BEHAVIOR-PROVING evidence item to OMN-16813.

The three autobind items are all surrogates and would leave
behavior_proving_count = 0:

  - two BYTE-IDENTICAL file-content greps (static inspection, and they grep a
    class NAME rather than any assertion, so they pass on a file whose tests were
    all deleted),
  - one foreign suite (tests/test_evidence_admissibility.py, this repo's own),
  - one bare PR-state read.

None executes the chain the ticket is about. The new item runs the actual suite --
the same command the required `Event Chain Gate` CI job runs.

RECEIPT IS ADVERSARIAL, runner != verifier (OMN-12791). My first attempt set both
to this lane and the receipt-honesty gate correctly rejected it as
SELF_ATTESTATION. The independent verifier is GitHub Actions' own required
`Event Chain Gate` job 98727318636 (run 33133247111, conclusion=success) on
omnibase_infra#2952, whose log is reproduced verbatim in probe_stdout:

  test_intent_arm_reaches_the_real_effect_handler .................... PASSED
  test_a_dead_intent_leg_is_invisible_on_every_topic_the_gate_watches  PASSED
  test_missing_intent_executor_refuses_rather_than_publishing_a_terminal PASSED
  test_validation_is_what_keeps_the_executors_silent_drop_unreachable  PASSED
  8 passed in 1.22s

check_value carries a `repos/OmniNode-ai/omnibase_infra/tree/<sha>` reference
because commit_sha is an omnibase_infra commit and COMMIT_SHA_EXISTS cannot
resolve it in this repo -- also caught by the gate on the first attempt, not
assumed.

Existing receipts are unaffected: contract_entry_sha256 is per-entry (OMN-13888)
and authoritative when present, so appending an item does not unbind them.

Verified: check_receipt_hardening.py exit 0; pre-commit clean on both files.

Evidence-Ticket: OMN-16813
jonahgabriel added a commit that referenced this pull request Aug 28, 2026
#7353)

* evidence: OCC companion pass 1 for OmniNode-ai/omnibase_infra#2952

* evidence: OCC companion self-bind for #7353

* evidence(OMN-16813): behavior-proving check, and drop the incorrect OMN-16755 binding

Two corrections to the autobind output on this companion.

1. DROPPED contracts/OMN-16755.yaml and its three receipts.

The autobind bound OMN-16755 because that ticket id appears in omnibase_infra#2952's
prose -- the PR cites it as the SOURCE of the finding, not as work it closes.
OMN-16755's own ACs are about a gateway link-health bus hop, and its premise was
falsified on 2026-08-27T20:21Z (the chain routes in-process and is alive). #2952
satisfies none of them.

Left in place, that contract is a live false-autoclose hazard: the
evidence-autoclose sweep would have read three passing surrogates against
OMN-16755 and had grounds to flip a ticket whose real work is untouched. Removing
the binding is the honest state; OMN-16755 keeps its own separate disposition.

2. ADDED a BEHAVIOR-PROVING evidence item to OMN-16813.

The three autobind items are all surrogates and would leave
behavior_proving_count = 0:

  - two BYTE-IDENTICAL file-content greps (static inspection, and they grep a
    class NAME rather than any assertion, so they pass on a file whose tests were
    all deleted),
  - one foreign suite (tests/test_evidence_admissibility.py, this repo's own),
  - one bare PR-state read.

None executes the chain the ticket is about. The new item runs the actual suite --
the same command the required `Event Chain Gate` CI job runs.

RECEIPT IS ADVERSARIAL, runner != verifier (OMN-12791). My first attempt set both
to this lane and the receipt-honesty gate correctly rejected it as
SELF_ATTESTATION. The independent verifier is GitHub Actions' own required
`Event Chain Gate` job 98727318636 (run 33133247111, conclusion=success) on
omnibase_infra#2952, whose log is reproduced verbatim in probe_stdout:

  test_intent_arm_reaches_the_real_effect_handler .................... PASSED
  test_a_dead_intent_leg_is_invisible_on_every_topic_the_gate_watches  PASSED
  test_missing_intent_executor_refuses_rather_than_publishing_a_terminal PASSED
  test_validation_is_what_keeps_the_executors_silent_drop_unreachable  PASSED
  8 passed in 1.22s

check_value carries a `repos/OmniNode-ai/omnibase_infra/tree/<sha>` reference
because commit_sha is an omnibase_infra commit and COMMIT_SHA_EXISTS cannot
resolve it in this repo -- also caught by the gate on the first attempt, not
assumed.

Existing receipts are unaffected: contract_entry_sha256 is per-entry (OMN-13888)
and authoritative when present, so appending an item does not unbind them.

Verified: check_receipt_hardening.py exit 0; pre-commit clean on both files.

Evidence-Ticket: OMN-16813

* evidence(OMN-16813): name the receipt for its check_type so the eligibility gate resolves it

The receipt id validator_occ_merge_eligibility looks for is
<ticket>:<evidence_item_id>:<check_type>, and it resolves the file by check_type
name -- command.yaml for check_type: command, test_passes.yaml for
check_type: test_passes. The autobind only ever emits command receipts, so the
new behavior-proving item (check_type: test_passes) was written to command.yaml
by pattern-matching its siblings, and the gate correctly reported:

  missing_or_nonpass_receipts:
    ["OMN-16813:dod-behavior-intent-arm-chain-gate:test_passes"]

Renamed, not re-typed. Downgrading the check to check_type: command to match the
filename would have made the gate pass while turning the only behavior-proving
leg back into a surrogate -- which is the whole defect this item exists to fix.

Content unchanged; check_receipt_hardening.py still exits 0 (contract_entry_sha256
binds the entry, not the path).

Evidence-Ticket: OMN-16813

---------

Co-authored-by: node-occ-companion-effect <occ-companion-effect@omninode.ai>
Co-authored-by: jonahgabriel <jonah@omninode.ai>
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.

1 participant