Commit Graph
1754 Commits
Author SHA1 Message Date
sam 49da68fb25 Merge branch 'crew/cluster1' into crew-integration 2026-09-15 10:33:15 +10:00
sam abb23247c5 refactor(tools): delete unused plugin-tool registration API from builtin.Registry
RegisterPluginTool/SetPluginToolExecutor/UnregisterPluginTools and the
PluginToolDef/PluginToolExecutor types have no production caller.
Plugin/MCP tool registration flows through agentexec.pluginToolSet and
internal/tools.Registry, not this staging registry (tools-builtin-2,
duplicate of tools-core-8).
2026-09-15 10:25:59 +10:00
sam 5c8f2f400a refactor(tools): delete unreachable AST-based tool discovery
Registry.Discover, DefaultRegistry and the go/ast extraction helpers
have no production caller; static source discovery has no PRD and no
consumer. Production registration goes through bootstrap.go's
toolReg.Register and the provider Registry's RegisterBatch (tools-core-3).
2026-09-15 10:23:17 +10:00
sam 6951125415 feat(channels): wire chat.webhook route config through to the gateway
internal/channels/webhook's RouteConfig implements and tests HMAC
signature validation, payload template extraction, and reply delivery,
but setupWebhookGateway built []webhook.RouteConfig{{Path: "/webhook"}}
literally -- no config field could reach Secret/Template/DeliverTo, so
the gateway accepted any unsigned POST despite its package doc claiming
signature validation.

Adds config.ChatConfig.Webhook (WebhookRoute: path, secret as the
existing SecretRef pattern, template, deliver_to) and webhookRoutes(),
the pure translation into []webhook.RouteConfig that
setupWebhookGateway now calls. A secret ref that fails to resolve logs
and falls back to no validation rather than refusing to start, since
signature validation stays opt-in (an empty secret is documented,
valid config) unlike the mandatory forge webhook secret.
2026-09-15 10:22:54 +10:00
sam 778d33f89c refactor(tools): delete unreachable dispatch/gating engine
DispatchSequential, DispatchConcurrent, ClassifyEntry and their
supporting types (dispatch.go) have zero non-test callers; the live
tool path is agentexec/toolset.go's BuildToolSetFrom. Removes the
dead engine and its tests, and updates the PRD status table that
referenced it (tools-core-1).
2026-09-15 10:19:39 +10:00
sam ba3d8cba21 refactor(archied): delete the daemon's unused webui.Server and UI adapters
b.web and its three adapters (skillCatalogAdapter, memoryUIAdapter,
curatorsUIAdapter) were constructed at boot but the daemon never calls
Handler() on the server and no route reads any of these fields -- the
dashboard is served by the separate archie-ui process (compose.go),
which deliberately leaves the same surfaces nil, and the daemon's
config snapshot goes through the standalone webui.BuildConfigView, not
a Server method. Removed the field, its four assignment sites, and the
three adapter files; test boot literals that carried a leftover
`web: &webui.Server{}` for no assertion-relevant reason had it
dropped, and the one test that specifically pinned b.web's store
surfaces staying nil is now moot with the field gone.
2026-09-15 10:19:00 +10:00
sam da5b9e7273 refactor(gateway): delete orphaned SessionState goal/steer/queue machinery
No /goal, /steer, or /queue command exists in messaging.localCommands, no
Router handler dispatches them, and BuildGoalPrompt was never merged into
the turn's system prompt. NewSessionState had no caller outside its own
test. Delete the entire mechanism rather than let a fully-built but
unreachable feature be mistaken for a live one.
2026-09-15 10:18:57 +10:00
sam 65d51250ff fix(gateway): delete unwired Router.Dangerous approval path
All four production Router constructions left Dangerous nil; the only
Decide implementation was webui.DangerousService, used directly by the
webui HTTP handler, not through the Router. handleDeny and the typed
/approve branches always returned "not configured" in production. Delete
DangerousApprover, the Dangerous field, /deny, and the dead branches so
the router surface matches what is actually wired; the dashboard's
dangerous-action path is unaffected since it never routed through here.
2026-09-15 10:18:53 +10:00
sam f7815d3b62 fix(channels): delete unreachable Telegram webhook delivery mode
telegram.New only ever constructed with empty webhookURL/webhookSecret
(telegram_setup.go) and config.TelegramConfig has no field to set them, so
the SetWebhook/StartWebhook branch, WebhookHandler, and webhook teardown in
Stop were dead code exercised only by tests. Long-polling is the only
reachable mode; delete the webhook path and its ConfigSchema properties so
the schema no longer advertises unsupported config.
2026-09-15 10:18:48 +10:00
sam 739d4530de refactor(memory): delete the unreachable <memory> fence scrubber
internal/memory/scrubber had no importer anywhere in the repo; the
only emitter of <memory> fences (builtin.Provider.SystemPromptBlock)
also has no caller in the streaming output path, so the whole package
was dead code. Deleted it and the doc comment claiming a scrubber
consumes SystemPromptBlock's output.
2026-09-15 10:18:29 +10:00
sam 0da70ca8f4 refactor(staterpc): delete the superseded single-token auth interceptor
UnaryTokenInterceptor/TokenValidator/checkToken (auth.go) and
constantTimeTokenValidator (state_store.go) had no production caller:
server auth on the bridge-address listener is wired through
TaskGrants.UnaryInterceptor/StreamInterceptor, which replaced this
all-or-nothing token check with per-task scoped grants. Removed the
dead cluster and its now-pointless tests; TaskGrants' own auth
rejection paths are already covered in task_grants_test.go.
2026-09-15 10:18:25 +10:00
sam d7b809e61b fix(agentworker): wire configured tool-result policy into worker's LoopRunner
TaskConfig now carries the daemon's ToolPolicy (MaxResultChars/SpillDir)
via ForTask/ToConfig, and runTask applies it to the constructed
LoopRunner. Previously the worker always built the agent loop with a
zero-value ToolLimits, so tool results in every task's agent stage were
never capped or spilled despite the configured 50k default (agentexec-1,
tools-core-11).
2026-09-15 10:14:50 +10:00
sam 96610bda6e feat(archied): wire the scheduling ticker engine at boot
schedulingConfig translated [scheduling] config into a domain
EngineConfig but nothing ever called it in production: the whole
scheduling/cron family (ticker engine, cronstore, crondelivery) was
built and tested but reachable from no binary, so an operator setting
scheduling.interval etc got a silently inert section.

setupScheduling opens a cronstore.Store as the engine's JobSource,
builds a crondelivery.Router with a workflow-kind runner backed by the
same non-forge gateway.TaskCreator chat's /spawn already uses, and
constructs the scheduling.Engine from schedulingConfig. startServices
starts it alongside every other subsystem; Stop is registered via
addCleanup on the same Background-timeout pattern as the curator
runtime. No chat task creator configured leaves the engine unstarted
rather than running with no reachable job kind -- the "chat" delivery
kind stays unmapped for the same reason (no unified cross-channel
outbound sender exists at this composition root yet).
2026-09-15 10:14:10 +10:00
sam 1957d0ab39 feat(tools): add contractaudit for standing contract-conformance reporting
Reachability (tools/reachaudit, epic archie-core-06ag) answers "is this code
in a shipped binary?". It cannot answer the complementary question: "does
every declared contract surface have a consumer, or a declaration that it
has none?". ratelimit was in the binary closure and called by nothing, which
reachability could not see.

tools/contractaudit classifies each subject of each declared surface as
CONSUMED, DECLARED-UNCONSUMED, UNDECLARED-UNCONSUMED, or STALE-DECLARATION,
and only the last two are findings. The declaration allowlist must match
reality exactly: a missing entry fails and so does an entry that outlived
its subject, because a stale allowlist is how a gate quietly stops checking
anything.

Surfaces: the two gRPC services, whose consumption is derived by scanning
adapter bodies for calls through the generated client, and the dashboard
HTTP API, matched between the registerXRoutes call sites and the path
literals the bundled client calls.

Findings on the current tree, all deliberate and now declared:
ListCaptures and ListUndispatchedCaptures are superseded by their streaming
variants -- staterpc's client calls StreamCaptures -- so no production
client reaches the unary RPCs.

Three bugs this tool found in itself, each recorded because each is the
class of error that makes a conformance check worse than none:

- Joining RPCs to adapter methods by name silently reported live RPCs as
  unconsumed, because adapters do not map one-to-one: StoreClient.Get calls
  GetSession, List calls ListSessions.
- Reflecting over the client value rather than the pointer reported zero
  methods, hence the whole surface unconsumed.
- Treating the asset mount and the health probes as dashboard API routes
  reported four healthy routes as undeclared; they have different consumers
  and are out of scope for this surface.

The consumer extractor fails loudly on a call shape it cannot parse rather
than under-reporting, and every check is negative-tested: a route, an RPC,
and a removed consumer are each injected, confirmed to fail for the right
reason, and reverted. The declaration staleness rule is tested too.

Advisory when run directly; task check runs it -strict. See
docs/prds/contract-conformance-audit.md.
2026-09-15 09:41:20 +10:00
sam 33975060d2 test(archied): assert provider-disable warning by attribute, not message text
TestResolveProviderSecretsDegradesInsteadOfFailing matched a substring of the
warning's prose. Assert the structured provider attribute instead so a
rewording can't break the suite while a missing warning still fails it.
2026-09-15 05:25:12 +10:00
sam a5d7af837e fix(deployments): drop stray services.gateway.poll_interval key
ServiceConnection only has target/target_token; poll_interval was never a
real field there and never did anything. Caught by the new unknown-key
check in the configuration loader (TestDeploymentOverlaysHaveNoUnknownKeys).
2026-09-15 05:08:05 +10:00
sam d4e7d67051 feat(archied): warn at boot when the config file has unrecognised keys
Surfaces configuration.Document.UnknownKeys as a warning naming the
offending keys. Stays a warning, not a boot failure, per
docs/architecture/configuration.md's startup policy: only an invalid
config is fatal, and a stray key is far more likely an operator typo in an
otherwise-working file.
2026-09-15 05:07:57 +10:00
sam 9b2fb4a82c feat(configuration): report config keys no decode target consumed
decodeTOML discarded toml.DecodeFile's metadata, so a misspelled or
renamed key parsed, validated and silently did nothing. Document.UnknownKeys
now carries the dotted key paths a loaded file's decode targets left
undecoded.

One file feeds two decode targets (&doc.Config and &doc.Scheduling), so a
key legitimately owned by one shows up as undecoded in the other -- a key
is only reported when both leave it undecoded (unknownKeys intersects the
two sets), which is what keeps a valid [scheduling] block from being
misreported as unknown on every config that uses it.

YAML config sources are unchanged for now (no equivalent metadata hook in
the yaml decoder); this covers the TOML path, which is what
config.example.toml, every shipped deployments/*.toml profile, and
install.sh's generated config.toml all use.
2026-09-15 05:07:54 +10:00
sam 9942ac4487 test(archied): assert flush behaviour instead of grepping main.go
TestSubscribeAgentEventsFlushesBeforeReturning only checked that main.go's
source text contained the string "flush task event subscription", so it
passed whether or not subscribeAgentEvents actually flushed and failed if
the message were merely reworded. Replace it with a real embedded-NATS
test: subscribe, then publish on a separate connection with no delay, and
assert the event arrives -- repeated to make the SUB/PUB ordering race
observable. Mutation-verified: removing the flush call makes this fail
reliably (multiple iterations lose the race) while the text-grep version
would have kept passing.
2026-09-15 05:07:26 +10:00
sam bb4e2f9135 fix(logging): keep the live descriptor open across a failed rotation
rotate() closed the current file before attempting the rename+reopen, so
when the reopen failed (a full disk, a permission change) every write
afterward went to a closed *os.File and was silently dropped -- the sink
stayed permanently broken rather than recovering once the transient
condition cleared. Keep the old descriptor open across the rename/reopen
and only close it once the new one is confirmed, so a write during (or
after) a failed rotation always lands somewhere.
2026-09-15 04:55:48 +10:00
sam 6f26d790ba fix(email): stop dropping the first paragraph of plain-text bodies
extractBody re-split the already-isolated body on the first blank line it
found, intending to strip a stray content-header block some MTAs emit.
That heuristic can't distinguish a header block from an ordinary blank
line between paragraphs, so any multi-paragraph plain-text email silently
lost everything before the first paragraph break.
2026-09-15 04:55:44 +10:00
sam ce4f43dd8d fix(config): deep-copy Image.Hosted/Image.Local in Config.Clone
Clone's own doc comment promises mutating the clone cannot touch memory
shared with the original, but Image.Hosted/Image.Local were left as a
shallow map copy -- a runtime overlay or dashboard PATCH decoding into the
clone could mutate the published config's image provider maps.
2026-09-15 04:38:54 +10:00
sam bc430fa50d fix(secret): recover a panicking secret engine instead of crashing
Registry.Resolve and Getenv called engine.Resolve directly with no panic
recovery, so a defective interpreted engine (sops/Vault plugin) took the
whole daemon down at boot when resolving a provider credential
(provider_secrets.go's only caller has no recovery of its own). Wrap both
call sites in yaegiutil.Safe, the same recovery every other Yaegi
extension surface in this repo already uses.
2026-09-15 04:38:51 +10:00
sam 97a9ed7ea5 fix(webui): enforce CSRF/origin gate on binding and mapping mutations
handleTaskAction, the config and workflow write handlers all call
authorizeTaskMutation before mutating, but the binding and mapping
create/update/delete/approve handlers never did, leaving those dashboard
endpoints reachable by a cross-origin request with no CSRF header -
contradicting dynamic-curators.md's documented mutation contract.
2026-09-15 04:35:04 +10:00
sam eaa58dfe73 fix(daemon): guard binding dispatch loop against nil dispatcher/creator
BindingDispatcher and BindingTaskCreator are documented "optional: nil
disables the dispatch loop", same as Bindings, but dispatchBindings only
checked Bindings before dereferencing the other two. Any composition that
wires Bindings without also wiring both handles panicked on the first
dispatch cycle.
2026-09-15 04:35:00 +10:00
sam 164886308b 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).
2026-09-15 03:35:45 +10:00
sam 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 89cfa44 introduced. archied setup can now write a
provider reference to any engine (-provider-secret-ref bws:OPENAI_API_KEY), and on
a machine without that engine the config used to load clean and then brick the
daemon. It now starts with that provider disabled and a warning.

The comment on templateDefaultActiveProvider described the old fatal behaviour and
is corrected rather than left to mislead the next reader.

All three behaviours are mutation-verified: returning an error again, accepting a
half-named reference, and disabling without clearing the reference each fail the
corresponding test. The red was an assertion failure, not a compile error -- the
logger parameter was threaded through first so the new test could be run against
unchanged behaviour.
2026-09-15 03:28:35 +10:00
sam 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.
2026-09-15 03:23:08 +10:00
sam 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.
2026-09-15 03:15:53 +10:00
sam c9970bb5de docs(prds): decide example-config drift is gated, not generated
Records why config.example.toml and deployments/*.toml should not be generated:
the example documents 137 keys (active and commented) and its hand-written
comments are the file's purpose, TOML round-tripping does not preserve them, and
docs/prds/config-schema.md forbids building on config.Config because that struct
is scheduled for dissolution. generated-documentation.md:225 additionally
prohibits adding a hardcoded type list to docsgen. The deployment profiles are
curated complete-configs setting 3-46 keys, not projections of the example.

What the check did find is worth more: decodeTOML
(internal/infrastructure/configuration/decode.go:27) discards the TOML metadata,
so unknown config keys are silently ignored -- a misspelled key parses,
validates, and does nothing. That is fixed by reporting Undecoded() across every
target a file feeds, as a warning rather than a fatal error, because
configuration.md's settled startup policy is that a missing credential degrades
and only an invalid config stops the daemon.

Also withdraws a premise this session used: a measurement claiming 17 keys were
set by a profile but documented nowhere was an artifact of an extractor that
stripped comment markers. providers.<name>.api_key_env is a real documented
field (internal/config/config.go:180) and [[identities]] is documented. The
decision does not rest on it, and the withdrawal is recorded in the document so
the premise is not reused.

Filed with it: config-5 (unknown keys ignored, P1) and docs-and-tools-1
(generated-documentation.md documents a four-subcommand docsgen that
tools/docsgen/main.go does not implement, including the `check` mode the same
document names as the remedy for its own admitted "drift is ungated" gap).
2026-09-15 02:52:24 +10:00
sam 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
1f3f54b, so setup.Params is consulted before each question instead and the
prompts are only reached for answers nothing supplied. Run stays a wrapper
passing the zero value, so the package's existing tests keep passing untouched.
No environment variable is consulted anywhere: flags and prompts are the only
two ways an answer arrives.

--defaults is a known-valid unattended baseline, not "each prompt's own default".
That cannot work, and the test proves it: the provider step's first option is
OpenAI, whose model prompt hard-errors on an empty answer. The baseline therefore
covers every required answer and leaves optional ones to answer themselves as
"skip" -- ollama is the only keyless provider, so an unattended install boots
without needing a secret.

Two gaps closed after review rather than left as accepted work:

- A cloud provider was not configurable without a terminal, because the provider
  API key had no typed parameter: unattended setup could only ever pick the
  keyless self-hosted provider. Params.ProviderAPIKey and -provider-api-key fix
  that. The key goes to the env file and TOML carries only the secret reference.
- The write order was unpinned. Inverting installValidatedConfig's two writes --
  committing secrets before the config -- left every test green, so nothing held
  the invariant the SecretSink contract states. The new
  TestInstallValidatedConfig_ConfigWriteFailureLeavesNoSecret fails on that
  inversion; the existing validation-failure test does not cover it.

Also fixed three lint failures in the first pass (gocyclo on RunSetup, and two
ineffectual `choice` initialisers): RunSetup's flag surface, the flag-to-Params
mapping, the prompter choice and the existing-config read are now separate
functions, which is the real fix for the complexity rather than a suppression.

The setup flow no longer hand-rolls its own answer format: -telegram-user-ids
reuses setup.ParseTelegramUserIDs, the same parser the prompt path uses, so the
allowlist cannot be parsed two ways.

Found by an adversarial package sweep (temp tracker: config-1,
repo-root-deployment-2, .local/issue-tracker/). Plan of record:
.local/issue-tracker/design-archied-setup.md. install.sh still generates its own
config; that is phase 2 and is not claimed here.
2026-09-15 02:52:24 +10:00
sam 1f3f54bedd test(archied): pin the wiring these fixes depend on and drop text coupling
Two fresh-context reviews of the preceding five fixes found that the tests were
mostly sound but that three things were not: one harness was coupled to shell
source text, one assertion was coupled to a tool count, and -- worse -- the two
changes carrying the most weight were pinned by nothing at all.

Composition order. review_pr worked only because Run builds the worktree manager
before the gateways; no test observed it. Reverting the order left every test
green while the daemon silently stopped offering review_pr, because the producer
guard then returns nil instead of advertising a broken tool. Pin the order by
source position, matching the existing
TestSetupBackendsRegistersContainerCleanupAfterNATS, since no runtime seam can
see it. methodBody now resolves package-level funcs as well as methods.

Composition wiring. The daemon fix's whole point is that resolved routing
bindings reach the worker, yet nothing verified that buildDaemon puts them on the
daemon: with b.kindWorkflows replaced by nil, only the new test fails and both
the daemon and worker packages stay green. That is the "tested in isolation,
never verified wired" shape this work exists to remove, so pin the hop.

The wire contract itself. taskrun.Request's json tags are the interface between
two binaries, and a same-type round trip cannot see a tag rename. Assert the
emitted keys literally; renaming one now fails with the key list.

Brittleness. selfHostConfig no longer string-matches install.sh's heredoc opener
or assumes the delimiter is EOF, and no longer hand-substitutes a copy of
forge_block's output -- it discovers heredocs by shape and selects the one
declaring [nats], a table the assertions never touch. Verified against four
behaviour-preserving refactors that previously failed: renaming the delimiter,
reordering the redirect, factoring the path into a variable, and <<-. The two
[services.gateway] source greps are gone: defaults.go already supplies that
target, so there was no behaviour to pin. review_pr is asserted present by name
rather than by entry count, so a sibling review tool cannot turn it red.

Also carry the published request's decode error instead of discarding it, so a
payload-shape break reports as itself rather than as an empty routing binding.

Every new test was verified non-vacuous by reintroducing the defect.
2026-09-15 02:18:30 +10:00
sam 669f98a059 fix(daemon): carry kind/label routing bindings to the process that routes
An operator's kind/label -> workflow overrides were decoded, validated and
installed into the DAEMON's package-level state via
workflow.SetKindWorkflows/SetLabelWorkflows -- but workflow.Route's only
production caller is app/agentworker/task_execution.go, in the separate
archie-agent process. The bindings never crossed the boundary, so every
configured override was silently ignored and routing always fell back to the
built-in defaults (bug -> tdd, feature -> feasibility, bootstrap -> bootstrap).

Carry the resolved bindings on taskrun.Request, mirroring how MCPServers already
crosses this boundary, and apply them in the worker before Route is called.
Resolved values are carried rather than file paths, so the worker does not need
the routing files to be readable in its sandbox. nil still means "use the
built-in defaults", so this is backward compatible for any request built by an
older daemon.

routeTask is a named seam for that install-then-route step. It mutates
package-level routing state, which is sound here because each archie-agent
process is task-scoped and ephemeral; if the worker ever served more than one
task that assumption would need revisiting.

Tests are mutation-verified: removing either the two Set calls in routeTask or
the two request fields in runViaAgent reproduces the exact assertion failures
the lane observed red-first, so neither test is vacuous.

Found by an adversarial package sweep (temp tracker: workflow-engine-1,
.local/issue-tracker/).
2026-09-15 02:13:33 +10:00
sam f54f130065 fix(install): emit an active State Store target so a fresh install can boot
install.sh produces config.toml two ways, and neither emitted an active
[services.state].target. The self-host branch writes a hand-rolled heredoc with
no [services] section at all, and the non-self-host branch rewrites only the
[forge] block of config.example.toml -- where [services.state] sat commented
out. openStateStoreAdapter requires a target, so a freshly installed archied
aborted at startup with no way to boot from the config the installer had just
written.

Activate [services.state] with a loopback target in both sources, which is the
producer fix: the config the installer emits is the invalid state, so it is
corrected where it is generated rather than defended against at the daemon.
[services.gateway] is activated alongside it for the same reason it is safe to
-- internal/infrastructure/configuration/defaults.go already defaults that
target to 127.0.0.1:8585, so declaring it changes no resolved value and only
makes the emitted config explicit.

Add TestInstallerGeneratedConfigHasServiceTargets, which parses what each
branch actually produces: config.example.toml through the real config loader,
and the install.sh heredoc reconstructed with its shell expansions resolved.
Both assertions are red-first -- with the sources reverted the test fails on
both branches with the boot-fatal message.

Found by an adversarial package sweep (temp tracker: repo-root-deployment-1,
.local/issue-tracker/).
2026-09-15 02:10:31 +10:00
sam 372f80628a fix(archied): stop advertising review_pr when no reviewer can run
review_pr was registered on every channel and failed on every call with
"worktree manager is not configured". Two independent causes, one contract:

The daemon ran setupGateways before buildTreesAndIdentities, so setupGateways
reached prReviewer() while b.trees was still nil and captured it; the memoised
reviewer then held that nil for the process lifetime. Build the worktree
manager before the gateways, which is the ordering the reviewer depends on.

Ordering alone cannot fix the standalone Gateway, which calls prReviewer() and
never builds trees at all. Have prReviewer() return nil when b.trees is nil, so
a reviewer that can never run is not produced. That is what
gateway.ReviewTools' existing nil-reviewer guard always intended -- "a tool that
cannot run must not be advertised" -- but the guard never fired because the
daemon never passed nil.

TestPrReviewerIsMemoized asserted a trees-less boot yields a non-nil cached
reviewer, encoding the broken precondition as expected behaviour, which is why
a green suite hid this since review_pr shipped. It now gives the boot a real
worktree manager so its actual subject -- one shared in-flight set across
channels -- stays pinned, and two tests are added: one for the nil-trees
invariant, and one that composes the real wiring (prReviewer -> ReviewTools)
and asserts review_pr is registered only when the reviewer can run.

Found by an adversarial package sweep (temp tracker: app-archied-5,
.local/issue-tracker/).
2026-09-15 02:08:46 +10:00
sam 498fc011a4 fix(store): keep an empty binding secret empty so a partial edit cannot erase it
UpdateBinding documents that an empty caller Secret is preserved by
COALESCE(NULLIF(?, ''), secret), and binding.ValidateForUpdate explicitly makes
an empty Secret mean "keep the current one". The sentinel was defeated before
the SQL saw it: encryptBindingSecret ran first and, with a binding cipher
configured, sealed the empty string into a non-empty
"arcie-binding:v1:<fp>:<base64>" envelope. NULLIF(?, '') then no longer matched,
COALESCE took the envelope, and a routine PATCH that changed only name/source/
workflow overwrote the shared HMAC secret with the encrypted empty value. Once
re-approved the binding could never authenticate an inbound webhook again, and
nothing surfaced the loss.

Fix it at the producer rather than by re-testing emptiness at the SQL layer: an
empty secret is the store's "no secret" sentinel, so it stays empty and the
existing COALESCE guard keeps working. decryptBindingSecret already treats an
empty stored value as nothing-to-decrypt, so this is symmetric.

The only existing coverage, TestUpdateBindingPreservesSecretWhenEmpty, opens the
store without a cipher and so never exercised this path. Add a table-driven test
over the cipher path covering both directions -- an empty caller secret must
preserve the stored secret, and a supplied one must still replace it, so the fix
cannot degrade into "updates never change the secret".

Found by an adversarial package sweep (temp tracker: persistence-1,
.local/issue-tracker/).
2026-09-15 01:51:07 +10:00
sam b0e7b03ca1 fix(tools): judge the rm guard by base name so absolute paths cannot bypass it
checkRecursiveDelete compared the raw segment name, `seg.Name != "rm"`, while
every sibling rule in the same table resolves the command through baseName --
checkMkfs, checkBlockDeviceWrite, checkKillAll, checkSystemPower,
checkSelfTermination and checkDaemonLaunch all call baseName(seg.Name), and
baseName's own doc says its purpose is that /sbin/reboot and reboot are judged
the same. The test suite already pinned that convention for /sbin/poweroff.

Because tokenise yields the raw first word, `/bin/rm -rf /` produced
seg.Name == "/bin/rm", the rule declined, no other rule matched, and Hardline
returned nil. Since provider/builtin calls command.Hardline on the shell tool's
command field before every execution, an absolute path defeated the
recursive-root-delete gate entirely. `/bin/rm -rf /etc` (any critical path, not
just the root) was equally reachable; an overlay probe confirmed both, and
confirmed the sibling /sbin/poweroff case was already correct.

Resolve through baseName, matching the rest of the rule table, and add table
cases for absolute-path rm plus an allow case for an ordinary absolute-path
recursive delete so the normalisation cannot over-block.

Found by an adversarial package sweep (temp tracker: tools-command-1,
.local/issue-tracker/).
2026-09-15 01:51:03 +10:00
sam db18d2675a feat(ratelimit): wire per-identity inbound rate limiting into the gateway
internal/ratelimit was fully built (sliding-window limiter, ticker-driven
eviction) but had no consumer, leaving multi-identity deployments with no
inbound request budget on any channel (archie-core-6wxb / GH #797).

Adds Message.SenderID (Telegram numeric user ID, SMTP from address, or
webhook route path -- the closest thing webhook has to a caller identity),
threads it into Router.Route/RouteStream via a shared checkRateLimit, and
wires an opt-in [chat.rate_limit] config section through bootstrap with the
documented EvictStale ticker.
2026-09-15 01:24:20 +10:00
sam 71c890b89b Merge pull request #828 from samcharles93/feat/cron-scheduling-config
feat(config): [scheduling] block, its translator, and the events-bus sink adapter
2026-09-15 00:26:59 +10:00
sam 8301a949ee Merge pull request #827 from samcharles93/fix/webui-config-projection-chat-setup
fix(webui): count every chat front-end in the published projection
2026-09-15 00:26:55 +10:00
sam b894951e62 Merge pull request #826 from samcharles93/feat/deep-research-design
docs(research): design a deep-research fan-out capability
2026-09-15 00:26:51 +10:00
sam 83890e0065 Merge pull request #825 from samcharles93/fix/webui-per-identity-forges
fix(webui): publish per-identity forges so multi-identity task rows keep their links
2026-09-15 00:26:46 +10:00
sam f78272fb17 chore(release): archied v1.25.0 archie v1.25.0
deploy / gate (push) Failing after 3m37s
deploy / build-and-push (push) Skipped
deploy / dist-zip (push) Skipped
2026-09-15 00:22:15 +10:00
sam 812ad71ac7 Merge pull request #830 from samcharles93/crew/docs-audit
docs(modules): fix example install path; ModuleDir has no default
2026-09-15 00:21:26 +10:00
sam ba0b1969d0 Merge pull request #829 from samcharles93/fix/update-component-tags
fix(update): build each component from its own approved release tag
2026-09-15 00:19:44 +10:00
sam 853aef4eee chore(docs): correct the required Go version to 1.27.0
go.mod requires go 1.27.0; the guidance file still said 1.26.5.
2026-09-14 23:38:15 +10:00
sam 355e1c64b2 fix(scheduling): respect configuration ownership 2026-09-14 23:25:09 +10:00
sam 3a33caf45f fix(update): build each component from its own approved release tag
Components are independently versioned (RELEASING.md), so the newest
archied/v* and archie/v* tags usually sit on different commits --
gateway-only releases are the norm. The installer required both tags to
resolve to the same commit whenever both components changed, which
refused every update once the two newest releases diverged
(archied/v1.24.0 at 037326a, archie/v1.23.0 at 43bc29f).

Build each changed component from its own tag's commit instead: daemon
binaries and the adapter refresh from the daemon release, the managed
worker image from the agent release.
2026-09-14 23:25:06 +10:00
sam b2bf33e5db test(archie-ui): drive the projection through the real producer in the smoke suite
The real-process suite hand-wrote the ConfigView document into the store, so it
asserted on a shape it built itself and could not have caught a producer that
forgot to publish a field. Both values GitHub #821 named -- chat.show_tool_calls
and the setup operator name -- arrive in the extracted process through that
projection and nowhere else.

seedStore now renders the document with webui.BuildConfigView, the same function
the daemon calls, from a config.Config, and a helper republishes between turns
the way a config reload does. The suite additionally streams a turn through the
fake Gateway's tool event and asserts the resulting frames twice: with
show_tool_calls on the frames carry the tool, and with it off they do not. That
is the browser-visible behaviour the issue described, asserted on what the UI
process actually sends.

Verified the new assertions are sensitive rather than vacuous: emptying
ConfigView's chat section makes the "on" case fail on a missing tool frame and
the checklist case fail on an empty operator, which is the original bug.
2026-09-14 10:55:55 +00:00
sam 73aa86181e fix(webui): count every chat front-end in the published projection
GitHub #821 reported two dashboard behaviours degrading in the extracted UI
process because webui.Server.Cfg is nil there. Half of it was already closed:
03afd2e ("take configuration off the dashboard server", on main since
2026-09-12) moved the daemon's ConfigView renderer off webui.Server, gave
ConfigView a chat section carrying show_tool_calls, the operator name and a
channel flag, and pointed chatShowToolCalls and handleSetup at the projection.
The chat page and the checklist do read published values now.

The channel flag was still wrong. It was derived from telegram and the webhook
gateway only, while the daemon's own channel status manager lists three
front-ends and counts the inbound mail gateway as one. An email-only
deployment therefore read as configured on /api/channels and unconfigured on
the setup checklist at the same time, and the checklist told the operator to
connect a channel they already had.

Fix at the producer: config.ChatConfig gains FrontEnds, the single definition
of "this front-end is configured", enumerating telegram, email and the webhook
gateway. Both the published projection (ChannelConfigured) and the daemon's
channel descriptors (status.NewManager) now derive from it, so the two surfaces
cannot drift apart again. A front-end added to [chat] is counted by both or
neither. Whitespace-only values are not configured: an env var name of " "
resolves to nothing and " " cannot be listened on.

The setup checklist stays. It renders each step as a title, a detail and a done
mark with no control behind it, so it answers "what is this deployment
missing?" rather than promising to fix it; the process that cannot apply setup
never offered to. Removing it would delete the one surface that distinguishes a
fresh deployment from a finished one, and the values it reads already cross the
boundary in ConfigView at no cost to the daemon. The write path stays descoped
for Phase 3 (docs/prds/ui-service-boundary.md, /api/config (write) row): the
checklist reports configuration, it does not change it.

docs/prds/ui-service-boundary.md records that judgement and corrects the
"Real-process evidence" paragraph, which claimed the channel flag covered every
chat channel.
2026-09-14 10:53:16 +00:00