test(manifest): keep the rule-manifest test able to catch a keel init reseed - #173
Merged
Conversation
… reseed PR #172 landed the live DCA rule's `budget_usd` 25 -> 50, aligning the manifest with `config.dca.budget_usd` -- the value the live executor actually spends, since `executor._build_intent` ignores the rule row's own `budget_usd` entirely. That alignment silently WEAKENED the test that came with it. `test_committed_manifest_is_valid` now asserts manifest == config, but 50 is also `Dca.__init__`'s constructor default, and `deploy/live-rules.json`'s DCA params are now EXACTLY the constructor defaults. So the scenario the test originally existed to catch -- `keel init` on a fresh box silently reseeding every rule from constructor defaults, discarding an operator's tuned value, with nothing erroring -- now passes green. The values can no longer tell a correctly-provisioned box from a reseeded one. Asserting "the value is not merely the constructor default" is impossible here: the operator's intended value IS the default. So this restores the guard using the one thing that still discriminates -- `keel init` always seeds at `candidate`, and every rule in the committed manifest is `live` -- and pins the coincidence itself, so that if the budget ever moves off the default the value check regains its power and the pin is what says so. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
eaitbrahim
force-pushed
the
fix/live-dca-budget-50
branch
from
August 6, 2026 22:54
c4fdc61 to
7366d03
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is now
This PR started life as the
deploy/live-rules.jsonDCAbudget_usd25 -> 50 change, split out of #172. #172 was merged and carried that change in, so the value edit, theexecutor.pycomment and the prose are all onmainalready. Rebased ontoorigin/main, what remains is the one thing #172 did not land: repairing the test it silently weakened.The problem
#172replaced this assertion intest_committed_manifest_is_valid:with a check that the manifest's budget equals
config.dca.budget_usd. Checking agreement rather than a literal is the right instinct — a hardcoded number there just re-creates the drift it is meant to catch, one deploy later.But it lost something. The original assertion guarded a specific, real failure:
keel initon a fresh box seeds every rule atcandidatefrom each rule kind's constructor defaults, silently discarding any parameter an operator tuned by hand, on a box that otherwise looks correctly provisioned. Nothing errors.50is alsoDca.__init__'s constructor default. Anddeploy/live-rules.json's DCA params are now exactly the four constructor defaults:Dca.__init__defaultcadence_daysbudget_usdDecimal("50")dip_bonus_pctDecimal("0")lookback_daysSo "manifest agrees with config" is satisfied both by a correctly-provisioned deployment and by one that
keel initquietly reseeded. The values cannot tell those two states apart any more.Why I did not do what was asked literally
The instruction was to assert "the value is not merely the constructor default". That is impossible to satisfy honestly — the operator's intended budget is the constructor default. Any assertion of that form would either be false or would require moving
Dca's default away from 50 to suit a test, which changes library semantics for a test's convenience. So the guard is restored a different way.What the test asserts now
budget_usd==config.live-sandbox.yaml'sdca.budget_usd, parsed from the file, not hardcoded. This is the value the executor actually spends.live, and no rule in the manifest iscandidate. This is the only discriminator assertion (1) leaves standing:keel initalways seeds atcandidateregardless of what the params say.Dca(product_id=...).describe()["params"]. If the operator ever moves the budget off the default, this is what fails, and its message explains that the failure is good news: assertion (1) has regained the ability to catch a reseed on its own, and (2) is no longer the last line of defence.Verification
Each assertion was confirmed to fail for the right reason, by mutating the committed manifest and reverting:
candidate:AssertionError: the live DCA rule is not status=live -- if this is a candidate, keel init likely reseeded it from Dca's constructor defaults...budget_usd->"25":AssertionError: the live DCA rule's budget_usd must match config.dca.budget_usd... assert Decimal('25') == Decimal('50')cadence_days->14: trips assertion (3) with the "reasoning behind assertion (2) no longer applies" message.ruff,pytestandmypyclean.🤖 Generated with Claude Code