Historical SG rebalance claim deduplication bug
- Repository:
QuantStrategyLab/LongBridgePlatform
- Source ref:
ai-history-sg-claim-dedup-20260915
- Baseline revision:
26844fa9b909e98e867acf4c50120b90acc6c792
- Execution mode: historical offline sandbox only
Problem
In the SG rebalance path, a due durable command is claimed before execution. In
the same session, the service can then find evidence in the execution marker or
prior report that the signal was already executed. The service skips duplicate
execution, but the current claim remains in CLAIMED, so later processing sees a
stale in-flight command and is blocked.
The historical evidence is:
- The affected cycle is SG 9/11, with signal 9/10 and effective date 9/11.
- The command was claimed once (
cmd-3915a5fb16264cb4eab5cd4a970de069).
- Same-cycle evidence says the duplicate was skipped because the signal dated 9/10
for the 9/11 execution session had already been recorded.
- The observed report had
action_done=false,
broker_submission_done=false, and orders=0.
- The later unresolved state is caused by the claimed command remaining
durable, not by evidence of a broker submission.
Requested repair
Inspect the existing claim, marker, prior-report, and terminal-state flow and
propose the smallest repair that closes the current claim when duplicate
execution is positively confirmed and no new submission is made. Preserve the
existing duplicate-execution protection.
Do not cancel or otherwise terminally resolve a claim when marker/report
reading fails, identity cannot be established, evidence is ambiguous, or the
broker outcome is unknown. Those cases must remain fail-closed and retain the
claim for reconciliation.
The repair and regression coverage may modify only:
application/rebalance_service.py
tests/test_rebalance_service.py
The regression must be deterministic, offline, and use historical fixtures. It
must cover both the positively confirmed duplicate path and a negative path in
which marker/report evidence is unavailable or unreadable; the latter must
remain CLAIMED with zero orders/submissions. Do not perform live orders,
deployments, remote state changes, or workflow dispatch.
Required response
Return the proposed patch and tests for human review, with the exact files
changed, the evidence used, and the test command/result. If the source or
evidence needed to establish a safe terminal state is absent, stop and report
the gap instead of guessing.
This is an authorized historical research task, not an active production incident. The bridge may create one draft PR against the historical sandbox branch after its isolated tests pass. Do not merge, deploy, or modify the production main branch.
Previous attempt diagnostic feedback (append-only; preserve the issue body above)
Use the fixed repository state only: QuantStrategyLab/LongBridgePlatform, branch ai-history-sg-claim-dedup-20260915, baseline commit 26844fa9b909e98e867acf4c50120b90acc6c792. The allowed write set remains exactly application/rebalance_service.py and tests/test_rebalance_service.py; do not modify other files, prompts, frameworks, grants, claims, deployment, or trading behavior.
The prior generated test was diagnosed offline with these concrete failures: CommandStore.current_state was always CLAIMED; enqueue returned the same already-due command, so the positive path had duplicate due work; the frozen plan dates were inconsistent; and the append_event return value of None was not verified. These are diagnostic facts, not a request to copy the previous human repair.
Regenerate and implement the smallest fix in the two allowed files against the supplied baseline. The positive test must exercise the real path from an initially QUEUED command to one claim, use an independent future command for the new signal, and use the frozen plan date transition 2026-09-10 to 2026-09-11 with the correct marker key. It must verify the actual marker/prior-report reads, final state CANCELLED, exactly one claim, and zero orders.
Keep negative cases independent and verify they actually read the evidence, remain CLAIMED, emit no close event, and submit zero orders. Cover marker-missing/prior-report-present behavior. If evidence reads fail, or append_event returns None, do not claim closure; preserve the unresolved/claimed state and emit the existing warning behavior without inventing a new return protocol.
Return targeted edits against the supplied baseline. The bridge, not this model session, applies the patch and runs the pinned offline tests; do not claim test execution or results yourself. Do not claim AI success from a human patch, do not call another model, do not dispatch production work, and do not merge or publish.
Historical SG rebalance claim deduplication bug
QuantStrategyLab/LongBridgePlatformai-history-sg-claim-dedup-2026091526844fa9b909e98e867acf4c50120b90acc6c792Problem
In the SG rebalance path, a due durable command is claimed before execution. In
the same session, the service can then find evidence in the execution marker or
prior report that the signal was already executed. The service skips duplicate
execution, but the current claim remains in
CLAIMED, so later processing sees astale in-flight command and is blocked.
The historical evidence is:
cmd-3915a5fb16264cb4eab5cd4a970de069).for the 9/11 execution session had already been recorded.
action_done=false,broker_submission_done=false, andorders=0.durable, not by evidence of a broker submission.
Requested repair
Inspect the existing claim, marker, prior-report, and terminal-state flow and
propose the smallest repair that closes the current claim when duplicate
execution is positively confirmed and no new submission is made. Preserve the
existing duplicate-execution protection.
Do not cancel or otherwise terminally resolve a claim when marker/report
reading fails, identity cannot be established, evidence is ambiguous, or the
broker outcome is unknown. Those cases must remain fail-closed and retain the
claim for reconciliation.
The repair and regression coverage may modify only:
application/rebalance_service.pytests/test_rebalance_service.pyThe regression must be deterministic, offline, and use historical fixtures. It
must cover both the positively confirmed duplicate path and a negative path in
which marker/report evidence is unavailable or unreadable; the latter must
remain
CLAIMEDwith zero orders/submissions. Do not perform live orders,deployments, remote state changes, or workflow dispatch.
Required response
Return the proposed patch and tests for human review, with the exact files
changed, the evidence used, and the test command/result. If the source or
evidence needed to establish a safe terminal state is absent, stop and report
the gap instead of guessing.
This is an authorized historical research task, not an active production incident. The bridge may create one draft PR against the historical sandbox branch after its isolated tests pass. Do not merge, deploy, or modify the production main branch.
Previous attempt diagnostic feedback (append-only; preserve the issue body above)
Use the fixed repository state only:
QuantStrategyLab/LongBridgePlatform, branchai-history-sg-claim-dedup-20260915, baseline commit26844fa9b909e98e867acf4c50120b90acc6c792. The allowed write set remains exactlyapplication/rebalance_service.pyandtests/test_rebalance_service.py; do not modify other files, prompts, frameworks, grants, claims, deployment, or trading behavior.The prior generated test was diagnosed offline with these concrete failures:
CommandStore.current_statewas alwaysCLAIMED;enqueuereturned the same already-due command, so the positive path had duplicate due work; the frozen plan dates were inconsistent; and theappend_eventreturn value ofNonewas not verified. These are diagnostic facts, not a request to copy the previous human repair.Regenerate and implement the smallest fix in the two allowed files against the supplied baseline. The positive test must exercise the real path from an initially
QUEUEDcommand to one claim, use an independent future command for the new signal, and use the frozen plan date transition2026-09-10to2026-09-11with the correct marker key. It must verify the actual marker/prior-report reads, final stateCANCELLED, exactly one claim, and zero orders.Keep negative cases independent and verify they actually read the evidence, remain
CLAIMED, emit no close event, and submit zero orders. Cover marker-missing/prior-report-present behavior. If evidence reads fail, orappend_eventreturnsNone, do not claim closure; preserve the unresolved/claimed state and emit the existing warning behavior without inventing a new return protocol.Return targeted edits against the supplied baseline. The bridge, not this model session, applies the patch and runs the pinned offline tests; do not claim test execution or results yourself. Do not claim AI success from a human patch, do not call another model, do not dispatch production work, and do not merge or publish.