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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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 027dc99 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.
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.
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.
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
9a4f11c, 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.
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.
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/).
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/).
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/).
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/).
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.
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 8950bde, archie/v1.23.0 at 6cf73db).
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.
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:
19062a7 ("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.
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.
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.
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.
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 c65f9fb'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.
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.
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.
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.
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.
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.
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.
The check adapter resolved available releases with
`git -C "$REPO" ls-remote`, where REPO defaulted to $HOME/projects/archie-core.
With that checkout absent, moved or renamed, the swallowed error left Available
empty for every component -- which FormatSnapshot renders as "Archie is up to
date." A failed lookup therefore read as parity: the exact inverse of what an
operator needs to know.
Resolve releases from the forge API and `git ls-remote` against the remote
directly, with no working-tree state and no dependence on a clone existing. When
neither source answers, exit non-zero so the /update command reports that it
could not check instead of fabricating an up-to-date result.
A tagged release is announced whether or not it has a published artifact, and
Reference now records which source answered and the artifact state, so an
operator is not sent to a tag with nothing to download without being told.
This is what hid archied/v1.24.0 from the live host: tagged, never published.
The failure tests run the real script through a fake git and curl, so they
assert the source-selection logic rather than a stub. Against the previous
script all four fail, including the checkout dependency itself.
A self-update to 1.23.0 failed its health check and rolled back. The
adapter built and installed ./cmd/archied and nothing else, and the
watchdog restarted archied.service and nothing else, so the new daemon
came up against a State Store, Gateway and UI still on the previous
release. Since 1.23.0 archied cannot boot without a reachable State
Store (openStateStoreAdapter), which on a host that had never run one is
an immediate exit, a failed health check, and a rollback that looks like
a bad release rather than an incomplete deployment.
Install every binary the reference deployment runs, versioned off the
archied tag, and back each up so the rollback restores all of them
together. A binary with no .prev was introduced by the failed release, so
rollback removes it instead of leaving one behind that points at
processes the restored release does not run.
Restart in dependency order: the State Store owns archie.db and every
other process dials it, the Gateway serves the contract archied and the
UI dial, so each comes up before its consumers and stops after them.
archied itself is cycled unconditionally and a failed stop still aborts
the rollback, because a presence probe that guesses wrong must never
skip the stop that keeps a live process off the binary and the database
being restored. The siblings are best-effort, which is safe because the
adapter now refuses the update outright, before touching the host, when
a unit for one of them is missing, naming what to create.
install.sh had the same single-binary assumption, so a fresh install
produced a host that could not start either.
Closes archie-core-hbqk.
Emphasis stripping ran two non-greedy regexes, `_(.+?)_` and `\*(.+?)\*`,
over every paragraph, heading, list item and quote. Neither honoured
CommonMark's flanking rules, so any two markers on a line paired up and
both characters were deleted:
"allow_concurrent": true, "max_retries": true
-> "allowconcurrent": true, "maxretries": true
internal/webui/config_schema_test.go
-> internal/webui/configschematest.go
takes no *sql.Tx and returns *Result
-> takes no sql.Tx and returns Result
Agent reports relayed to Telegram therefore cited files that do not
exist, which reads as hallucination rather than as the transport fault
it is. Replace both regexes with a scanner that pairs delimiters by
CommonMark's left/right-flanking rules, including the rule that an
underscore may not open or close inside a word. Single "*" additionally
may not open on punctuation: CommonMark reads "*.go files in cmd/*" as
emphasis, and in a relay carrying globs and pointer types that costs far
more than a surviving marker.
closeCode ran the same stripper over fenced code. Code is verbatim by
definition, so it no longer does.
Separately, markdownToBlocks knew only fenced code, not CommonMark's
indented form, which models emit constantly. An indented block fell
through to the paragraph case, which space-joins lines, arriving as one
run-on line with its markers eaten on the way. Parse it as code, ending
at the first non-indented non-blank line, and refuse to let it interrupt
an open paragraph so a wrapped prose line stays prose. Paragraph
continuations are now trimmed before joining, so the join is one space
rather than the source indentation.
Closes archie-core-8x1r, archie-core-cvu6.
webui.Server declared Cfg *config.Holder with eight read sites, none of
which ran in the UI process: composition leaves it nil there. The field
survived because the daemon kept a webui.Server it never served, using it
to render the published ConfigView snapshot and to hold the readiness
probes (archie-core-ml30).
Split at the producer. LocalConfigView becomes webui.BuildConfigView, a
pure function over a ConfigViewInput the configuration owner assembles;
the DTO and its schema stay where the UI renders them. The daemon builds
that input from its own state (boot.configViewInput) and publishes the
result. Readiness reads the daemon's Holder, channel manager and chat
contract, and the registry it produces is a daemon field, not a field on
a server with no listener. Boot now owns one Holder instead of seeding a
second and replacing it in buildDaemon; operator retry caps read it too,
so they follow a reload rather than a boot-time snapshot.
Server loses Cfg, ConfigProvenance, LastReload, ConfigOverrides and
SetProvenance. The nil-guarded branches they fed went with them, each
checked first against what the UI process actually serves:
- chat.show_tool_calls and the /api/setup checklist were degraded, not
dead. ConfigView gains a chat section carrying show_tool_calls, the
operator name and whether a channel is configured, and both surfaces
read the projection. The end-to-end suite asserts the checklist renders
from the published snapshot.
- /api/logs takes its path as a process-local option. The history is on
the daemon's disk, so a dashboard elsewhere cannot read it by learning
the path; that route still needs a contract.
- handleChannels drops its config-derived fallback, superseded by the
status manager, which already carries the descriptions and detail.
- trustForwardedHeaders keeps only the process's own setting, which the
UI process already sets.
- resolveForge keeps the published-projection path it already had.
ConfigView.Editable moves to handleConfig, decided by whether this
process holds UpdateConfig. It describes the writer, not the document, so
the write contract (archie-core-j28m) makes the page editable by wiring
one field. The write handlers and their seams stay for it.
overlay.Store gains Keys: Snapshot nests dotted keys for decoding, so the
overridden-key list was publishing section names ("budgets") where the
dashboard marks and resets rows by stored key ("budgets.max_steps").
Multi-identity forge links move to archie-core-pv6t: forgeConfigForTask
resolved a task's forge from config.Config, had no reachable caller once
the holder was gone, and belongs in the projection rather than the
rendering package.
The capture batch reads moved onto server-streaming RPCs (StreamCaptures /
StreamUndispatchedCaptures) to get past gRPC's 4 MiB unary cap, but the
client interceptor suite attached the bearer token to unary calls only:
Dial installed WithUnaryInterceptor and nothing for streams, while
TaskGrants.StreamInterceptor requires the administrative token. On every
token-protected (non-loopback) listener -- every container-mode deployment
-- the daemon's binding dispatch and the dashboard's capture inspector got
PermissionDenied from the stream interceptor, and the unary fallback those
reads replaced is no longer taken, so there was no working path.
- Add StreamClientTokenInterceptor, mirroring gatewayrpc's, and install it
alongside the unary one in Dial, the single client dial path the daemon,
the dashboard and the agent all use.
- Route agenttransport's State Store dial through staterpc.Dial, deleting
the duplicate dial/fail-closed logic that installed only the unary
interceptor -- a second place for this class of bug to hide.
- Regression tests: the grants harness now dials through the production
Dial so client-side wiring cannot drift again;
TestCaptureStreamsCarryTheAdminToken reads both list surfaces (5 MiB
batch) through a token-protected listener;
TestStateStoreRealProcessTokenProtectedCaptureStream does the same
against the real binary; TestUpdateRejectsNilTask covers the Update
guard left untested by the earlier finding fix.
Closes archie-core-h019.5. The shipped contract already made only a confirmed
error-level finding block, and kept zero-findings distinct from not-run; what
was missing was the other half of calibration, and that is what a reviewer that
cries wolf needs.
- ReviewReport gains Checked []ReviewCheck {Property, Evidence}: the properties
the reviewer verified clean. Evidence is required, for the same reason a
finding requires a failure scenario -- a check without evidence is an
assertion, not a verification.
- The reviewer records checks through a typed record_checked tool, mirroring
record_finding, so it cannot end its turn having silently skipped the
checklist.
- Style/formatting/naming nits are stated out of contract, in the ReviewFinding
type doc and the reviewer prompt: they are the padding that trains an
operator to skim.
- The PR-body findings section renders the cleared properties, so a
zero-finding review arrives backed by what was checked rather than reading
the same as a review that never looked.
Design: docs/prds/review-calibration.md.
The in-process suite proved the composition; nothing proved the process.
This builds the real binary, points it at a State Store and a Gateway on
loopback gRPC through an operator-shaped config.toml, and drives it over
HTTP: the token exchange and its 401s, the embedded SPA, a chat stream
relayed frame by frame, an operator task action crossing to the Gateway
and refused without the CSRF header, unauthenticated capture intake, the
ratified degradations, readiness dropping when a dependency dies while
liveness holds, and a clean SIGTERM.
It found one regression, fixed here at the producer. Task rows lost their
forge links in the extracted process: taskURLs read config.Holder, which
is nil once the dashboard stops sharing the daemon's process, so every
click-through to the issue and the PR silently disappeared. The forge is
now resolved once per request from whichever source that process owns,
the daemon's configuration or the daemon's published projection.
A multi-identity deployment keeps no links rather than gaining wrong ones:
the projection carries the default identity alone, so it now says so and
the renderer withholds.
Add Manager.Resume, the complement of refresh: refresh resets to origin/<base>
for a fresh run; Resume fetches and hard-resets to origin/<branch> so the
already-pushed PR work survives. This is the worktree primitive the remediate
workflow (archie-core-8li9 step 3) needs to continue work on an existing PR
branch without discarding its commits.
Tests pin the discriminating property: Resume lands on the branch tip (the
committed work), not base, and cleans abandoned untracked files.
Add a forge-neutral PullRequestReviewReader (type-asserted, like the noop forge
gap) so archie can react to review activity on a PR it opened. GitHub and Gitea
implementations normalise review state to approved/requested_changes/commented/
dismissed and apply a sinceID dedup cursor. First slice of archie-core-8li9
(PR review comment remediation).