Commit Graph
1082 Commits
Author SHA1 Message Date
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
sam a2cca6088e feat(cronevents): adapt the events bus to scheduling.Sink
A scheduled run has no task, no chat turn and no workflow behind it, so its
emitted events are the only trace it leaves -- and the engine's Sink is the
emitter shape of a bus it deliberately does not import. Something has to turn
one into the other; this is that seam.

  - Sink(mode, bus) returns a sink over the bus for "bus", and nil for
    "none"/absent or a nil bus. Nil rather than a no-op sink keeps
    "emission is off" visible to whoever reads the composition, and it is
    the configuration the engine documents as valid: it still runs, it is
    just unobservable.
  - The published event carries the engine's own Kind/Detail/Data and no
    task-scoped identity. A cron run has none, and borrowing the emitting
    daemon's would attach it to an unrelated task's timeline.
  - An unrecognised mode is an error; the loader rejects it first, but a
    hand-built config must not silently disable observability.

TDD: the sink tests were written first and failed on assertions (Sink("bus")
returned nil; an unknown mode was accepted), not on compilation. The
end-to-end test drives a real engine on an injected clock and subscribes to
the bus, so the Emit -> Publish path is proven rather than assumed -- no
sleeps, no wall-clock deadlines.
2026-09-14 10:51:47 +00:00
sam 4d838b9fb1 feat(configuration): translate [scheduling] into scheduling.EngineConfig
The engine needs a fully-resolved configuration, not zero values it has to
second-guess. Add the translator the wiring slice then hands to
internal/app/archied:

  - TranslateScheduling resolves unset tunables from the domain's own
    Default* constants rather than a second copy here, so the two cannot
    drift.
  - A negative tunable is reported as a startup error wrapping
    ErrInvalidInput, matching validateCapture and validatePollInterval.
    Clamping was rejected: it runs something other than what the operator
    wrote, which is how a misconfiguration stays invisible.
  - Events and Clock stay nil. This package owns no bus and no clock --
    attaching them is composition -- and the engine documents a nil sink as
    a valid configuration: it still runs, it is just unobservable.

applySchedulingDefaults and validateScheduling keep defaulting and
validation separate, the split applyDefaults' own doc explains: the load
path applies both, Validate applies only the latter.

TDD: the translator tests were written first and failed on assertions
(Interval = 0s, want 1m0s; negative values accepted silently), not on
compilation.
2026-09-14 10:51:41 +00:00
sam 57d8d48279 feat(config): add [scheduling] config block
The cron ticker engine had no path from operator input to runtime. Add the
four settings its EngineConfig is built from, as a declared type rather than
loose root fields:

  interval, max_parallel, job_timeout, events_sink

Every field is optional and defaults independently, so an absent section is
valid and resolves to the engine's own documented constants. Zero means
"unset, give me the default", which is why a negative value is a startup
error rather than a clamp -- it is the only way an operator can name an
unusable value deliberately, and running something other than what was
written is how a misconfiguration stays invisible.

events_sink is a simple on/off, "bus" or "none": the engine's Sink contract
is the bus's emitter shape and there is exactly one bus in the process, so a
named-sink registry would be scaffolding with one entry. Absent resolves to
"none", the same shape applyMemoryDefaults and applyNATSDefaults use, so a
resolved config has one spelling for "not publishing" rather than two that
happen to mean the same thing.

config.example.toml documents the block in the house style, commented out
like [[repos]] and [capture]: a live example would be a default the operator
never chose.
2026-09-14 10:51:36 +00:00
sam 87d8d39321 fix(webui): publish per-identity forges so multi-identity task rows keep their links
Task rows in a deployment configuring [[identities]] rendered no forge links.
ConfigView carried the default identity's forge alone, so resolveForge
(api_tasks.go) withheld the links entirely rather than pointing every row at
the wrong forge -- production behaviour since the UI process cutover
(archie-core-8cda.5.4), where the dashboard runs in a process with no
config.Holder. archie-core-ml30 then removed webui.forgeConfigForTask and its
test, which resolved a task's forge from config.Config and had no reachable
caller once the holder was gone.

Fix at the producer, not the renderer. ConfigView gains `identities`: each
configured identity's forge type and host, plus the repositories it owns. That
is the whole answer to "which forge owns this task", and it is a projection the
daemon already rebuilds and republishes on boot and on every reload, so nothing
new is needed on the publish side. Only coordinates and repository names cross
-- an identity's token is a secret reference and stays out, which the new test
asserts alongside the existing leak guard.

resolveForge ports the matching rules recovered from 5b91a3a's
forgeConfigForTask onto that projection: an exact identity name first, then
repository ownership, and an ambiguous repository -- two identities claiming the
same owner/name -- falling back to the default forge rather than inventing a
link. Two deliberate departures from the recovered shape: it indexes the
identity list once per request instead of rescanning config per task, since the
projection supplies repo slices it can key on directly; and a document that
reports multi-identity but carries no per-identity forges still withholds,
because that is what an older daemon published and guessing there is the
original bug. The recovered code's first-wins scan for a duplicated identity
name is preserved.

Tests: the projection's per-identity forges and their secret-freedom; the three
matching rules and both fallbacks through resolveForge; every row of a
multi-identity GET /api/tasks carrying the right forge's link; and the real
archie-ui binary driven over HTTP against a multi-identity projection, which
fails on the pre-fix resolver with three unlinked rows.
2026-09-14 10:36:29 +00:00
sam d7304e3897 docs(research): design a deep-research fan-out capability
Records the design for an orchestrator that spawns 1..N subagents to
research in parallel, collates their findings, and returns one cited
report grounded in web search and web fetch.

Grounds every claim against the tree: web search has no implementation,
fan-out has no owner (agentloop runs one mission; the only nested loop
is the PR reviewer's Subagent), and no operator-push delivery path
exists. Maps the six stages, the three candidate shapes, and the six
decisions -- most importantly that citations are rendered from a source
store rather than model prose, since the disclosed failure modes and an
EMNLP 2026 error localisation both put the majority of final-report
errors at the orchestrator.

Adds a deterministic cross-check and a separate citation pass, neither
of which appears in any surveyed implementation.
2026-09-14 10:29:08 +00:00
sam 166972b3a0 Merge pull request #824 from samcharles93/fix/releaseupdate-test-race
test(releaseupdate): fix a data race and a sleep in the install-cancellation test
2026-09-14 20:19:34 +10:00
sam b11086e926 test(releaseupdate): fix a data race and a sleep in the install-cancellation test
Found by a full-repo 'go test -race ./...' sweep. internal/releaseupdate was
the only package that failed it.

The race: blockingInstallerStub.Install assigned s.gotCancelled lazily --

    if s.gotCancelled == nil { s.gotCancelled = make(chan struct{}) }

Install runs on the caller's goroutine (Service.Install calls it), while the
test goroutine reads s.gotCancelled. Two goroutines, one unsynchronised field.
The channel is now built by a newBlockingInstallerStub constructor, so no
goroutine ever writes it after the stub is handed to the test. Fixing it at
the producer rather than guarding the read.

The sleep: the test asserted 'the installer did not observe cancellation' with

    select { case <-s.gotCancelled: ... case <-time.After(50*time.Millisecond): }

which is a race against the clock to prove a negative, and is weaker than the
thing it stands in for -- a channel nothing has closed is simply not ready.
It is now a select/default, asserted synchronously.

The assertion was also unfalsifiable in one direction: if the channel were
never closed at all, the old test passed for the wrong reason. It now also
asserts the positive half -- after Install returns, the detached context is
released, so the observer MUST have fired -- which is what makes the negative
check meaningful.

A second constructor of the same stub is updated too; it relied on the lazy
assignment and would have closed a nil channel.

Reproduced before the fix (race detector, same test):
  WARNING: DATA RACE ... service_test.go:201
  --- FAIL: TestServiceInstallSurvivesCallerContextCancellation
After: 3/3 clean runs under -race.
2026-09-14 10:14:27 +00:00
sam 8db744ed6e Merge pull request #822 from samcharles93/feat/cron-delivery-runners
feat(crondelivery): cron delivery runners and kind-routing router
2026-09-14 20:06:36 +10:00
sam bb1aea0b30 feat(crondelivery): add chat, workflow and routing cron runners
The ticker engine had no work to dispatch. Add the delivery half as a new
infrastructure package with three scheduling.Runner implementations:

  - ChatCourier sends a job's payload text to its target chat.
  - WorkflowTask submits a job as a unit of work.
  - Router dispatches on the job's kind and is the single runner the engine
    is given, so the engine stays unaware that more than one delivery exists.

Nothing here talks to a channel, a broker or a forge. The outbound send is
an injected Courier function and work intake is a narrow TaskSubmitter
interface, so which transport carries a message stays the deployment's
decision rather than the cron's, and the package is testable without a
network.

An unrecognised kind is refused at the gate, not failed: it emits
KindJobError with phase "dispatch" in the engine's own data shape and
returns nil, so a misconfigured job is visible without being reported as a
job that tried and broke. A nil sink still refuses, just unobservably.

Every runner returns the context error on a cancelled run and produces no
side effect, so the engine's bounded shutdown drains rather than waiting
out the per-run timeout.

Tests exercise a real cronstore on a temp path, including the epic's
headline daily-status scenario end to end from a persisted due job through
the router to the delivered message.
2026-09-14 09:54:41 +00:00
sam 08cfe837a9 feat(cronstore): add job kind discriminator and bump schema to 2
Jobs need a discriminator for the delivery router to dispatch on, and
JobSpec had none. Add a top-level Kind field with values "chat" (default
when empty) and "workflow".

The empty value is load-bearing: every job written before this field
existed carries no kind and must keep delivering as a chat message, so an
empty Kind resolves to "chat" rather than being rejected.

DisallowUnknownFields means this additive change must bump schemaVersion,
so it goes 1 -> 2. A version-1 file still loads — Kind reads back empty —
which a test pins, because the alternative is that every existing cron job
stops firing on upgrade.

The store does not interpret the value: an unrecognised kind is persisted
verbatim and refused by the router, which owns the kind-to-runner mapping.
2026-09-14 09:54:41 +00:00
sam 93434d177d Merge pull request #823 from samcharles93/fix/quality-gate-clean
fix(test): make task check pass clean - remove a doc-prose test and a startup race
2026-09-14 19:49:54 +10:00
sam c2ebcb8298 test(archied): stop racing state-store startup against a wall clock
TestRunStateStoreAcceptsEnvironmentToken wrapped the whole of RunStateStore --
SQLite schema init and the serve loop -- in a 200ms context deadline, so
whether it passed depended on how fast the disk was. Measured before the fix:
6 failures in 12 consecutive runs. A gate that fails half the time teaches
people to ignore it, and the failure it reported ('store: init schema:
context deadline exceeded') named a time budget, not a defect.

Cancellation is the assertion, so the test now cancels and then asserts:
the call must not return before cancellation (that would mean startup refused
the config, the thing this test exists to catch) and must return within a
generous grace once cancelled. The graces bound 'did startup reject us', not
'machine speed'. Measured after: 12 passes in 12 runs.

Also applies the canonical gofumpt and 'go fix' output to
internal/infrastructure/staterpc/dial.go, cmd/archie-ui/main_test.go and
internal/releaseupdate/check_script_test.go. task check runs gofumpt -w over
the tree, so leaving these unformatted made the gate rewrite unrelated files
mid-run and report dirty state for changes it had made itself.
2026-09-14 08:09:14 +00:00
sam 4b250ba929 test(plugin): stop asserting documentation prose in a test
TestPluginEngineRuleIsCanonicalAndSharedByAgentInstructions read
ARCHITECTURE.md and CLAUDE.md and failed if their prose did not contain a
particular heading and link. That is not a behaviour check: it makes an
agent-instruction file load-bearing for the build, so editing documentation
can break compilation of the test suite, and a doc drift becomes a red gate
that says nothing about the code.

The genuine invariant -- that an engine family has one owner that both
registers and resolves it -- is asserted on the AST by
TestEngineFamilyInspectionRejectsInvalidShapes, which is untouched.

Removes the readTestFile helper it was the only caller of.
2026-09-14 08:09:14 +00:00
sam cc0dc3915a chore(releaseupdate): adopt go fix errors.AsType rewrite 2026-09-13 15:00:36 +10:00
sam 27203c6523 fix(build): gate the tools module read-only in task check
Nothing in the delivery gate entered tools/, so its dependency drift was
only ever discovered by a command that silently repaired it, dirtying the
tree with an unrelated diff. task check now runs test:tools.

-mod=readonly is passed explicitly on every documented tools command: a
developer's global GOFLAGS=-mod=mod in go env overrides the toolchain
default and re-enables the rewrite.

Also corrects the archie-build-and-env coverage table, which claimed task
check omits task lint.
2026-09-13 15:00:33 +10:00
sam c12f6865d7 fix(tools): tidy the tools module against the root module
tools/go.mod replaces the root module, so its build list must satisfy the
root module's requirements. The root had moved on, leaving the tools module
unbuildable under -mod=readonly and silently self-repairing otherwise.

go 1.26.5 -> 1.27.0, ai-sdk v0.1.25 -> v0.1.32, modernc.org/libc
v1.74.4 -> v1.75.7, memory v1.11.0 -> v1.12.1, sqlite v1.56.0 -> v1.58.0.
2026-09-13 15:00:28 +10:00
sam fa8b608c1f chore(tools): add reachaudit reachability report tool
Reports completion state rather than intent: walks the tree, finds
code no shipped binary can reach, and attributes each finding to its
package with provenance and tracker status, so "is it implemented?"
and "is it reachable?" are separately answerable.

Advisory only; it never proposes deletion.

Also ignore .local/ (gh CLI state created inside the tree).
2026-09-13 14:48:17 +10:00
sam 9e73e9190a docs(curator): correct forge-tools dependency; record chat shell reach 2026-09-13 14:27:08 +10:00
sam d91ff8affa docs(curator): settle dynamically-defined curator definitions as data 2026-09-12 13:36:13 +00:00
sam 82d5cc267f Merge pull request #793 from samcharles93/fix/self-update-truthful-discovery
fix(update): make release discovery and the task-DB backup truthful
2026-09-12 14:04:08 +10:00
sam dad9389530 fix(update): back up the task store the daemon actually uses, or refuse
configured_task_db_path() read the top-level db_path and handed that literal
file to the watchdog as ARCHIE_TASK_DB_PATH (scripts/archie-update-install).
The daemon's task store is not that file: taskDBPath() in
internal/app/archied/main.go derives `<db_path>-tasks.sqlite`, and the
configured path is commonly a zero-byte placeholder beside it. The updater
therefore backed up an empty file, and a rollback would have restored that
empty file over the real database and deleted its -wal/-shm -- destroying the
task store the backup exists to protect.

That awk also matched db_path in any section. [indexing] owns its own
database, so a config listing it before the top-level key handed the watchdog
an unrelated database as ARCHIE_TASK_DB_PATH and backed that up instead.

Resolve the top-level key only, append the sibling suffix the daemon uses, and
refuse the update when the backup cannot be taken. The backup is the only
route back from a forward schema migration, so an update that cannot take one
must not start; it now runs as pre-flight, ahead of the adapter refresh, so a
refusal changes nothing on the host.

The tests drive the real script with a config file the harness controls; all
three fail against the previous adapter.
2026-09-12 03:01:58 +00:00
sam 176533d181 test(update): use errors.As in the check adapter harness 2026-09-12 02:59:52 +00:00