7414713d61ba7e3446094ddbab5259bb23689b53
6
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
c0dbb6410c |
fix(archied): disable a provider whose credential is missing instead of refusing to boot
configuration.md's startup policy -- "a missing credential disables a capability.
Only an invalid config stops the daemon" -- names this exact case: "Apply the same
reasoning to any future capability credential, LLM keys especially: start, report
the capability as unavailable, let the operator see it." The code did the
opposite. resolveProviderMap returned an error when a provider's api_key could not
be resolved, and again when it resolved empty, so configuredSecretRegistry failed
and the daemon would not start. A provider nobody referenced still blocked boot,
because the walk covers every entry in cfg.Providers rather than the ones [models]
uses.
The forge path was fixed to degrade for precisely this reason (resolveForge,
guarded by TestResolveForgeDegradesInsteadOfFailing); this is its provider
counterpart. A credential that cannot be resolved now disables that provider with
a warning naming it and why, and the daemon starts.
Disabling clears the reference rather than leaving it. webui's ProviderView
derives Configured from api_key or APIKeyEnv, so an unresolvable reference left in
place would advertise a provider nothing can use -- the "looks configured and is
not" shape this codebase keeps having to remove. Consumers already treat an empty
APIKeyEnv as no credential (agentexec/runtime skips such a provider, the daemon
exports nothing to the agent container), so clearing it is the whole disable.
The other half of the policy is kept: a reference naming only one of engine and
key is a config error, not a missing credential, and stays fatal.
applyForgeDefaults only ever builds a ref with both halves, so a half-named one can
only come from a hand-edited config.
This also defuses the trap
|
||
|
|
89cfa44b5e |
feat(configuration): let setup reference a secret without carrying its value
A parameterised install could not configure a cloud provider without a terminal:
the only way a secret value entered was the prompt, so an unattended run was
limited to the keyless self-hosted provider. The missing piece is the reference
form.
A reference is not a secret. An engine name and a key name are not sensitive --
which is exactly why a reference may be a parameter while a value may not -- so
setup gains -forge-secret-ref, -provider-secret-ref and -telegram-secret-ref,
each taking engine:key, parsed by one new setup.ParseSecretRef. When a reference
is given the step writes it to TOML and asks nothing, and setup neither reads nor
stores the value, because the value is not its to hold. That is the difference
from the prompt path, where the operator supplies a value and setup writes it
into the env engine and references it there.
Engine names are identifiers, not paths: the shipped engines are registered as
age, sops and vault, so a reference like vault/openbao:KEY is refused rather than
written into a config that could never resolve it.
Two refusals guard the silent no-op. A reference naming a key for the keyless
self-hosted provider, or for a forge that is disabled, would sit in the config
looking configured while nothing read it -- the failure shape this flow exists to
remove -- so both are refused rather than written.
telegram keeps writing token_env for the prompt path, because that form names an
env var and the prompt path is the env engine; a supplied reference may name any
engine, which token_env cannot express, so the reference path writes the
preferred token = {engine, key} form. Noted as the one asymmetry.
Also folded stepCloudProvider's key handling into cloudKeyEdit and cloudModel.
That was a lint fix for nested blocks, but the split is the honest shape: the two
branches obtain a key edit by different means and then resolve a model the same
way.
Every new test was mutation-verified by reintroducing the absence: ignoring the
forge reference, making ParseSecretRef validate nothing, and dropping the keyless
-provider guard each fail the corresponding test.
|
||
|
|
3f7dc7c088 |
fix(configuration): stop letting a secret value be set from the command line
archied setup took -forge-token, -provider-api-key and -telegram-token, each carrying a secret VALUE. That is wrong twice over: the value lands in shell history and in every process listing, and it is a second way to set a secret that no secret engine knows about. The codebase already holds the opposite invariant, and had before this landed: - configuration.md:423-425 states it directly -- "setup writes the reference to TOML and the value to the secret engine". - No CLI flag anywhere in the repository accepted a secret value; these three were the only ones. - install.sh already does it correctly: read_secret prompts without echoing so the value never reaches scrollback, and set_env_key writes it into the systemd EnvironmentFile, which is the env engine's backing store. So the SecretSink half was right -- writing the value to the env file IS writing it to the secret engine, for the env engine -- and the prompt path was right. Only the three value-carrying flags were wrong. Removed: Params.ForgeToken, Params.ProviderAPIKey, Params.TelegramToken and the flags that fed them, along with the parameter plumbing in step_forge, step_provider and step_chat. Those steps now always read the secret from the prompt surface. Params gains a comment recording why it deliberately has no secret-valued field, so the absence is a decision rather than an oversight. TelegramUserIDs stays: an allowlist of user IDs is access policy, not a credential. Two tests pinned the wrong behaviour and are replaced rather than deleted: - TestRunParams_ProviderAPIKeyNeverPrompts asserted a secret could arrive as a parameter. It becomes TestRunParams_SecretsComeOnlyFromThePrompter, which supplies every non-secret answer through Params and scripts only the secret reads, so it fails if a secret ever comes from anywhere else. - TestRunSetup_DefaultsWithForgeTokenWritesEnv exercised the removed flag. It becomes TestRunSetupRejectsSecretValueFlags, which asserts all three flags are rejected with exit 2 and that neither a config nor an env file is written -- verified by re-adding -forge-token and watching it fail. The unused rejectingPrompter went with them; its remaining replacement uses a scripted prompter instead. |
||
|
|
ef0d61782b |
feat(configuration): add archied setup, the caller the first-run flow was built for
docs/architecture/configuration.md decides that "install.sh must stop generating
config.toml; archied setup owns it", and gives the reason: the installer
hand-rolling TOML already drifted from the schema once, and "the durable fix is
that the code writing the config is the code that reads it". setup.Run,
tomlwrite, configtemplate.Example and terminalprompt were all built for that and
had no production caller between them. This adds the caller.
setup.Run's own doc comment states the obligations, and they are the shape of
installValidatedConfig: render the edits, prove the result loads through a real
configuration.Loader, and only then install the file and commit the secrets. A
validation failure returns before either write, so a bad config leaves neither a
config nor a secret on disk. The rendered bytes are proven from a temp file, so
a load failure cannot have already installed anything. The config is written
0600 via same-directory temp and rename.
Parameterisation is typed, not matched against prompt text. A flag-to-prompt
mapping would have to match strings, which is the brittleness removed in
|
||
|
|
0ddc43081e |
feat(setup): implement the interactive setup steps (archie-core-cbk)
internal/infrastructure/configuration/setup.Run drives operator identity, LLM provider, models, forge, and Telegram chat channel prompts and returns TOML edits -- not a config.Config. Building a parallel in-memory representation to validate against was rejected during design review: it's a second source of truth about the exact thing (text vs. struct disagreeing) this whole feature exists to stop. Tests instead render the edits against the real embedded template and load the result through a real configuration.Loader, proving the actual defaults/decode/validate path accepts it. Two boot-time landmines in config.example.toml surfaced by that approach, both fixed here: - [providers.openai] ships active with api_key pointed at the bws engine. cmd/archied/provider_secrets.go resolves every entry in cfg.Providers at startup, not just the ones [models] references, and refuses to start the daemon if any fails -- so picking any other provider (or picking openai but skipping the key) left a config that wouldn't boot on a machine without the bws CLI installed (the common case). stepProvider now neutralises providers.openai.api_key to the zero-value secret ref whenever openai wasn't the actual choice. - [[repos]] shipped active with a placeholder owner/name that validates cleanly (owner/name are only checked non-empty) and would have archied silently polling a repo that doesn't exist. Commented out in the template with an explanation; setup does not write this section since tomlwrite cannot target array-of-tables. TestExampleConfigLoads updated to expect zero repos. Also: forge and provider secret env-var names are each defined in one table (forgeToken, cloudProviders) read by both the config edit and the secret sink, so the two can't name a secret differently -- the exact bug class this feature exists to close for the installer, tested directly (TestRun_ForgeTokenKeyMatchesStoredSecretKey compares the decoded key against the key the secret was actually stored under, not a hardcoded literal on both sides). Telegram writes chat.telegram. token_env, not a secret.SecretRef -- TelegramConfig has no such field. Telegram also requires at least one allowed_user_id: AllowedUserIDs is deny-by-default, so a bot token with none configured answers nobody, which reads as broken rather than as the safe default it is. SecretSink is a caller-supplied sink (Put buffers, Commit persists), not a return value: Run never hands back plaintext secrets, and the caller is expected to call Commit only after proving the generated config loads -- so a validation failure never leaves a secret written without the config that references it. Refs archie-core-cbk |
||
|
|
6ee86f2593 |
feat(setup): Prompter interface and a TTY-gated terminal implementation
archie-core-via. internal/infrastructure/configuration/setup defines Prompter -- Select, ReadLine, ReadSecret, Confirm, all context-aware -- which is all the setup step logic (to follow) needs from a prompt surface. No terminal dependency, so steps are testable without a TTY. internal/infrastructure/terminalprompt.Terminal is the real implementation, using golang.org/x/term. New refuses construction when its input isn't a real terminal, with a message naming the problem -- enforcing "a non-TTY invocation fails with a clear message rather than writing a partial config" at the earliest possible point, rather than falling back to a plain read that would silently accept piped/scripted input (ssh, `archied setup < answers.txt`, CI). Terminal satisfies Prompter structurally; this package does not import that one, so there's no infrastructure -> infrastructure edge for what Go's type system already gives for free. Each blocking read runs in a goroutine raced against ctx.Done(), so Ctrl+C returns promptly instead of leaving the operator stuck; the losing goroutine is abandoned on cancellation; term.ReadPassword's own raw-mode restoration is not interruptible, so an abandoned secret read can leave the terminal in raw mode until it unblocks on its own -- documented on Terminal.readSecret rather than worked around, since a cancelled setup command is expected to exit shortly after via its own signal handling anyway. Tested by constructing a Terminal directly (bypassing New, same package) over a plain pipe with an injected readSecret seam -- New's TTY gate itself is exercised separately against a real os.Pipe(). No weakening of the production constructor for testability. Refs archie-core-via |