Files
museion/docs/devlog/20261110-issue182-profilelayout-config-set-rail_log.md
T
AlexKucera a8b158ca26
CI / ci (push) Canceled after 0s
refactor(profiles): one layout + config-set rail
#182: ProfileLayout owns the profile root default and every per-profile
path (dir, .env, configured marker, gateway pid, skills dir) — the five
scattered profile-root literals are gone; the provisioner, the settings
writer, and backup/restore derive paths only through it, pinned once in
ProfileLayoutTests. RESTORE.md prose and the ps-scan grep keep their
literal text deliberately (doc text and argv matching, not paths).

HermesConfigRail owns the config set/unset contract once: argv shape
(+--force), provider-first hoisting (switching providers clears a stale
inherited base_url — a caller can no longer order it wrong), ✓-line
verification, unset-idempotence. The provisioner seeds provider/default/
max_tokens; the writer edits provider/default/effort/base_url — each
keeps its own key list, only the mechanism and ordering rule unify. The
rail's Failure carries key/profile/excerpt for both error surfaces.

Audit hardenings folded in: a leading-dash value refuses before any
spawn (free-text model/endpoint fields cannot reach the child CLI as
options), whitespace-only endpoints read as empty at both writer gates,
the deliberate 500-char excerpt cap is pinned not just commented, and
the failed-unset branch is pinned (the fake hermes grew a
config-unset-fails knob).

Full suite 684 passed / 0 failed; dash + whitespace pins flip-verified.

Closes #182
2026-11-10 11:32:47 +01:00

5.6 KiB

ProfileLayout + one config-set rail — the Hermes profile's paths and CLI contract get owners

Date: 2026-11-10 Type: issue Reference: Closes #182 (settings cluster, 2026-11-09 architecture review)

Goal

The profile-root string repeated five times across provisioner/settings-writer/backup and the config set CLI contract (argv shape, provider-first ordering, ✓-line verification) was hand-rolled twice. Give both a single owner so a layout or contract change is one module + one pinning suite.

What Was Done

  • Museion/ProfileLayout.swift (new) — defaultRoot + five per-profile path builders (profileDir, envFile(in:), configuredMarker(in:), gatewayPID(in:), skillsDir(in:)).
  • Museion/HermesConfigRail.swift (new) — the ONE config set/unset owner: argv (+--force), provider-first hoisting (isProviderSet, stable relative order), ✓-line verification, unset-idempotence, leading-dash value refusal, structured Failure (verb/key/profile/excerpt) consumed by both callers' error surfaces.
  • Adopted: provisioner (perform default, provisionSurface, marker reads/writes, skills dir, ProvisioningModel.runPass fallback, configureDefaults now hands the rail provider/default/max_tokens), settings writer (profileRoot default, env fan-out + read paths, writeSurface hands the rail provider/default/effort-set-or-unset/base_url, writeProviderKey base_url write-through), backup (perform default, source dirs, gateway.pid, BackupModel.runPass fallback).
  • Deleted: ConfigWrite, the writer's setKey/unsetKey/excerpt trio, the provisioner's private excerpt (rail exports one, #180-audited 500 cap).
  • Pinning suites (new): ProfileLayoutTests (every builder against literals), HermesConfigRailTests (argv+force, provider-first hoisting, ✓-verification, unset-idempotence, failed-unset, dash-refusal, excerpt cap). Fake-hermes gained a config-unset-fails knob. Writer suite gained the whitespace-endpoint pin (both gates).
  • Audit fixes (finish-audit fanout): cut providerKey constant, Equatable conformances, and the tautological layout pin (ponytail); trimmed-emptiness at both endpoint gates (learning #6's class); leading-dash value guard (security LOW-1 — free-text values can't reach the child CLI as options).
  • DOX: Museion/AGENTS.md (ProfileLayout + HermesConfigRail map entries, configure/backup/settings bullets updated), MuseionTests/AGENTS.md suite map.

Decisions & Rationale

Decision Rationale
Rail hoists model.provider first, callers' lists stay literal The ordering RULE is the rail's (a caller can't order it wrong); each caller's ordered key list is its own pin — the spec's "each caller keeps its own key list"
Failure throws structured fields, writer rethrows directly SettingsModel renders error.localizedDescription; message shape byte-matches the old WriteError; provisioner maps to Outcome.failed with the excerpt
Excerpt cap 500 (not the writer's old 300) The more-lossless twin wins when absorbing near-twins (#180); marked deliberate AND pinned (excerpt(900).count == 500)
RESTORE.md prose + ps-scan grep keep their literal path text Prose that must outlive the app, and argv-text matching — not path derivations; documented in the layout header
Op renamed Write SwiftLint 3-char identifier floor
Declined: precondition on layout builders Every production call site passes the fixed ProfileSurface table (verified twice by reviewers) — YAGNI

Gotchas & Fixes

Problem Root Cause Fix
First background full-suite ran on pre-rename products test-without-building tests the BUILT products; the Op→Write rename landed after build-for-testing Rebuilt + reran the definitive gate on the final tree (680/0 → 684/0 after audit pins)
One patch gutted non-zai key write only touches env Inverted old/new strings in the patch — signature kept, body deleted Re-read region, restored body + inserted the new whitespace pin
detect-changes listed untouched ref/writing skills files Index-relative noise (mid-session analyze snapshot vs pre-audit index) git status is the file-list truth; re-ran analyze after the audit edits

Files Changed

File Change Summary
Museion/ProfileLayout.swift new — the profile layout owner (root default + 5 path builders)
Museion/HermesConfigRail.swift new — the config set/unset CLI rail (argv, hoist, ✓-verify, dash guard, Failure)
Museion/ProfileProvisioner.swift paths via layout; configureDefaults → rail; private excerpt deleted
Museion/ProfileBackup.swift paths via layout (perform default, sources, gateway.pid, model fallback)
Museion/HermesSettingsWriter.swift profileRoot default, env/base_url paths via layout; set/unset → rail; trimmed endpoint gates
MuseionTests/ProfileLayoutTests.swift new — the layout pinning suite
MuseionTests/HermesConfigRailTests.swift new — the rail contract suite (7 pins)
MuseionTests/ProfileProvisionerTests.swift fake-hermes config-unset-fails knob
MuseionTests/HermesSettingsWriterTests.swift whitespace-endpoint pin (both gates)
Museion/AGENTS.md, MuseionTests/AGENTS.md, AGENTS.md DOX pass + gitnexus stats bump

Open Items & Next Steps

  • None — all five acceptance criteria met and verified (full suite 684 passed / 0 failed on the final tree; swiftformat/swiftlint clean; flip-cycle verified the dash + whitespace pins discriminate).

Log written by write-log skill