Skip to content

golive: keep fork features as they are across a fork-to-fork switch - #557

Merged
scuttletoby merged 4 commits into
mainfrom
fix/golive-529-features-unchanged
Nov 20, 2026
Merged

scuttletoby merged 4 commits into
mainfrom
fix/golive-529-features-unchanged

Conversation

@scuttletoby

@scuttletoby scuttletoby commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

BASE main
Fixes #529

Not stacked. This PR is rebased onto main, which now includes #554, and merges cleanly with #556. A patch-id comparison shows that only this PR's own commits came over.

What

The kit treated "every fork feature off" as a fixed rule in four places: check, the switch's before step, verify, and the rehearsal's R4. So once any fork feature was switched on, no later fork release could go live through the kit. This PR does points (1) and (2) of the issue.

  • check records the whole feature state from the staged build's report on the live home, as features: each value, the names on, and where each one is on, all sorted. A report without the list or the values refuses. While the live build is upstream (its version has no .fork.N: the first switch), every feature must still be off. While it is a fork build, check also runs the live build's own report beside the running T3, and refuses before anything stops unless both builds read the same values in the same places. The refusal names each feature that differs, for example a new feature on by default, or usagePacingGate advise → enforce. A live fork build that gives no report this kit reads passes only with all off.
  • switch reads the features again just before the stop, with both builds, beside the running T3 (as check does, with server_changed after the read). If anything changed since the check, it refuses with T3 still running. before and verify then require exactly the check's full state, not an empty one.
  • rehearse has a new features-off step after the preflight. It switches every feature that is on off in the clone's settings.json only (never in the live home or the copy; the restore puts the copy's file back). It then needs a report that says all off before any server starts. A feature the machine's policy keeps on, or a settings.json that is not plain JSON, fails the run before R2 and names it. The result records what was switched off and where (featuresOff).

Point (3), the update path: this PR keeps the kit as the path for fork-to-fork updates. The alternative is to let a fork build that is already live update itself with upstream's t3 update, or with the fork's automaticUpdates (fork #5). That would skip the kit's check, copy, rehearsal and put-back. It is left as a later choice.

State question (tests)

  • Runs again: a switch refused because a feature changed since the check goes through on the next run once the check is run again. A second rehearsal switches the copy's features off in its new clone again and gets the same result.
  • Stopped half-way: a rehearsal killed at the features-off step, or in the middle of writing the clone's settings, runs again cleanly, and nothing needs settling (StoppedHalfWay covers both points).
  • Old, empty or missing state: all off is recorded as [] and passes. A report with no featuresOn list refuses in check, in the switch and in the rehearsal. A missing settings.json with a feature the policy keeps on fails, and names it.

Follow-ups (not in this PR)

  • The rehearsal record's featuresOff is not compared with the switch's features (lens A 3). A rehearsal always runs with every feature off, so it never covers the set that goes live. The README now says so.
  • Point (3) of the issue, the update path (above).

General vs project

Everything here is general to the kit: the fork report's featuresOn and featuresWhere, the .fork.N version form, and the clone's settings.json. Nothing names a machine, a project or a feature; the tests use made-up feature lists.

Old code

Test On main's lib (back, check, live, rehearse, switch)
check ForkFeatures (fork build, features on) fails: refused with fork features off
switch FirstSwitchFeatures (feature switched on after the check) fails: caught only after T3 stopped, then T3 is put back
switch ForkFeatures (verify, before with features on) fail: unchanged features that are on are flagged
rehearse FeaturesOff fail: R4 fails with fork features on, nothing switched off in the clone
live.fork_build, rehearse._features_off missing on main

I ran these against main's lib files with the new tests and fixture. All golive suites pass on this branch: back, check, contract, copy, gap, journal, rehearse and switch.

🤖 Generated with Claude Code

@scuttletoby

Copy link
Copy Markdown
Owner Author

Review (lens A)

Verdict: one BLOCKING finding. A fork-to-fork switch can go live with features changed, because "unchanged" is measured only with the target build, and only by feature name.

Checked: check, switch (features_changed, _before, _look), rehearse (features-off, _off_in), live, and upstream forkReport.ts. check, switch and rehearse all pass on the branch (74 / 106 / 94 tests). With main's check.py, ForkFeatures fails or errors, as the body says.

BLOCKING

  1. lib/golive/check.py:263-270 and switch.py:262,546: nothing compares the target with what the live build has on, and only the names are compared.
    • (a) check, features_changed, before and verify all read featuresOn from the staged target build's report on the live home. t3-golive: later switches refuse once fork features are on #529 point 1 asks for the live build's list. In a fork-to-fork switch, take a feature the target reads as on while the live build reads it as off. Examples: a new feature whose default is on, a policy default or lock that changed, or a settings key the old build ignored and the new build honours. check records it, before and verify then require it, and the switch goes live with that feature newly on, with no refusal. The old rule ("all off") could never do this.
    • (b) featuresOn holds names only. forkReport.ts lists usagePacingGate (and modelPolicy) as "on" for any value except off. So advise → enforce (design §4.7 stages exactly this one) passes check, before and verify as "unchanged". So does a change of the places a feature is on (featuresWhere: which projects or threads).
    • Fix: when the live build is a fork build, check also runs the live binary's __fork-report and refuses unless fork.features (the whole name→value map, not the names) and featuresWhere match the staged build's view. Then carry that map, not the name list, into features_changed, _before and _look. If an older fork build cannot give a report of this kit's REPORT_VERSION, refuse unless every feature is off (the safe side).

MINOR

  1. switch.py:546 and _look: the lists are compared in order. That is fine today (Object.entries gives a fixed order), but comparing sorted() lists, or the map from finding 1, would not depend on it.
  2. Rehearsal: R3 now always runs the target with every feature off, so a passed rehearsal never exercised the configuration that will go live (for example waitFor on, against the migrated database). That is a fair trade for not acting on the copy, but the README's rehearsal section should say so. Also featuresOff in the record is not compared with the switch's featuresOn: if they differ, the rehearsal did not cover the switch's set.

On the brief's question, does the rehearsal touch the live home's settings? No. _features_off writes only p['home']/userdata/settings.json (the clone, which R0 has proved has no links out). It refuses a symlinked settings.json, writes via a temp file and os.replace (a new inode, so a hardlinked copy is never written through), and the restore puts the copy's file back before only a preflight runs. The settings sum is now taken after the edit, so R5's "settings.json changed" check still compares like with like.

State question:

  • Runs again: a refused switch passes once check is rerun, and a second rehearsal edits its fresh clone again.
  • Stops half-way: the features-off temp file is in the clone, which is redone.
  • Missing or empty state: a missing settings.json with a policy feature fails with its name, and all off is recorded as [].
  • A report with no list refuses everywhere. That is fine.

@scuttletoby

Copy link
Copy Markdown
Owner Author

Review (lens B)

Head 5162b5b. Read #529, the diff and the body; ran all golive suites on this head. Mutation check: I removed the new features_changed re-read before the stop in _switch_on. ForkFeatures.test_features_changed_since_the_check_refuse_with_t3_running_and_a_rerun_goes (both subtests) and FirstSwitchFeatures.test_a_feature_switched_on_since_the_check_refuses_before_the_stop then fail. The tests do test the fix.

Brief questions:

  • Does the rehearsal touch the live home's settings? No. _features_off writes only <rehearsal root>/home/userdata/settings.json, after _r0_clone has checked that nothing in the clone leads to the live T3. It refuses a symlinked file, and writes a temp file plus os.replace, so a hard-linked clone file is replaced, not written through. A kill mid-write leaves only a temp file in the clone, and the next rehearsal makes a new clone. R5's settings.json sum is taken after the step.
  • Can a fork-to-fork switch go live with features changed? Not by a change in settings: check, the re-read before the stop, before and verify all compare the same list. But see 1.

BLOCKING

1. "Unchanged" is read by the target build only, never by the build that is live. lib/golive/check.py:190 and :263-270.
check records featuresOn from the staged target's __fork-report on the live home. before and verify use the target too. So the list is "what the target build would switch on", not "what is on now". Compare the live fork build's own report, which this PR does not.
Failure: the live build is …fork.1 with agentSlots on. …fork.2 adds feature X that is on by default, or reads a renamed or migrated settings key, or a changed policy default, and so reads X as on. Check records ['agentSlots', 'X'] and passes; the re-read, before and verify all agree. The switch goes live with X newly on. The rehearsal, which now runs with everything off, never ran X either. Before this PR, "all off" would have refused it. The first-switch rule catches it only on the first switch.
Fix: when live.fork_build(live version), also run the live build's own __fork-report (its kept runtime binary) beside the running T3. Refuse in check when its list differs from the target's, and name the features that differ, e.g. "the target would switch on X that is off today". Then "unchanged" means unchanged across builds. A test: a fixture where the live build's report says ['agentSlots'] and the target's says ['agentSlots', 'X'] must refuse.

MINOR

  1. The rehearsal does not test the feature set that goes live. It now always runs the target with every feature off, so the first time the target runs with the features that will be on is on the live home. That is what t3-golive: later switches refuse once fork features are on #529 (2) asked for, and the right trade. Say it in the README's rehearsal section so nobody reads a passed rehearsal as having tested waitFor and the rest.
  2. The feature lists are compared in order. before['featuresOn'] and verify use exact list equality. Today the same build gives the same order, so it is fine, but a target whose report order is not stable would trip a false verify failure and an automatic W1. Comparing sorted() lists costs nothing.

State question: a switch refused for a changed list changes nothing and a rerun goes through (tested). A rehearsal killed at features-off reruns cleanly (tested). A missing or empty settings file reads as all off. A report without the list refuses in all three places. A non-dict settings.json with features on fails before any server. Merges cleanly with #554 and #556.

Verdict: NOT SAFE until 1 is fixed. I rank 1 blocking because fork-to-fork switches are this PR's whole purpose, and main refuses that case today. The first switch, from upstream with all features off, is not affected.

scuttletoby and others added 3 commits November 20, 2026 00:47
check recorded "all off" as a hard rule in four places (check, the switch's
before step, verify, the rehearsal's R4), so once any fork feature was on
no later fork release could go live through the kit.

- check records the staged build's featuresOn list in its result. While
  the live build is upstream (the first switch) every feature must still be
  off; a report without the list refuses.
- switch reads the list again just before the stop (beside the running T3,
  as check does) and refuses with T3 running when it changed; before and
  verify require exactly the check's list.
- rehearse switches every feature that is on off in the clone's
  settings.json only (never the home's or the copy's; the restore puts the
  copy's back), requires a report that says all off before any server
  starts, and records what it did in a features-off step and the result.

Fixes #529

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ad the same (#529)

check now also runs the live fork build's own report beside the running T3 and compares
the whole feature state (each value, the names on, where) with the staged target's,
order-independently. A difference refuses before anything stops, naming each feature.
A live fork build without a readable report passes only with all off. The switch's
re-read before the stop, `before` and verify compare the same full state. The README
says a rehearsal never runs the target with the features that go live.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scuttletoby
scuttletoby force-pushed the fix/golive-529-features-unchanged branch from 5162b5b to 383a11d Compare November 20, 2026 00:51
@scuttletoby

Copy link
Copy Markdown
Owner Author

Fix round

Head 383a11d9c1. Rebased onto main (which now includes #554) with --onto origin/main df35246. The patch-ids match, so only this PR's commits came over. It merges cleanly with #556.

Item Change Test On the old code
BLOCKING (A+B) (a): "unchanged" was measured only with the target build When the live build is a fork build, check.features_answer also runs the live build's own __fork-report (the live server's binary, beside the running T3, before server_changed). It refuses before anything stops unless both builds read the same, and names each feature that differs. A live fork build with no readable report (another report version, none at all, no list) passes only with all off check ForkFeatures: test_a_feature_the_target_reads_on_and_the_live_build_off_refuses_before_anything_stops (live [agentSlots, waitFor], target adds newThing), …_reads_off_and_the_live_build_on_refuses_too, test_a_live_build_without_a_report_of_its_own (no report, reportVersion: 2, not JSON, no list; all off passes); switch test_a_target_that_reads_other_features_than_the_live_build_refuses_with_t3_running all fail: check passes, and the switch is not refused
BLOCKING (b): only names were compared New live.features_state holds the full map: values (from fork.features), sorted on, and sorted where. check, the re-read before the stop (now by both builds), before and verify all compare this state. A report without fork.features refuses test_a_value_change_with_the_same_names_on_refuses (usagePacingGate advise → enforce), test_a_change_of_where_a_feature_is_on_refuses, test_a_target_report_without_the_features_map_refuses; switch test_the_live_build_reading_another_set_since_the_check_refuses_before_the_stop; verify subtest (usagePacingGate off → advise) fail: not refused
MINOR A2 / B3: lists compared in order The state is sorted test_order_alone_is_no_change; the verify test reorders the list —
MINOR A3 / B2: the rehearsal never runs the feature set that goes live README (features-off step): a passed rehearsal says nothing about the features that go live; the switch's verify is their first run docs —

The rest are listed as follow-ups in the PR body: comparing featuresOff with the switch's set, and point (3).

State question:

  • Rerun: a refusal changes nothing; once the owner sets the feature the same for both builds, the rerun passes (test_a_refusal_changes_nothing_and_a_rerun_passes_once_both_builds_agree, and the switch rerun keeps enforce).
  • Stopped half-way: a change after the check refuses before the stop; a change while T3 is stopped starts the old build again.
  • Old state: an older live fork build without a report passes only with all off.
  • Empty state: all off is recorded as an empty state.
  • Missing state: a report without the list or the map refuses.

Suites on this head, all OK: back 106, check 82, contract 5, copy 108, gap 29, journal 29, rehearse 94, switch 108. To get the old-code results, I ran the new tests and fixture against this branch's lib from before the fix commit: check ForkFeatures 7 failures and 3 errors; switch ForkFeatures, FirstSwitchFeatures and WayBack 9 failures (Refused not raised for the new blocking cases).

@scuttletoby
scuttletoby merged commit afc41d0 into main Nov 20, 2026
27 checks passed
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.

t3-golive: later switches refuse once fork features are on

1 participant