cmd/loop: bless text-only session updates

Add an env-gated bless mode to recorded-session replay so
CLI-only text changes can refresh fixtures without a live
recording pass. The replay still uses the recorded gRPC
traffic, stdin, and environment, and it only rewrites
stdout, stderr, and run_error after the command preserves
the recorded success or failure shape.

Keep the updater strict by refusing to bless sessions when
replay leaves recorded gRPC events unconsumed, and add
focused tests for the rewrite rules. Document the bless
workflow next to the session fixtures, including the need
for -count=1 so the Go test cache does not skip updates.
This commit is contained in:
Boris Nagaev 2026-05-04 01:23:05 -05:00
parent e6e3820a76
commit ca1ce698f0
No known key found for this signature in database
3 changed files with 716 additions and 10 deletions

View file

@ -45,6 +45,18 @@ Base URL: `http://127.0.0.1:12345`
- Session replay now clones the CLI command tree per run, so flag state (`IsSet`) does not leak between sessions.
- Historical warning: earlier replays could have sticky flags across runs; if you see odd ordering-dependent failures, re-check that the replay uses the cloned command path.
## Bless mode for CLI text changes
- Use `LOOP_UPDATE_RECORDED_SESSIONS=true` to let `TestRecordedSessions` rewrite recorded `stdout`, `stderr`, and `run_error` values after a successful offline replay.
- Always run bless mode with `-count=1` so the Go test cache does not skip the update:
- `LOOP_UPDATE_RECORDED_SESSIONS=true go test ./cmd/loop -run TestRecordedSessions -count=1 -v`
- You can target a narrower subset with `-run`, for example:
- `LOOP_UPDATE_RECORDED_SESSIONS=true go test ./cmd/loop -run 'TestRecordedSessions/static-openchannel' -count=1 -v`
- Bless mode is intentionally narrow:
- it reuses the recorded gRPC stream, stdin, and env,
- it refuses to bless a session if the command changes from success to failure or vice versa,
- and it refuses to bless a session if replay no longer consumes the same recorded gRPC interaction.
- Use live recording, not bless mode, when a commands behavior or RPC flow changed.
## Session coverage map
| Subdir | Commands / scenarios |
| --- | --- |