a7d6f71d5a2c9da170a46bfc4471f9979189de87
5
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6bdbd5e31e
|
feat(config): key services by name through a registry
Services was a struct with one field per service, so each service's name was stated three times: the field, the loader's defaulting branch, and every consumer's field access. Adding one meant editing all three, and nothing stopped them disagreeing. The drift was already there: stateStoreResolvedToken and gatewayResolvedToken were identical apart from the env var each hard-coded. Services becomes map[string]ServiceConnection, and RegisterService declares a service once with the five fields it has. Everything that differs between services is now an argument rather than a branch elsewhere: an empty registered target means the operator must supply one, which is how services.state.target stays required while the gateway's is defaulted, and the registered token env var replaces the two copied resolvers with Services.ResolvedToken. Defaulting iterates the registry, so a new service needs no loader edit. Consumers read Services.Get(name). Keeping a typo'd section reported took explicit work. [services.gatway] used to land in toml.MetaData.Undecoded() because the struct had no such field; a map decodes any section, so it would have loaded silently and left the daemon dialing the default. unregisteredServiceKeys asks the registry which names are real, and the test for it fails with an empty UnknownKeys when that check is removed. The TOML shape is unchanged, so no deployment profile, config.example.toml or install.sh edit is needed. Refs: archie-core-u23g |
||
|
|
0e64573b04
|
refactor(install): install.sh delegates config generation, and tests stop reading hand-written configs
Two things fall out of one principle: a test that asserts against a hand-written file is testing an artifact a human or an agent may legitimately rewrite at any moment, so only generated output is a valid target. install.sh generated config.toml two ways -- a full heredoc for the self-host path and an awk splice of the [forge] block into config.example.toml -- with a forge_block shell helper feeding both. That is the arrangement docs/architecture/configuration.md decided against: it "must stop generating config.toml; archied setup owns it", because the installer hand-rolling TOML already drifted once (choosing Gitea produced a config naming a token the installer never wrote). Both generators and forge_block are gone; install.sh collects its answers as before and passes them to archied setup as parameters, with secrets passed as REFERENCES to the env keys it just wrote rather than as values, which would put them on a command line. The installer also now asks for a cloud model, which archied setup requires and the old path never emitted. deployment_contract_test.go tested the removed generators by parsing install.sh's shell text, reconstructing the heredoc and asserting on its content. It broke the instant install.sh stopped generating config -- "install.sh has no heredoc declaring the daemon config's [nats] table" -- which is the failure mode in miniature: the test was coupled to an artifact, not to behaviour. Deleted. What it actually protected is kept, asserted on the GENERATED config instead: TestRunSetup_GeneratedConfigSatisfiesDaemonRequirements runs archied setup and loads what it wrote, requiring services.state.target and bot_user. A test against generated output fails when generation breaks and passes when a human merely tidies the template. Found by an adversarial package sweep (temp tracker: config-1, repo-root-deployment-1, repo-root-deployment-2). |
||
|
|
027dc9925b
|
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.
|
||
|
|
24ba2ce609
|
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. |
||
|
|
ee608d81fb
|
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
|