refactor(profiles): one layout + config-set rail
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
#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
This commit is contained in:
1 parent
f49e4b6ca0
commit
a8b158ca26
14 files changed
+484
-113
No files matched your search
@@ -173,6 +173,30 @@ struct HermesSettingsWriterTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test func `whitespace-only endpoint is treated as empty at both gates`() async throws {
|
||||
// Learning #6's class: raw isEmpty passes whitespace through; the
|
||||
// gates mirror the trimmed emptiness the model side validates.
|
||||
let (binDir, writer) = makeRig()
|
||||
// Surface gate: a blank endpoint never rides base_url.
|
||||
try await writer.writeSurface(
|
||||
.pass1,
|
||||
config: SurfaceModelConfig(provider: .zai, model: "glm-5.3", effort: nil),
|
||||
zaiEndpoint: " ",
|
||||
)
|
||||
#expect(fakeHermesLog(binDir, "config-set-museion-pass1") == [
|
||||
"-p museion-pass1 config set model.provider zai",
|
||||
"-p museion-pass1 config set model.default glm-5.3",
|
||||
])
|
||||
// Key gate: a blank zai endpoint skips the write-through (the key
|
||||
// still fans out to .env).
|
||||
try await writer.writeProviderKey(
|
||||
provider: .zai,
|
||||
config: ProviderKeyConfig(endpoint: " ", apiKey: "sk-z"),
|
||||
profiles: [.chat],
|
||||
)
|
||||
#expect(fakeHermesLog(binDir, "config-set-museion").isEmpty)
|
||||
}
|
||||
|
||||
@Test func `non-zai key write only touches env`() async throws {
|
||||
let (binDir, writer) = makeRig()
|
||||
let root = binDir + "/profiles"
|
||||
|
||||
Reference in new issue
Block a user