Skip to content

fix: Recompute account drawdown before risk admission - #968

Merged
Pigbibi merged 4 commits into
mainfrom
fix/drawdown-cache-recompute-r4
Nov 4, 2026
Merged

Pigbibi merged 4 commits into
mainfrom
fix/drawdown-cache-recompute-r4

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

AI assistance

Codex (configured worker model gpt-6.1-sol) authored the cache repair and offline validation. Independent acceptance belongs to the established review-and-merge bot; previous review findings remain historical until the new exact head is reviewed.

What changed

Refresh stale drawdown caches from current account NAV/peak while preserving valid native explicit drawdown and native peak-only arithmetic. A 7.5% artificial reduce case previously sold zero shares because cache recomputation replaced the native .075 float with a smaller binary64 value; it now sells exactly five, matching main. Native .2 remains bit-equal.

Keep metadata/nested cache values separate from the native measurement during rebuilds. Existing timestamped fallback retains its measurement provenance and expiry check. UNKNOWN still uses the unavailable-observation gate, and measured breaches retain the persistent breaker behavior. No sizing function or threshold changes.

The complete PR contains the earlier cache regressions and necessary r4 measurement fixtures. This follow-up changes only the adapter and adds native compatibility tests; existing fixtures and expected values are untouched by this repair.

How verified

  • Full final production-pinned offline suite: 6,361 passed, 6 skipped, 368 subtests passed; exit 0. Unmodified main: 6,274 passed, 6 skipped, 368 subtests passed. The initial PR head reproduced one failure: the unchanged .075 fake sell test.
  • Regression checks before repair: 15 failed, 6 passed. The five focused modules passed all 194 cases; the final full suite covers the resulting production tree.
  • Packed binary64 comparison: 80 same-input native cases match main exactly, including actual artificial dispatch, both symbols, threshold neighbors, native .2, volatility and peak-only controls. Another 16 corrected-cache cases match main given an independently fresh explicit current measurement. This does not claim stale inputs have unchanged results or universal equivalence for every input.
  • Ruff, whitespace, frozen lock, protected workflow contract, QPK pin consistency and Cloud Run startup validation passed.
  • Central style checker revision 6ad9627e588bfe474fa14130fb03af948f74d03e, run over the entire candidate tree: 0 blocking, 1 existing README advisory, exit 0. Repository style check reports the same result.
  • Failure attribution: the three historical cases all pass on fresh main and the pre-PR base (both currently the same revision). Reapplying the retained uncommitted r3 source reproduces one .075 sizing failure and two .2 precision failures; they are not three pre-existing .075 failures. Blame and adjacent good/bad bisect identify initial PR commit 58af1e1e03623d4abec054b493a9eb05884fb0cb as introducing the committed .075 regression. The two historical .2 failures were already corrected in r4. No failure is waived as pre-existing.
  • Hosted CI, the separate research-overlay pin environment, deployed adoption and runtime qualification are not established by these local checks.

Why

The cache repair must not replace current native measurements or change main's sizing boundary behavior. Keeping source provenance prevents cache values from gaining native precedence after rebuild.

Risk

High: account risk adapter. Existing malformed/missing measurement, stale-cache, timestamp, journal/restart and switch-off tests remain green. Bit equality is limited to the stated comparison matrix. Existing required native checks and review gates remain intact. No merge, deployment, labels, production switches, credentials, IAM or Gateway operations are part of this change.

Publication check

Shared checker publication-check/2.0-advisory, build 2947dd7867b4: 2533 total findings, 2410 matching lines on the complete tracked candidate tree and offline probe; advisory scan completed. No real credential was identified in this repair. The central checker result is recorded above.

First 20 matches (masked text):

repo/.env.example:11: IB_GATEWAY_HOST=<PROJECT_ID>
repo/.env.example:19: TELEGRAM_TOKEN=<<HOST>>
repo/.<PROJECT_ID>/CODEOWNERS:9: /.env.example @<PROJECT_ID>
repo/.<PROJECT_ID>/CODEOWNERS:10: /.<PROJECT_ID>/CODEOWNERS @<PROJECT_ID>
repo/.<PROJECT_ID>/CODEOWNERS:11: /application/account_new_risk_gate_support.py @<PROJECT_ID>
repo/.<PROJECT_ID>/CODEOWNERS:12: /application/execution_kernel_adapter.py @<PROJECT_ID>
repo/.<PROJECT_ID>/CODEOWNERS:13: /application/execution_receipt_adapter.py @<PROJECT_ID>
repo/.<PROJECT_ID>/CODEOWNERS:14: /application/execution_service.py @<PROJECT_ID>
repo/.<PROJECT_ID>/CODEOWNERS:15: /application/ibkr_order_execution.py @<PROJECT_ID>
repo/.<PROJECT_ID>/CODEOWNERS:16: /application/paper_execution_admission.py @<PROJECT_ID>
repo/.<PROJECT_ID>/CODEOWNERS:17: /application/paper_execution_command_consumer.py @<PROJECT_ID>
repo/.<PROJECT_ID>/CODEOWNERS:18: /application/portfolio_risk_diagnostics.py @<PROJECT_ID>
repo/.<PROJECT_ID>/CODEOWNERS:19: /application/relative_risk_preview.py @<PROJECT_ID>
repo/.<PROJECT_ID>/CODEOWNERS:20: /application/tqqq_offline_risk.py @<PROJECT_ID>
repo/.<PROJECT_ID>/CODEOWNERS:21: /runtime_execution_policy.py @<PROJECT_ID>
repo/.<PROJECT_ID>/CODEOWNERS:22: /scripts/deploy_notification_only.py @<PROJECT_ID>
repo/.<PROJECT_ID>/CODEOWNERS:23: /scripts/deploy_pilot_no_traffic.py @<PROJECT_ID>
repo/.<PROJECT_ID>/CODEOWNERS:24: /scripts/execution_report_heartbeat.py @<PROJECT_ID>
repo/.<PROJECT_ID>/CODEOWNERS:25: /scripts/ibkr_deployment_audit.py @<PROJECT_ID>
repo/.<PROJECT_ID>/CODEOWNERS:26: /scripts/summarize_execution_ledger_cloud.py @<PROJECT_ID>

@Pigbibi

Pigbibi commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 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 ✅ Completed 2026-11-04T11:18:27.202900Z de9a610 Manual request
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 58af1e1e03

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Pigbibi

Pigbibi commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review current head 76cc9172b33815e3ae595b8d50e1c50989bc5004. This repair preserves native explicit drawdown and leaves sizing algorithms and existing fixtures unchanged. The full offline suite passes; failure attribution and central publication checks are documented in the PR body.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 76cc9172b3

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Pigbibi Pigbibi added the owner-approved Owner approval; review bot may apply on owner's authorization, ledgered label Nov 4, 2026
@Pigbibi
Pigbibi marked this pull request as ready for review November 4, 2026 07:59
@Pigbibi
Pigbibi enabled auto-merge November 4, 2026 08:00
@Pigbibi

Pigbibi commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review exact head 9e68fdaf97048dc66e8da185fe2f1cb8733446a3 for PR #968.

The snapshot portfolio projection now preserves drawdown observation time. Regression: 4 failed before the fix; focused suites: 162 passed after. Full suite: 6,366 passed, 6 skipped, 368 subtests passed. Existing P1/native/cache tests remain green.

Publication checker publication-check/2.0-advisory (build 2947dd7867b4): exit 0, advisory; 2533 full-tree matches / 2410 matching lines. Phase-2 style check: 0 blocking, 1 existing README advisory. No deployment or runtime acceptance is claimed.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 9e68fdaf97

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Pigbibi

Pigbibi commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: de9a610e0e

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Pigbibi
Pigbibi merged commit 95b8f10 into main Nov 4, 2026
13 checks passed
@Pigbibi
Pigbibi deleted the fix/drawdown-cache-recompute-r4 branch November 4, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

owner-approved Owner approval; review bot may apply on owner's authorization, ledgered

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants