Skip to content

feat(torghut): add renewal bond profit escrow#5412

Open
gregkonush wants to merge 44 commits intomainfrom
codex/swarm-torghut-quant
Open

feat(torghut): add renewal bond profit escrow#5412
gregkonush wants to merge 44 commits intomainfrom
codex/swarm-torghut-quant

Conversation

@gregkonush
Copy link
Copy Markdown
Member

@gregkonush gregkonush commented May 5, 2026

Summary

  • Implements the active Torghut runtime handoff across docs/torghut/design-system/v6/137-torghut-renewal-bond-profit-escrow-and-evidence-carry-2026-05-07.md and companion docs/agents/designs/133-jangar-in-flight-stage-renewal-bonds-and-controller-ingestion-settlement-2026-05-07.md with a shadow-only torghut.renewal-bond-profit-escrow.v1 receipt in /readyz and /trading/status.
  • Preserves and validates the doc 64/doc 63 runtime cutover signal carried by the NATS handoff: typed quant-health URL parity, lane-local profit_window_id and evidence_escrow_id projection, stale evidence expiry, evidence epochs, runtime-closure receipts, proof-lease projection, and shared simple-lane live-submission blocking.
  • Extends Jangar dependency quorum parsing so Torghut can consume stage trust, renewal bonds, controller ingestion settlement, and generated-at metadata while ranking zero-notional repair actions from the shared status surface.
  • Keeps live capital defaults unchanged and fail-closed: stale empirical proof, stale TCA, missing quant evidence, market-context contradictions, proof-floor failures, missing Jangar stage trust, or blocked hypothesis readiness hold max_notional at 0.

Related Issues

None. Requirement provenance came from the torghut-quant implementation mission, the NATS general-channel handoff for doc 64/doc 63 cutover criteria, and the current Torghut source-of-truth guide selecting the May 7 doc 137/doc 133 renewal-bond runtime objective as the active implementation handoff. After the final origin/main merge, the v6 index also lists newer follow-on docs 143/144 from main as next-work architecture; this PR does not claim to implement those later contracts.

Testing

  • PASS: /tmp/codex-uv-bootstrap/bin/uv sync --frozen --extra dev
  • PASS: /tmp/codex-uv-bootstrap/bin/uv run --frozen ruff format --check app/main.py app/models/__init__.py app/models/entities.py app/trading/discovery/runtime_closure.py app/trading/evidence_epochs.py app/trading/evidence_receipts.py app/trading/hypotheses.py app/trading/profit_leases.py app/trading/profit_windows.py app/trading/renewal_bond_profit_escrow.py app/trading/submission_council.py migrations/versions/0030_evidence_epochs.py tests/test_evidence_epochs.py tests/test_hypotheses.py tests/test_profit_leases.py tests/test_profit_windows.py tests/test_renewal_bond_profit_escrow.py tests/test_runtime_closure.py tests/test_submission_council.py tests/test_trading_api.py tests/test_trading_pipeline.py
  • PASS: /tmp/codex-uv-bootstrap/bin/uv run --frozen ruff check app/main.py app/models/__init__.py app/models/entities.py app/trading/discovery/runtime_closure.py app/trading/evidence_epochs.py app/trading/evidence_receipts.py app/trading/hypotheses.py app/trading/profit_leases.py app/trading/profit_windows.py app/trading/renewal_bond_profit_escrow.py app/trading/submission_council.py migrations/versions/0030_evidence_epochs.py tests/test_evidence_epochs.py tests/test_hypotheses.py tests/test_profit_leases.py tests/test_profit_windows.py tests/test_renewal_bond_profit_escrow.py tests/test_runtime_closure.py tests/test_submission_council.py tests/test_trading_api.py tests/test_trading_pipeline.py
  • PASS: /tmp/codex-uv-bootstrap/bin/uv run --frozen pytest tests/test_evidence_epochs.py tests/test_profit_leases.py tests/test_profit_windows.py tests/test_renewal_bond_profit_escrow.py tests/test_runtime_closure.py tests/test_submission_council.py tests/test_trading_api.py tests/test_trading_pipeline.py tests/test_hypotheses.py (250 passed, 1 warning)
  • PASS: /tmp/codex-uv-bootstrap/bin/uv run --frozen pytest --cov --cov-branch --cov-report=term-missing --cov-report=xml (1965 passed, total coverage 76.68%)
  • PASS: /tmp/codex-uv-bootstrap/bin/uv run --frozen python scripts/check_diff_coverage.py --coverage-xml coverage.xml --threshold 90 (91.89% changed-line coverage)
  • PASS: /tmp/codex-uv-bootstrap/bin/uv run --frozen python scripts/check_migration_graph.py (ok=true, head 0030_evidence_epochs)
  • PASS: /tmp/codex-uv-bootstrap/bin/uv run --frozen ruff format --check app/trading/discovery/runtime_closure.py tests/test_runtime_closure.py scripts/run_whitepaper_autoresearch_profit_target.py tests/test_run_whitepaper_autoresearch_profit_target.py after the final origin/main conflict resolution
  • PASS: /tmp/codex-uv-bootstrap/bin/uv run --frozen ruff check app/trading/discovery/runtime_closure.py tests/test_runtime_closure.py scripts/run_whitepaper_autoresearch_profit_target.py tests/test_run_whitepaper_autoresearch_profit_target.py after the final origin/main conflict resolution
  • PASS: /tmp/codex-uv-bootstrap/bin/uv run --frozen pytest tests/test_runtime_closure.py tests/test_run_whitepaper_autoresearch_profit_target.py (48 passed, 1 warning) after the final origin/main conflict resolution
  • PASS: /tmp/codex-uv-bootstrap/bin/uv run --frozen pyright --project pyrightconfig.json (0 errors, 0 warnings, 0 informations)
  • PASS: /tmp/codex-uv-bootstrap/bin/uv run --frozen pyright --project pyrightconfig.alpha.json (0 errors, 0 warnings, 0 informations)
  • PASS: /tmp/codex-uv-bootstrap/bin/uv run --frozen pyright --project pyrightconfig.scripts.json (0 errors, 0 warnings, 0 informations)
  • PASS: git diff --check
  • PASS CI: torghut-ci / Bytecode + pytest + coverage on head 4a4e24db2 (5m50s)
  • PASS CI: torghut-ci / Pyright on head 4a4e24db2 (1m0s)
  • PASS CI: torghut-ci / Quality signals (complexity + security) on head 4a4e24db2 (20s)
  • PASS CI: CI / check_changed_files, Semantic Commits / Lint commit messages, and Semantic Pull Request / Validate PR title

Screenshots (if applicable)

N/A. Backend runtime projection, API status payload, tests, and documentation changes only.

Breaking Changes

None. The proof lease, profit-window, evidence epoch, runtime-closure, and renewal-bond escrow payloads are additive and shadow-first; live capital defaults remain fail-closed.

Risk And Rollback

Risk: the new renewal-bond and profit-window projections are intentionally conservative. They can keep paper/live capital blocked while preserving stale-but-useful proof for zero-notional repair ranking, so rollout operators should treat new repair_only and expired-escrow states as expected safety behavior rather than a live-order enablement.

Rollback: revert this PR or roll back the Torghut image through the normal release PR/GitOps path. Downstream consumers can ignore renewal_bond_profit_escrow, profit_window_contract, and profit_lease_projection while keeping the existing live_submission_gate and TRADING_SIMPLE_SUBMIT_ENABLED=false; append-only evidence epoch and receipt rows should remain for audit continuity.

Large-Diff Review Gate

This PR exceeds 1000 additions plus deletions (5917 additions, 455 deletions at current diff), so Codex review is required before merge under the repo execution contract. Current head is 4a4e24db2c32c549efb999fd177dd8739172383e; the current-head Codex review request is #5412 (comment). The connector is still blocked by the account usage-limit response at #5412 (comment). Do not merge until a Codex review posts and any resulting threads are resolved, or a maintainer explicitly waives this large-diff gate.

Checklist

  • Testing section documents the exact validation performed.
  • Screenshots and Breaking Changes sections are handled appropriately.
  • Documentation, release notes, and follow-ups are updated or tracked.

@gregkonush
Copy link
Copy Markdown
Member Author

gregkonush commented May 5, 2026

Status as of 2026-05-07T10:43Z: mergeable with green CI; blocked only on the large-diff Codex review gate.

  • Current head: 4a4e24db296fa816f06815c79485d1b460112a93.
  • Merge state: CLEAN / MERGEABLE; worktree is clean and tracking origin/codex/swarm-torghut-quant.
  • CI gate: green. Bytecode + pytest + coverage, Pyright, Quality signals, check_changed_files, semantic commits, and semantic PR title checks all passed; non-impacted matrix jobs are intentionally skipped.
  • Local validation refreshed in this workspace: uv sync --frozen --extra dev passed; diff-scoped ruff format --check passed on 21 touched Python files; diff-scoped ruff check passed; focused Torghut regressions passed (252 passed, 1 warning); migration graph passed at head 0030_evidence_epochs; all three Torghut pyright profiles passed; git diff --check passed.
  • Review gate: PR size remains over the 1000-line threshold (5917 additions, 455 deletions). Current-head @codex review request is posted at feat(torghut): add renewal bond profit escrow #5412 (comment).
  • Blocker: the Codex review connector is still returning account usage-limit responses, so this PR must not be merged unless Codex review later posts and threads are resolved or a maintainer explicitly waives this large-diff gate. Current-head connector response is feat(torghut): add renewal bond profit escrow #5412 (comment).

@gregkonush gregkonush changed the title fix(torghut): enforce shared live gate for simple lane feat(torghut): add evidence epochs and shared live gate May 5, 2026
@gregkonush
Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@gregkonush
Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@gregkonush
Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@gregkonush
Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@gregkonush
Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@gregkonush
Copy link
Copy Markdown
Member Author

@codex review

Refreshed on current head 9f3defc after scoped Torghut formatter cleanup. Large-diff review gate still applies before merge.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@gregkonush
Copy link
Copy Markdown
Member Author

@codex review

Refreshed on current origin/main at head 9fccdc0. Large-diff review gate still applies before merge.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@gregkonush
Copy link
Copy Markdown
Member Author

@codex review

Refreshed on current head 9fccdc0 after fast-forwarding the Torghut quant branch onto current main. Large-diff review gate still applies before merge.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@gregkonush
Copy link
Copy Markdown
Member Author

@codex review

Refreshed on current origin/main at head f18e315. Large-diff review gate still applies before merge.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@gregkonush
Copy link
Copy Markdown
Member Author

@codex review

Refreshed on current head f18e315 after branch refresh onto current main. Large-diff review gate still applies before merge.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@gregkonush
Copy link
Copy Markdown
Member Author

@codex review

Refreshed on current origin/main at head 4685c09. Large-diff review gate still applies before merge.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@gregkonush
Copy link
Copy Markdown
Member Author

@codex review

Refreshed on current head 4685c09 after branch refresh onto current main. Large-diff review gate still applies before merge.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

…uant

# Conflicts:
#	services/torghut/tests/test_trading_pipeline.py
@gregkonush
Copy link
Copy Markdown
Member Author

@codex review

Refreshed on current main at head a46b55a with green CI. Large-diff review gate still applies before merge.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@gregkonush
Copy link
Copy Markdown
Member Author

@codex review

Current head: ffd244a. This PR is over the 1000-line large-diff threshold and needs Codex review before merge unless a maintainer explicitly waives that gate.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

…uant

# Conflicts:
#	services/torghut/app/trading/discovery/runtime_closure.py
@gregkonush
Copy link
Copy Markdown
Member Author

@codex review

Current head: 4a4e24d. This PR remains over the 1000-line large-diff threshold and needs Codex review before merge unless a maintainer explicitly waives that gate.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

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