gunk-dev/the-valley
the-valley:oc-c5aacccoutcomeopen

The agent-run client is valley flow, and writes no klaus name

State
free to start
Created
2026-11-22 by contributor
Changes
  • valley:the-valley/nwouumplynzkzrsyuxkqtwrmvrxqwtrw

Body

The agent-run client in `flow/` is reached as `valley flow <args>`, and no name it writes carries `klaus`.

Operator decisions: the command is `valley flow`; state lives under `.valley` (flow's files under `.valley/flow/`), not `.klaus`; the Unix account a deployment runs it under is out of scope.

Design, after a cross-model critique against the code:

- `valley` stays stdlib-only. `valley flow` execs a separate program `valley-flow` found on PATH (not beside the binary: the packaged `valley` is wrapped, and the helper updates independently), passing the arguments after `flow`, stdio and exit status through.
- Stage 1 is additive. The package attribute `klaus` and `bin/klaus` stay, because the installed self-update builds that attribute and runs that binary, live panes embed a later `klaus _finalize`, and dashboards restart onto `klaus` on PATH. The same package gains `bin/valley-flow`. Flow names itself by how it was invoked. Nothing persistent changes.
- Stage 2, text: docs, prompts and messages say `valley flow`, once consumers carry a `valley` that dispatches it.
- Stage 3, persistent names, each with its own rule rather than a blanket read-old/write-new:
  - config and prompt files fall back per file, keeping host/project precedence;
  - sessions are enumerated from both roots and an existing session keeps its directory (records hold absolute worktree, log and clone paths; memory has absolute symlinks), so no bare move of the old directory;
  - locks keep one path for as long as old and new processes can coexist;
  - the conversation ref falls back per requested blob, and a new ref name needs the host to authorize it first (the hook rejects `refs/the-valley/*` pushes today, and finalize discards that push error);
  - readers of new environment names, labels and trailers ship before writers of them;
  - also to cover: `klaus_exit`, the `klaus-check-completed:` stream line, `.git/klaus`, `klaus-continue.lock`, the hook file `klaus.config` and its keys, the default temporary worktree root.
- Stage 4, consumers switch and the old names with nothing left to read are removed; trailer and conversation-ref reads stay. Removal accounts for rollback and for machines that skip releases.

Each stage needs an old-session → update → finalize and dashboard restart → rollback test through the packaged entry points.

Comments

  1. contributor2026-11-22 03:24 UTC
    Change valley:the-valley/nwouumplynzkzrsyuxkqtwrmvrxqwtrw landed: v2 as ccb7354855a5d31ca49641637a44f079c16a7ca0.
    
    Every change the knot links has landed and it has no active children, so klaus set it done.
  2. contributor2026-11-22 03:24 UTC
    Stage 1 of four landed as ccb7354 (valley flow dispatch, additive). Stages 2 to 4 remain: text, persistent names, consumers and removal. Launch later stages without naming this knot as the issue, or the landing closes it.
  3. contributor2026-11-22 14:24 UTC
    Stage 2 (text) is ready as sryk. Left for stage 3, from the independent review of its head: error prefixes that still print the old command name (flow/internal/cmd/restack_conflicts.go:214,216; flow/internal/pipeline/pipeline.go:693,713), and the prompt line and parser for the hidden pre-review command (stream.RunsPreReview matches only the old spelling, so the prompt was left). Stage 2 also reworded human-readable reasons that are stored in records and events (restack refusals, the review lock error); nothing compares their wording.
  4. contributor2026-11-22 14:50 UTC
    Stage 3 design (persistent names), part 1 of 3: names table, first half. Authored by an independent model against main at 30e24c8. Rows marked keep are proposals awaiting the operator.
    
    Moving declarations and newly created state to `.valley/flow` gives flow a coherent namespace without relocating live work. A reader-first rollout can preserve running sessions and rollback while leaving costly historical protocols stable.
    
    This is proposed behaviour, not built. R means the reader bridge, W the writer cutover, and P the publication-error fix. Existing records and conversations are never rewritten merely to replace a name.
    
    | Old name | New name or decision | Writers → readers; evidence at HEAD | Compatibility, order and retirement |
    |---|---|---|---|
    | `~/.klaus/config.json` | `~/.valley/flow/config.json` | `init` and operator → commands, including updater. `flow/internal/config/config.go:533`; `flow/internal/cmd/self_update.go:77` | R reads new file first, falling back only when absent. Preserve host/project precedence and host-only settings. W scaffolds new files; migrate an existing complete file only after old config readers are retired. Keep fallback while supported installations retain it. |
    | `~/.klaus/projects.json` | `~/.valley/flow/projects.json` | Project commands and scaffolding → project resolution and sync. `flow/internal/project/registry.go:25`; `flow/internal/project/registry.go:102`; `flow/internal/cmd/new.go:154` | One writable registry, never two copies. R remembers and writes the selected location. Existing registry stays there until its writers are stopped for cutover. Refuse independent registries at both paths rather than silently losing updates. |
    | `~/.klaus/sessions/**` | `~/.valley/flow/sessions/**` for new sessions | Coordinator, launch, finalize, dashboard, watches, jobs and consults → their corresponding readers. `flow/internal/run/homedir_store.go:25`; `flow/internal/cmd/watch.go:242`; `flow/internal/cmd/report.go:114` | R enumerates both roots and resolves each session ID to one directory. Every child file stays with that directory, including runs, logs, events, prompts, workspaces, jobs, consults, ledgers, scratch and locks. W creates new sessions under the new root. Old-session writes continue for that session’s lifetime, including later resumes. Remove legacy discovery only when no retained session needs it. |
    | Persisted paths inside session/run records | Keep their values | Launch/coordinator → resume, finalize, cleanup and replay. `flow/internal/run/run.go:23`; `flow/internal/run/run.go:33`; `flow/internal/cmd/session.go:193`; `flow/internal/cmd/replay.go:68` | Never substitute `.klaus` inside stored paths. Worktrees, logs, clones and backend conversation locations have identities beyond the directory spelling. No retirement through this rename. |
    | `~/.klaus/memory/` | `~/.valley/flow/memory/` | Backend memory writers; flow creates links → coordinators. `flow/internal/config/config.go:1155`; `flow/internal/config/config.go:1188` | Keep one shared directory while coordinators coexist. R selects the existing directory. Move it only with memory writers stopped; preserve the old target as an alias until persisted backend links are repaired. Do not start a second empty memory directory. |
    | `~/.klaus/consult-snapshots/` | `~/.valley/flow/consult-snapshots/` | One-shot consult → backend and cleanup using returned paths. `flow/internal/cmd/consult_snapshot.go:69` | W changes allocation only. In-flight consults finish and clean up their original paths. No fallback search or migration is needed for this transient allocation root. |
    | `~/.klaus/sync.log` | `~/.valley/flow/sync.log` | Background and explicit sync → operator; code appends. `flow/internal/projectsync/log.go:25` | W appends new invocations to the new file. Old producers may finish appending to the old file. Document both during coexistence; do not concatenate or duplicate records automatically. Retain old history independently of executable removal. |
    | `~/.klaus/locks/` | Keep the legacy coordination path | Reviews → other reviews. `flow/internal/cmd/review.go:195`; `flow/internal/review/lock.go:16` | All versions use the same lock files. Do not apply state-root fallback to locks. Keeping this small compatibility anchor permanently costs less than another lock-transition protocol. Session-local locks remain inside their pinned session directories. |
    | `$XDG_STATE_HOME/klaus/self-update.json`, otherwise `~/.local/state/klaus/self-update.json` | `~/.valley/flow/self-update.json` | Update, pin and rollback → subsequent updater invocations. `flow/internal/selfupdate/selfupdate.go:77`; `flow/internal/selfupdate/selfupdate.go:190`; `flow/internal/selfupdate/selfupdate.go:283` | R reads either location and preserves `current`, `previous`, `failed` and `pinned`. Keep one writable state file. Resolve its location after acquiring the shared updater lock. Move only after pre-R updater invocations and fallback installations are retired; R must support rollback after that move. |
    | Legacy `self-update.lock` | Keep its current XDG-derived path | Every updater operation → competing updater operations. `flow/internal/selfupdate/selfupdate.go:479` | Separate lock location from JSON location. All versions retain the same lock inode/path; never delete or relocate a held lock. Keep permanently as a coordination anchor. |
    | `.git/klaus/{runs,logs,prompts}` | Keep | Project scaffolding → its state/log consumers. `flow/internal/cmd/new.go:175`; `flow/internal/run/store.go:113`; `flow/internal/cmd/new.go:185` | This is a separate `GitDirStore`, not a home session. Moving it into home storage requires a standalone-run storage design. Retain this bounded exception rather than inventing repository identities for a cosmetic rename. |
    | `<project>/.klaus/config.json` | `<project>/.valley/flow/config.json` | `init` and project author → config loader. `flow/internal/config/config.go:441`; `flow/internal/config/config.go:506` | R reads new-first per file, then old. Keep defaults → host → project precedence and the host-only `forbidden_terms` boundary. W changes scaffolding after readers ship. Project migration is a source change; retain fallback for older project revisions and supported clients. |
    | `<project>/.klaus/prompt.md` | `<project>/.valley/flow/prompt.md` | `init`/project author → worker prompt renderer. `flow/internal/config/config.go:501`; `flow/internal/config/config.go:523` | R reads both, new-first only on file presence; malformed/unreadable new files are errors. W scaffolds the new location without overwriting an existing custom template. Old reads remain while supported checkouts use them. |
    | `<project>/.klaus/pr-fix-prompt.md` | `<project>/.valley/flow/pr-fix-prompt.md` | Project author → follow-up prompt renderer. `flow/internal/config/config.go:635`; `flow/internal/config/config.go:1338` | Same per-file reader-first rule. Existing agents retain their already-rendered prompts; no rewrite of saved prompts. |
    | `<project>/.klaus/session-prompt.md` | `<project>/.valley/flow/session-prompt.md` | Project author → coordinator prompt renderer. `flow/internal/config/config.go:1032` | R before project writer migration. Existing coordinator instructions remain valid through the retained command aliases. Keep old reads for retained project versions. |
    | `<project>/.klaus/principles.md` | `<project>/.valley/flow/principles.md` | Project author → scaffolding. `flow/internal/config/config.go:1326`; `flow/internal/cmd/new.go:29` | R reads both before projects move it. Missing files retain the existing built-in default; a bad new file must not silently select old principles. |
    | `~/.klaus/prompt.md`; project `context.md` | No new flow interface | There is no dedicated global-prompt or `context.md` discovery interface in the audited code. The prompt loader uses a supplied repository root and named template file. `flow/internal/config/config.go:1338` | Do not invent migration code for these proposed rows. External includes or tools must be audited in consuming projects and moved by their owners. |
    | `refs/klaus/data` | Keep permanently | Finalize/`push-log` → replay; optionally the remote host. `flow/internal/cmd/hidden.go:1189`; `flow/internal/cmd/pushlog.go:67`; `flow/internal/cmd/replay.go:269` | P fixes publication diagnostics. Keep the existing default and honour explicit `data_ref` unchanged. Avoid parallel histories, dual pushes and permanent per-blob fallback solely for spelling. Host authorization is discussed below. |
    | `refs/klaus/client` | No production name to migrate | The occurrence is the test ref `refs/klaus/client-test`. `flow/internal/git/client_test.go:45` | Do not create a production compatibility promise from a fixture. The test ref may become `refs/test/client` with its test. |
    | `Klaus-Run:` | Keep permanently | Provenance helper and installed commit hook → audit readers. `flow/internal/git/git.go:717`; `flow/internal/git/git.go:767` | Immutable history and installed hooks already carry this contract. No host parser for this trailer was found in the audited tree. Avoid dual trailers and an unsupported claim that all external readers have upgraded. |
    | `KLAUS_SESSION_ID` | `VALLEY_FLOW_SESSION_ID` | Coordinator/pane command → session store, dashboard, watch and launch. `flow/internal/cmd/session.go:399`; `flow/internal/cmd/store_helper.go:15`; `flow/internal/cmd/launch.go:1633` | R reads both; W exports both with identical values. Retire old exports only after every reachable helper understands the new variable. Retire old reads only after old coordinators, panes and external launchers stop exporting it. |
    | `KLAUS_RUN_ID` | `VALLEY_FLOW_RUN_ID` | Local/remote pane command → stream and pre-review event attribution. `flow/internal/cmd/runevents.go:25`; `flow/internal/cmd/runevents.go:37`; `flow/internal/cmd/runevents.go:297` | R reads both; W exports both. Preserve attribution when an old formatter remains alive. Retirement includes sandbox helpers and old pane command strings. |
    | `KLAUS_RUN_EVENTS` | `VALLEY_FLOW_RUN_EVENTS` | Remote launch → pre-review output routing. `flow/internal/cmd/runevents.go:32`; `flow/internal/cmd/runevents.go:43`; `flow/internal/cmd/pre_review.go:215` | R reads both; W exports both. Keep the value `output` unchanged. Remove old exports/reads only after both remote producers and local stream consumers have crossed R. |
    | `KLAUS_BACKEND` | `VALLEY_FLOW_BACKEND` | Coordinator/worker launch → consult selection and review author identification. `flow/internal/cmd/session.go:453`; `flow/internal/cmd/launch.go:1369`; `flow/internal/cmd/consult.go:265`; `flow/internal/cmd/pre_review.go:124` | R reads both; W exports both. Explicit new values override inherited old values; child environments must contain matching aliases. Keep old reads while old backend processes can launch helpers. |
    | `KLAUS_AGENT_BACKEND` | `VALLEY_FLOW_AGENT_BACKEND` | Coordinator → worker-backend resolver. `flow/internal/cmd/session.go:453`; `flow/internal/cmd/backend.go:13` | R reads both without changing flag/saved-state/environment/config precedence. W exports both. Retirement requires old coordinators and launch scripts to be gone. |
  5. contributor2026-11-22 14:50 UTC
    Stage 3 design, part 3 of 3: rules, the three changes (R reader bridge, P publication errors, W writer cutover), and tests.
    
    R must centralise location resolution before changing writers. Session lookup, latest-session selection, reporting, watching and run discovery must all use it. Deduplicate two paths to the same physical directory; refuse two independent directories claiming the same session ID. Unknown sessions must fail lookup rather than silently create an empty replacement. For mutable singleton files, write back to the selected location; do not turn a fallback read into an implicit copy.
    
    Environment aliases need one precise rule: use the new variable when present, otherwise the old variable, preserving an explicitly empty value. When launching children, remove inherited duplicates and export matching aliases. `$TMUX` retains precedence over both socket variables. This avoids a new command interpreting one session while its old child interprets another.
    
    Use three changes. R adds readers, location resolution and command recognition, with legacy allocation defaults. P makes failed data publication observable and can land in parallel with R. W changes new allocations, environment exports, scaffolding and descriptive text after R has soaked. The cosmetic rows belong in W, not separate changes.
    
    Writer activation must be explicit because following main can skip releases. Add a temporary, host-only `storage_layout` setting: `legacy` by default during stage 3, `flow` to activate W’s new allocation roots. Read it from host configuration, never project configuration. Before activation, install R or later on continuing launchers, dashboards, sandbox helpers and fallback command paths, and ensure the rollback target supports R. Already-running backends and formatters may finish against their original session directories and retained protocols. Migrating shared config, registry, memory or updater state additionally requires their particular writers to be stopped; changing the allocation setting does not move them.
    
    The conversation ref is the proposed rename that would require host support first. `valleyhook/policy.go:163` refuses unrecognised `refs/the-valley/*` writes before ordinary grants apply. Keep `refs/klaus/data`: it is project storage, normally local, and optional publication uses the existing exact-ref named-grant mechanism at `valleyhook/policy.go:232`. A deployment choosing publication must authorize its named writer principals for that exact ref; do not open `refs/the-valley/*` or grant approval powers. Reject the alternative namespace rename because it adds host governance and dual-history handling without improving replay.
    
    P must replace the discarded error at `flow/internal/cmd/hidden.go:1242` with a durable publication result, surfaced by status/dashboard and a warning. Preserve the local scanned commit, finish normal finalization and distinguish publication failure from agent failure. Finalize currently continues to cleanup and kills its pane (`flow/internal/cmd/hidden.go:262`, `flow/internal/cmd/hidden.go:277`), so stderr alone is insufficient. Recovery should push the already-scanned ref after authorization/connectivity is repaired. Do not recommend rerunning finalize or `push-log` as conversation recovery: `push-log` stores run/log files and explicitly bypasses sensitivity checking (`flow/internal/cmd/pushlog.go:61`, `flow/internal/cmd/pushlog.go:70`).
    
    For R, extend the existing isolated lifecycle harness with predecessor and candidate binaries. Start a session, dashboard, worker and formatter under the predecessor; hold the backend on an event, install R, then release it. Assert finalization updates the original run, logs and event stream exactly once; dashboard restart retains tracking and ledger state; replay restores a conversation stored before the update; rollback to the predecessor works because new allocation remains disabled. Add focused tests for both-root enumeration, duplicate IDs, malformed new config, host-only settings, environment precedence and cross-version lock contention. The current harness builds one binary (`flow/e2e/e2e_test.go:22`); merely renaming its fixtures would not prove compatibility.
    
    For W, repeat that lifecycle with R as the rollback build, retaining an older worker/formatter in the original session. Activate the layout, create another session under the new root, and verify R and W both discover it while the original run finalizes in its original directory. Restart the dashboard R → W → R, checking events, budgets, jobs and dispatch ledgers rather than banner text. Replay the pre-cutover conversation; roll back and resume both sessions. Verify registry updates, updater pin/previous state and memory remain single-valued. Also test an update that skips R with activation absent: it must keep legacy allocation. Existing dashboard restart coverage provides the starting point (`flow/e2e/self_update_test.go:475`).
    
    For P, start the run before installation, reject its publication with a real receive policy, and finalize afterward. Assert the local conversation remains replayable, the publication failure survives pane termination/dashboard restart, and rollback still reads the run. Test exact-ref authorization and refusal of neighbouring refs. Use event/socket handshakes, not added sleeps; build comparison binaries once outside the tree. Run the checks named by `valley checks --names origin/main HEAD`, and `prose-format` for changed documentation.
    
    The chosen home and project roots are sound, but they cannot mean relocating every existing object immediately. Stored paths and backend memory links prevent a safe blanket `mv`; ended sessions can still be resumed. Keeping `.git/klaus` and legacy lock anchors is a deliberate exception worth making. Moving updater JSON into the chosen home root also changes its current XDG placement contract (`flow/internal/selfupdate/selfupdate.go:77`); document that explicitly and preserve legacy discovery. No Unix-account change is needed.
    
    The single most valuable change is explicit writer activation after the reader bridge is installed and available for rollback; soaking a source change alone does not establish that condition.
  6. contributor2026-11-22 14:50 UTC
    Stage 3 design, part 2 of 3: names table, second half.
    
    | Old name | New name or decision | Writers → readers; evidence at HEAD | Compatibility, order and retirement |
    |---|---|---|---|
    | `KLAUS_SCRATCH` | `VALLEY_FLOW_SCRATCH` | Worker environment → agents and repository tooling. `flow/internal/cmd/agent_pane.go:66`; `flow/internal/config/config.go:653`; `nix/tools/drv-churn.sh:81` | W exports both after R. Update generated instructions to the new variable. Keep the old export while older project checkouts contain tooling that reads it; binary-alias removal alone is insufficient. |
    | `KLAUS_TMUX_SOCKET` | `VALLEY_FLOW_TMUX_SOCKET` | Worker environment → flow’s tmux client. `flow/internal/cmd/agent_pane.go:68`; `flow/internal/tmux/tmux.go:32` | R reads both, preserving `$TMUX` precedence and worker isolation. W exports both. Retirement requires no old helpers or environments; test refusal to reach the wrong server. |
    | `KLAUS_TEST_TOOLS` | `VALLEY_FLOW_TEST_TOOLS` | Nix checks → test prerequisite guards. `nix/checks/flow.nix:68`; `flow/internal/tmux/tmux_test.go:171` | Update test readers first; then export both during transition. No runtime-session protocol. Stop old export once every check source being invoked supports the new name. |
    | `KLAUS_TEST_LEDGER_RACE_PATH`, `KLAUS_TEST_LEDGER_RACE_ID` | Corresponding `VALLEY_FLOW_*` names | Test parent → subprocess of that test binary. `flow/internal/pipeline/ledger_test.go:18` | Rename writer and reader together. No production compatibility code or retirement gate. |
    | `klaus-agents`, `klaus-agents-<id>` | Keep permanently | Pane creation → cleanup targeting. `flow/internal/cmd/agent_pane.go:25`; `flow/internal/cmd/agent_pane.go:118` | Stable internal identity avoids adding persisted naming versions or probing multiple live sessions. Rename the visible window title separately. |
    | `klaus:budget-paused` | Keep permanently | Budget pause/finalize → dashboard transitions and replay selection. `flow/internal/draft/draft.go:109`; `flow/internal/draft/draft.go:144`; `flow/internal/pipeline/transitions.go:780` | One canonical pause signal. Dual labels introduce stale-label reconciliation and old dashboards cannot recognise a new-only label. The cosmetic benefit does not justify that protocol. |
    | `klaus_exit` | Keep permanently | Installed pane shell → finalize’s log parser. `flow/internal/cmd/launch.go:1402`; `flow/internal/cmd/hidden.go:928` | This carries crash classification across process versions and saved logs. Keep one event, not dual events; retain the parser for historical logs. |
    | `klaus-check-completed:` | Keep permanently | Remote pre-review → local stream formatter. `flow/internal/cmd/pre_review.go:249`; `flow/internal/stream/checks.go:193` | Keep the transport prefix and emit once. Renaming it would couple upgrades across sandbox hosts and already-running formatters. |
    | `.git/klaus-continue.lock` | Keep permanently | Launch/continuation → competing launch and continuation operations. `flow/internal/cmd/takeover.go:77` | All versions lock the same file. A cosmetic rename must not allow concurrent ownership of the same work. |
    | Hook file `klaus.config` | Keep permanently | Hook installer → installed shell hooks. `flow/internal/git/git.go:726`; `flow/internal/git/git.go:752`; `flow/internal/git/git.go:864` | Installer and existing hooks retain one protocol. Avoid a file-and-script cutover with no user benefit. |
    | Hook keys `klaus.run`, `.changeid`, `.chaindir`, `.format` | Keep permanently | Hook installer → provenance, formatting and hook chaining. `flow/internal/git/git.go:753`; `flow/internal/git/git.go:790`; `flow/internal/git/git.go:868` | Keep alongside the hook file. No broad substitution of git configuration. |
    | Temporary worktree default `klaus-sessions` | `valley-flow-sessions` beneath `os.TempDir()` | Config default → new clone/worktree allocation. `flow/internal/config/config.go:414`; `flow/internal/cmd/launch.go:491`; `flow/internal/cmd/launch.go:520` | W changes new allocations only after R. Explicit `worktree_base` and stored clone/worktree paths win. Never move existing worktrees or infer their location from the new default. |
    | Fallback window title `klaus` | `flow` | Coordinator → human viewing tmux. Routing stores pane IDs. `flow/internal/cmd/session.go:374`; `flow/internal/cmd/session.go:385` | W changes newly assigned titles. No compatibility reader and no rewrite of existing sessions needed. |
    | WIP subjects and fallback draft title containing `klaus` | Same templates using `flow` | Budget pause/salvage → git/GitHub and humans. `flow/internal/draft/draft.go:97`; `flow/internal/draft/draft.go:325`; `flow/internal/cmd/hidden.go:719` | W changes future text only. Keep existing commits and titles untouched; no parser migration was found. |
    | `Initialize klaus run data` | `Initialize flow run data` | Data-ref initialization → git history. `flow/internal/git/git.go:505` | W changes new initialization commits only. Existing data-ref history remains unchanged. |
    | Knot comments containing `klaus` | New comments say `flow` | Flow knot bookkeeping → knot readers. `flow/internal/cmd/knot.go:214`; `flow/internal/cmd/knot.go:371` | W changes future prose only. Never edit historical comments as migration. |
    | Event `via: "klaus ready"` | `via: "valley flow ready"` | Ready command → reporting and event consumers. Writer: `flow/internal/cmd/ready.go:180`; reporting tests presence, not spelling: `flow/internal/report/report.go:495` | W writes canonical text once. Read historical values unchanged; do not normalise persisted events or duplicate them. |
    | Generated event `command: "klaus _pre-review"` | Canonical `valley flow _pre-review` | Pre-review → watches/reporting. `flow/internal/cmd/pre_review.go:214`; `flow/internal/cmd/watch.go:729` | W changes generated descriptive text. Preserve literal captured shell commands and old event values. Separately, R must teach `RunsPreReview` all supported executable spellings before generated invocations change; it currently recognises only `klaus`. `flow/internal/stream/checks.go:332`. |
    | `<!-- klaus-agent-reply -->` | Keep permanently | Review-fix agent → review detection. `flow/internal/pipeline/transitions.go:856`; `flow/internal/cmd/review_check.go:16` | Prevents agent replies becoming fresh trusted feedback. Historical comments and live agent prompts require the same marker. |
    | `<!-- klaus-actionable -->` | Keep permanently | Comment author → opt-in detection. `flow/internal/pipeline/transitions.go:869`; `flow/internal/cmd/review_check.go:25` | Keep existing user intent readable. No dual-marker protocol for a rename. |
    | `/klaus fix` | Keep permanently as a comment directive | Comment author → first-line opt-in detection. `flow/internal/pipeline/transitions.go:868`; `flow/internal/cmd/review_check.go:37` | This is a persisted comment language, not the executable name. Changing it introduces another accepted syntax without adding capability. |
    | `<!-- klaus-cross-review … -->` | Keep permanently | Review publisher → trust classification and round/repeat suppression. `flow/internal/review/pr.go:16`; `flow/internal/review/pr.go:176`; `flow/internal/cmd/review_check.go:104` | Keep historical reviews meaningful. A rename must not reset review budgets or lose duplicate suppression. |
    | Temporary prefixes `klaus-consult-*`, `klaus-consult-agy-*`, `klaus-prose-*`, `klaus-merge-*`, `klaus-review-*`, `klaus-pr-review-*`, `klaus-index-*` | Corresponding `valley-flow-*` prefixes | Allocator → consumers using the returned path. `flow/internal/backend/agy_readonly.go:20`; `flow/internal/consult/consult.go:65`; `flow/internal/prose/prose.go:404`; `flow/internal/cmd/pre_review_prose.go:103`; `flow/internal/cmd/merge.go:288`; `flow/internal/review/review.go:121`; `flow/internal/review/pr.go:113`; `flow/internal/git/git.go:527` | W changes future allocations. No discovery by these prefixes was found; existing processes retain their returned paths. No aliases or migration tests beyond existing lifecycle tests. |
    | Shell-local `klaus_backend_exit`; test temporary prefixes such as `klaus-tmux-*` | `flow_backend_exit`; `valley-flow-*` test prefixes | One generated shell snippet, or one test lifecycle. `flow/internal/cmd/launch.go:1402`; `flow/internal/tmux/tmuxtest/tmuxtest.go:23` | Writer and reader change together. Leave the `klaus_exit` wire value unchanged. No cross-version compatibility machinery. |
    | `klaus` executable, flake attribute, profile element, legacy version output and internal command strings | Keep through stage 4 | Package/updater and generated subprocess commands → old updaters, panes and dashboards. `nix/packages.nix:1216`; `flow/internal/selfupdate/selfupdate.go:33`; `flow/internal/selfupdate/selfupdate.go:385`; `flow/internal/cmd/launch.go:1370`; `flow/internal/cmd/dashboard_restart.go:104` | Preserve the existing package bridge. Stage 3 does not remove embedded `klaus _finalize` commands or alter the legacy smoke-test contract. Stage 4 needs its own reachable-binary and rollback audit. |
    | Nix derivation names containing `klaus` | Leave outside stage 3 | Package/check construction → Nix. `nix/packages.nix:1235`; `nix/checks/flow.nix:17`; `nix/checks/flow.nix:37` | These are build identities, not persisted flow state. Avoid rebuilding the dependency derivation merely for spelling. Required check names already use `flow-*`: `policy/project/policy.cue:97`. |
  7. contributor2026-11-22 17:10 UTC
    Operator decision on the stage 3 design: accept the rename and keep groups, with new commits carrying Flow-Run (both trailers read). The kept names are not kept for good: the design needs a strategy that evolves out of the old name eventually, so each kept name gets an exit path and a condition, not a permanent exception. The managed work Mac is out of scope for flow.
  8. contributor2026-11-22 17:25 UTC
    Stage 3 design amendment, part 1 of 3: exit path per kept name, first half. Supersedes "keep permanently" in the earlier table. Authored by an independent model against main at cfedff3.
    
    The R/P/W split preserves live sessions while moving compatibility work ahead of the naming changes. Preparing the complete transition in R can make W2 a controlled writer switch and final removal mostly deletion.
    
    The weak point is calling R a “reader bridge”: it must also continue writing an already-migrated store after rollback. A host setting cannot upgrade an old executable, an installed hook, or another machine publishing to the same repository.
    
    | Current → eventual name | What R prepares; present cost | Condition for switching writers | When the old reader can go |
    |---|---|---|---|
    | `refs/klaus/data` → `refs/the-valley/flow/data` | Resolve either store generation; support seeding the new ref from the old tip and continuing its history. Cost: one migration operation and two recognized ref names. Current initialization creates an unrelated empty history (`flow/internal/git/git.go:492`); replay reads one configured ref (`flow/internal/cmd/replay.go:269`). | **W2:** local tips reconciled, all publishers R-capable, host authorizes the exact new ref, old ref frozen, publication result verified. Local-only stores need no host grant. | **Never** for retained historical stores: keep one explicit legacy-ref resolver. Migrated stores read the new ref exclusively; no per-blob fallback. |
    | `<git-common-dir>/klaus-continue.lock` → `<git-common-dir>/valley/flow/continuation.lock` | Acquire both paths in fixed order. Cost: one additional descriptor and lock acquisition. The current lock protects continuation registration across worktrees (`flow/internal/cmd/takeover.go:25`, `:77`). | **W2:** no legacy launcher remains running or in supported launch paths; rollback target participates in the new lock. | Remove legacy acquisition when every supported writer uses the new lock. Delete the old file only after its users have drained. |
    | `$XDG_STATE_HOME/klaus/self-update.lock` and its state anchor → `~/.valley/flow/self-update.lock` and `self-update.json` | Recognize both state locations; acquire both locks; select **one authoritative state file**, preserving `Current`, `Previous`, failure and pin state. Cost: location resolver and second lock. Current state and lock share `Updater.Dir` (`flow/internal/selfupdate/selfupdate.go:42`, `:77`, `:483`). | State moves in **W1**, after updater timers and rollback are R-capable and an existing update has completed. Legacy lock acquisition ends in **W2**. | No supported updater uses the old location, and the authoritative state has been verified at the new location. |
    | `~/.klaus/locks/review-…lock` → `~/.valley/flow/locks/review-…lock` | Dual-lock the global fallback; preserve session-local lock locations. Cost: a second acquisition only for the moving global anchor. Current selection is session-local first, global otherwise (`flow/internal/cmd/review.go:195`); filenames are already neutral (`flow/internal/review/lock.go:20`). | **W2:** all global review writers use R or later. | Once legacy global writers are retired. Keep `review-…lock` unchanged permanently. |
    | Session-local ledger, consult and event-log locks | **Keep neutral filenames and each existing session’s root.** R enumerates both session roots and opens the recorded root. No dual copies of ledgers or logs. Ledger locks are separate files; events lock the log itself (`flow/internal/pipeline/ledger.go:117`, `flow/internal/consult/store.go:54`, `flow/internal/event/log.go:50`). | New sessions use the new root in **W1**. Existing sessions never move while active. | Old-root discovery ends only when no retained session needs it. Neutral filenames remain permanently. |
    | `klaus-agents[-<id>]` → `valley-flow-agents[-<id>]` | Record the exact tmux session name; absent metadata means the legacy name. Cleanup uses that identity. Cost: one field and legacy inference. Today creation and cleanup recompute the name (`flow/internal/cmd/agent_pane.go:25`, `:118`). | **W2:** all launchers, dashboards and cleanup commands understand recorded identities. Only new tmux sessions receive the new name. | No retained session can resume or clean up a legacy tmux session. Existing sessions are never renamed. |
    | `klaus:budget-paused` → `flow:budget-paused` | Recognize either label and clear both on resume. Cost: two comparisons and potentially another removal. Current detection and clearing accept one spelling (`flow/internal/draft/draft.go:144`, `:159`; `flow/internal/pipeline/transitions.go:780`). | **W2:** all dashboards, finalizers and automation inspecting the affected repositories recognize both. | No legacy writers remain and repository inventory shows no legacy pause labels. |
    | `klaus_exit` → `flow_exit` | Normalize either event into one exit result; never emit both. Cost: one parser alias. The pane writes it and finalize interprets it (`flow/internal/cmd/launch.go:1401`, `flow/internal/cmd/hidden.go:932`). | **W2:** consuming helpers and rollback are R-capable. Existing pane scripts retain their original output until they finish. | **Never** while old logs remain supported: retain one event-type alias. |
    | `klaus-check-completed:` → `flow-check-completed:` | Accept both prefixes, produce one check event, and recognize both executable forms in command parsing. Cost: prefix and command aliases. Current parsing accepts one prefix and recognizes only `klaus _pre-review` (`flow/internal/stream/checks.go:193`, `:332`). | **W2:** every consuming `_format-stream`, including remote-session consumers, is R-capable. | **Never** for retained transcripts: keep the two-prefix parser. |
  9. contributor2026-11-22 17:25 UTC
    Stage 3 design amendment, part 2 of 3: exit path per kept name, second half.
    
    | Current → eventual name | What R prepares; present cost | Condition for switching writers | When the old reader can go |
    |---|---|---|---|
    | `klaus.config`; `klaus.run`, `.changeid`, `.chaindir`, `.format` → `flow.config`; corresponding `flow.*` keys | Support both hook/config generations. While bridging, preserve the legacy file and write equivalent key sets; generate matching scripts in Go and replace files atomically. Cost: duplicate small configuration data and two template variants. Scripts currently hard-code the filename and namespace; installation removes and rebuilds the config (`flow/internal/git/git.go:726`, `:753`, `:790`, `:864`). | **W2:** every retained hook installation is identified and supports the new configuration. Keep legacy files for scripts still using them. **W1’s trailer change separately requires refreshed commit hooks.** | No installed or executing hook references the legacy file or keys. Do not add shell fallback logic. |
    | `<!-- klaus-agent-reply -->`, `<!-- klaus-actionable -->`, `<!-- klaus-cross-review … -->` → corresponding `flow-*` markers | Recognize both everywhere: reply exclusion, opt-in, trusted-review detection and round counting. Count each review once. Cost: three marker aliases. These markers affect dispatch and repetition limits (`flow/internal/cmd/review_check.go:16`, `:25`, `:100`; `flow/internal/review/pr.go:176`). | **W2:** every review detector is R-capable; generated prompts then request the new markers. Existing workers may finish using their original prompts. | **Never:** historical comments require these bounded marker aliases. |
    | `/klaus fix` → `/flow fix` | Accept both with the existing first-line, whitespace and quotation boundaries. Cost: one command alias (`flow/internal/cmd/review_check.go:25`). | **W2:** all comment consumers accept both; instructions switch to `/flow fix`. | **Never:** old comments must retain their meaning. Humans may continue using the alias. |
    | `<git-common-dir>/klaus/{runs,logs,…}` → `<git-common-dir>/valley/flow/{runs,logs,…}` | Discover both stores, retain each existing run’s actual store, reject conflicting duplicate identities. Cost: another store locator. Current paths are hard-coded and used by scaffolding (`flow/internal/run/store.go:108`, `flow/internal/cmd/new.go:176`). | **W2:** standalone run readers and writers are R-capable. New runs use the new store; existing runs finish in their original store. | After retained legacy records are deliberately migrated or removed and no process uses that store. |
    | Executable `klaus` → `valley-flow` | Updater smoke tests and dashboard restart support either executable, preserving the selected profile rather than finding an unrelated fallback. Cost: two-name lookup. Both executables already ship, but smoke tests require `klaus`; dashboard fallback is specifically toward `klaus` (`nix/packages.nix:1273`, `flow/internal/selfupdate/selfupdate.go:385`, `flow/internal/cmd/dashboard_restart.go:104`). | New internal invocations switch in **W2**. Executable removal waits for the final-removal conditions below. | No live pane, supported updater, timer, script or rollback target requires `bin/klaus`. |
    | Embedded `klaus _finalize`, `_format-stream`, `dashboard` → `valley-flow …` | Prepare generation-selected command construction and record which helper/build created the session. Cost: command selection and session metadata. These commands are embedded now (`flow/internal/cmd/launch.go:1370`, `:1413`; `flow/internal/cmd/session.go:399`). | **W2:** both executable names are present on every relevant local and sandbox PATH. Only newly constructed pane commands change. | When all panes containing the old commands have finished. Changing PATH does not rewrite their shell commands. |
    | Flake attribute `klaus` → `valley-flow` | Export both on Linux and Darwin; updater understands both. Preserve the legacy attribute’s legacy package identity, using a thin compatibility package around the same compiled program if necessary. Cost: one compatibility output, not another Go build. The updater currently builds exactly `.klaus` (`flow/internal/selfupdate/selfupdate.go:38`, `:465`); Darwin exports derive from `clientPrograms` (`flake.nix:176`, `nix/packages.nix:54`). | **W2:** R-capable updaters select `valley-flow`. Old updaters can still bootstrap through `klaus` until final removal. | All supported updater installations and consumers use the new attribute, including machines returning after being offline. Otherwise retain the cheap compatibility attribute. |
    | Profile element `klaus` → `valley-flow` | Match either element, record the actual element and store path, and restore either during rollback. Refuse ambiguous ownership. Cost: two-name matching and optional metadata. Current lookup/removal only uses `klaus` (`flow/internal/selfupdate/selfupdate.go:355`, `:410`). | **W2:** the active updater and its rollback target understand both identities. | Neither the installed element nor supported rollback requires legacy matching. Historical store paths remain valid strings. |
    | Nix derivation names `klaus`, `klaus-go-modules`, `klaus-flow-checker`, `klaus-${name}`, `klaus-flow-build` → `valley-flow`, `valley-flow-go-modules`, `flow-checker`, `flow-${name}`, `flow-build` | Prepare the canonical package plus legacy compatibility output. Build-only names need no runtime readers. Cost: changed derivations/cache identities (`nix/packages.nix:1248`, `:1267`; `nix/checks/flow.nix:17`, `:37`, `:81`). | Build-only names can change in **W1**; installation identity follows the package protocol in **W2**. Keep public required-check names unchanged. | No reader shim for build-only labels. Never rewrite existing store paths; retire the legacy compatibility derivation with its attribute. |
    | `Klaus-Run:` → `Flow-Run:` | Preserve interpretation of either trailer wherever provenance is consumed; prepare both Go and hook writers. Cost: two recognized keys, without rewriting history. Both writers currently emit `Klaus-Run:` (`flow/internal/git/git.go:717`, `:767`). | **W1:** commit-producing helpers and installed commit hooks are upgraded; in-flight legacy hook executions have drained before declaring cutover complete. | **Never:** retain the legacy trailer key for historical commits. |
  10. contributor2026-11-22 17:25 UTC
    Stage 3 design amendment, part 3 of 3: the naming_generation setting, the conversation ref, locks, package removal, and the change list (R, P, W1, W2, removal).
    
    Use one host-only **`naming_generation: legacy | bridge | flow`**, replacing `storage_layout`. `legacy` preserves current writers; `bridge` enables W1; `flow` enables W2. Project declarations cannot override it. Existing objects retain recorded identities: changing the default never moves a live session, renames its tmux session, or changes the destination of an already-recorded publication.
    
    Make this inspectable through a proposed `valley flow naming status`, reporting the selected generation, actual store locations, live session creators, hook installations, updater/current/previous packages and unresolved blockers. R builds advertise the generations they support; session creation records that support and the creator build. Missing metadata means legacy—not “probably upgraded.” A restarted dashboard must not relabel the session’s creator. Store records identify their active generation and concrete destination. These are evidence for the single generation setting, not independent feature switches.
    
    Advancement requires the reported checks plus operator verification of external timers, sandbox helpers and other publishers. Local inspection cannot certify an offline machine. Reject hash-based “minimum version” comparisons: builds are not a total compatibility order. Reject per-name settings because they multiply combinations to test and explain. The ordered generation intentionally makes W2 wait for its slowest dependency; W1 remains available while host authorization is pending.
    
    **R must support writing all three generations before any activation.** Rollback changes the executable, never the store generation. Conservatively, activation waits until no live session was created by a pre-R build, all participating helpers and hooks are R-capable, and the previous installed build supports the target generation. Pre-R sessions can finish normally while activation waits. Current discovery cannot establish this: it reconstructs one home root and enumerates only that root (`flow/internal/run/homedir_store.go:25`, `:80`), so the inventory and recorded identities belong in R.
    
    The conversation ref can start at exactly the old tip. For each clone, verify the old tip and create the absent new ref in one compare-and-swap transaction; subsequent commits descend from it. Fetch an existing canonical new ref before considering initialization. Refuse divergent histories for explicit reconciliation—do not silently choose a remote tip over unpublished local conversations. Default publication is disabled, so migration must not publish local-only history merely to consolidate it (`flow/internal/config/config.go:23`). Also fix append concurrency: `SyncToDataRef` currently updates the ref without an expected old value (`flow/internal/git/git.go:522`, `:565`). A seeded history still loses records if concurrent finalizers overwrite each other.
    
    This data belongs in **project storage**. The host must permit the exact `refs/the-valley/flow/data` through the reserved-namespace refusal, require a named grant for its publishers, and freeze writes to the old ref at cutover. Merely adding a grant currently fails before grant evaluation (`valleyhook/policy.go:163`, `:232`). Do not open `refs/the-valley/*`. Verify the exact new destination accepts the intended writer and unrelated refs remain refused. Once the new history contains the frozen old history, replay needs no per-blob fallback.
    
    The publication result must identify **repository/destination, full ref name, exact commit and outcome**. Destination plus commit alone cannot distinguish publication under the old ref from publication under the new one. Push the recorded commit, rather than a ref that may advance between recording and pushing; the current helper pushes a mutable refspec (`flow/internal/git/git.go:695`). Amend P accordingly if needed. On this HEAD finalize still discards its push error (`flow/internal/cmd/hidden.go:1246`); do not treat the in-review change as already deployed.
    
    For moving locks, R acquires **old then new**, releases in reverse order, and releases the first if acquiring the second fails. Canonicalize paths and avoid locking the same inode twice. Take the locks before reading or moving the protected state. Legacy processes contend with R through the old lock; new-only processes contend with R through the new lock. Legacy-only and new-only processes must never coexist. Never unlink or replace a held lock file. Dual locking is worthwhile for continuation, updater and global review anchors; session ledgers, consult locks and `events.jsonl` should keep their neutral names and pinned roots.
    
    Package removal needs a bootstrap sequence. R first supplies both attributes and both executable names, while `#klaus` continues producing the identity an installed legacy updater expects. W2 switches R’s updater to `#valley-flow`, replaces the actual matched profile element, and generates `valley-flow _finalize` commands for new panes. Keep `bin/klaus` until old panes and external invocations are gone; keep `#klaus` until supported legacy updaters are gone. Only then remove compatibility outputs and lookups. A host generation cannot control what an old updater builds from main, so making both attributes aliases of a newly renamed derivation is insufficient. Preserve one-step rollback throughout. Current replacement is remove/add with restoration on failure, not atomic (`flow/internal/selfupdate/selfupdate.go:404`); its failure path needs explicit coverage.
    
    The changes are:
    
    1. **R:** all table bridges, generation reporting and validation, recorded identities, both-root enumeration, dual locks, hook preparation, updater compatibility, and complete support for operating already-migrated stores. Keep ordinary writers on legacy defaults. Test a pre-R session finishing under R, dashboard restart, legacy replay, lock contention and rollback to the preceding build while generation remains legacy. Separately exercise R against a prepared flow-generation store.
    
    2. **P:** finish publication-error visibility and exact destination/ref/commit recording. It can proceed alongside R. Test rejected publication retaining the local conversation, a visible recoverable failure, and successful publication of the recorded commit. Include concurrent finalizers so the record cannot describe the wrong commit.
    
    3. **W1 / `bridge`:** activate the accepted home/project paths, new temporary-worktree defaults, environment aliases, visible titles and WIP text, new `via`/`command` values, and `Flow-Run`. Preserve old persisted values and export legacy environment aliases during coexistence. Current examples are `config.go:414`, `cmd/session.go:376`, `draft/draft.go:97`, `cmd/ready.go:180`, and `cmd/pre_review.go:214`, all under `flow/internal/`. Test an R-created session started before activation and finalized afterward, dashboard discovery across both roots, refreshed-hook trailers, replay, and rollback to R with new storage still active.
    
    4. **W2 / `flow`:** activate the plumbing rows after the host and deployment checks pass. Test exact-tip ref seeding and old-conversation replay through the new ref, refusal of divergence, host grant boundaries, new/bridge lock contention, cleanup using recorded tmux names, marker/check-event deduplication, and rollback to W1 while continuing the same new stores. Existing sessions retain their allocated paths and names.
    
    5. **Final removal:** remove only compatibility whose table condition is proven. Keep bounded readers for historical trailers, comments, logs and refs; keep neutral lock filenames permanently. Test updating from the preceding W2 package, rolling back to it, and finishing any supported session without `bin/klaus`. Verify Linux packaging and Darwin exports/cross-compilation; the existing Darwin checks do not prove native runtime behavior (`nix/checks/darwin.nix:1`).
    
    R, the P amendment, W1 implementation and W2’s host authorization change can be briefed today. W2 activation and final removal require the inventory results. The operator’s chosen directories remain suitable; the code argues against moving active stores or removing aliases merely because the foreground command has changed.
    
    The single most useful amendment is to make **R finishing a run after rollback against flow-generation storage** an acceptance test before W1 is briefed.
  11. contributor2026-11-23 00:57 UTC
    Stage 3 progress and one change to the W1 list.
    
    Landed: R in three parts (wire-name readers b8e46aa, package and updater c14b0e6, state locations with naming_generation and `valley flow naming status` 6a67919) and P (9ee9592). A host followed main across both the updater change and the locations change without intervention.
    
    W1 is briefed without the trailer switch. A critic read of main found that the R build's commit hook adds Klaus-Run for the amending run and its reader accepts both keys only when their lists agree, so a Flow-Run commit amended by an R build becomes conflicting provenance; widening W1's reader cannot repair a rollback build. W1 therefore makes the hook and reader safe under every generation (one merged list across both keys; the hook writes under the key the message already uses) and keeps writing Klaus-Run. Writing Flow-Run moves to W2, whose rollback target is then W1.
    
    Also decided for W1: a session's own state follows the session; everything a command writes fresh follows the host setting at the time of writing. The env export is normalised at every child-launch boundary (both spellings when set, neither when unset). The worktree default changes only when no config sets it.
    
    Open from review, carried into W1: ida-a5536f1 (registry under both names unreported in checkout lookups).