Commit Graph
1210 Commits
Author SHA1 Message Date
sam 267de032de fix(chat): remove unreachable Telegram-router restart wiring
Review fix for PR #873. The previous attempt wired Router.Restart on the
Telegram router, but that path is unreachable: telegram.go:260 registers an
exact-match /restart handler (restartHandler, restart.go:24) which consumes the
update before the chat router is reached.

The wiring was therefore a false affordance: it made the Telegram router report
RestartAvailable: true for a callback no production path invokes, and the test
only passed because it assembled a LocalChatAdapter by hand rather than driving
the composition production uses.

Remove it. Telegram's own restartHandler remains the sole path to
RequestRestart. The removals of boot.restartTelegram and
telegramSetup.RegisterRestart stand: those were written and never read, which is
the real defect (channels-telegram-3).

Tests are retargeted and table-driven: buildTelegramRouter leaves Restart nil
with and without an adapter (regression guard against re-adding the unreachable
wiring), the router's /restart route reports not-configured, and
RequestRestart's queue-then-reject contract is pinned at the adapter level.

This deliberately does NOT fix dashboard /restart: the web router runs in the
archie-gateway process while the Telegram adapter runs in archied, and no
gateway->daemon restart RPC exists. That needs its own design (see the bead
referenced in the PR body).
2026-09-19 02:17:59 +10:00
sam 559f07034b fix(chat): wire the Telegram adapter restart callback into the chat router
/restart could never work in production. boot.setupGateways captured the
Telegram adapter's restart callback into boot.restartTelegram, a field no code
ever read, so gateway.Router.Restart was nil in every composition:
handleRestartAdapter always answered "not configured" and LocalChatAdapter's
snapshot always reported RestartAvailable: false.

Fix at the producer: buildTelegramRouter assigns Router.Restart directly from
the adapter it already holds. The dead field and the telegramSetup.RegisterRestart
indirection are deleted rather than kept alive.

Red-then-green: TestBuildTelegramRouterWiresRestartCallback failed with
"router.Restart = nil, want the telegram adapter restart callback wired into the
router" before the change. TestBuildTelegramRouterRestartUnconfigured pins the
unchanged no-adapter behaviour, including the not-configured reply.
2026-09-19 01:50:41 +10:00
sam 121fbf730f Merge pull request #870 from samcharles93/fix/label-routing-and-triage-criteria
fix: restore kind routing for namespaced labels, and give triage real criteria
2026-09-19 00:35:05 +10:00
sam 678539e390 fix(workflow): require a workflow from triage when a code change is needed
The selection criteria alone left workflow optional and defaulted an omitted
or unrecognised value to implement, so a decide call could still skip the
decision and send an unsettled capability straight to the builder.

Omission is now a retryable rejection: CaptureTool gains RequiredWhenTrue, a
conditional requirement a flat RequiredFields entry cannot express, because
the close-without-change branch has no workflow to name and must not be made
to invent one. A rejected call is not recorded, so it does not consume
MaxCalls and the model retries with the field.

A value outside the enum now fails the stage rather than degrading to
implement: reaching OnResult with one means the model ignored its own schema.

Splits validateCaptureArgs into per-constraint checks (cyclop) and carries
the regenerated contracts.json.
2026-09-19 00:33:39 +10:00
sam 017f8e775f Merge pull request #869 from samcharles93/fix/ui-event-pump-retry-and-uptime-timer
fix: recover the UI activity feed and stop reaping released containers
2026-09-19 00:18:41 +10:00
sam 4e3e48ca76 feat(workflow): give triage criteria for choosing between workflows
The classify stage picked between implement, tdd and feasibility with no
stated criteria: the mission spent its guidance on needs_code_change and the
schema said only 'Which workflow fits best', with implement as the free
default for an omitted or unrecognised answer. Issue 813 was classified
implement on that basis.

Both surfaces now state what each workflow is for and say not to pick
implement merely because nothing else obviously fits. The mission moves to a
named triageMission so a test can assert the criteria reach the model.

Closes archie-core-s5ys
2026-09-19 00:17:44 +10:00
sam a73762d1e7 fix(workintake): match namespaced forge labels when routing by kind
labelKinds is keyed on bare strings, and this repo namespaces its labels
(type::feature, priority::medium), so KindsForLabels matched nothing and
every issue fell through kind routing to Route's triage fallback. Kind
routing has therefore never fired here: issue 813, a type::feature that
defaultKindWorkflows binds to feasibility, reached implement instead.

Labels now resolve to the value after the last '::'. The namespace is not
checked: bug/feature/bootstrap is specific enough that a label ending in one
means that kind whatever the tracker files it under.

Closes archie-core-tjoc
2026-09-19 00:17:44 +10:00
sam b38c14f6e1 fix(container): claim container teardown once instead of cancelling a timer
Timer.Stop cannot unwind a max-uptime callback that has already begun, so
cancelling still let the reaper and Release both stop and remove the same
container, which is the duplicate teardown and the misleading 'No such
container' warnings this was meant to remove.

Teardown is now claimed once per container: whichever of the two gets there
first talks to Docker and the loser skips to its own bookkeeping. Release
still claims after the grace period, so MaxUptime keeps biting during it.

Also table-drives the event pump priming cases, per the repo's test directive.
2026-09-19 00:13:36 +10:00
sam 0e1e5303ed fix(container): keep the max-uptime cap active during the grace period
The reaper was cancelled at the top of Release, before the grace-period
sleep, which let a container outlive MaxUptime by GracePeriod. MaxUptime is
documented as a cap from creation enforced regardless of task state, and a
grace period is task state, so the cancel belongs after the sleep.

Also asserts the disarmed reaper directly rather than only inferring it from
the absence of later Docker calls.
2026-09-19 00:06:26 +10:00
sam dedafd7d43 fix(container): cancel a container's max-uptime reaper on release
The timer stayed armed after Release removed the container, so an hour later
it stopped and removed an ID Docker had already forgotten and logged two
warnings that read like a failed teardown.
2026-09-18 23:59:40 +10:00
sam 13d32f34b0 fix(webui): retry event pump priming until the state store answers
archie-ui binds before archie-state-store is guaranteed to be listening, so
the first prime is routinely refused. PumpEvents returned on that error, which
left the activity feed history-only for the life of the process. Prime now
retries with capped backoff and gives up only when the context ends.

Orders archie-ui.service after archie-state-store.service as well, which
narrows the window without closing it: After= sequences the start, it does
not wait for the listener.
2026-09-18 23:59:40 +10:00
sam d3f72a4b20 Merge pull request #861 from samcharles93/feat/856-archie-update-check-reports-a-stale-agent-version-after-a-ma
archie-update-check reports a stale agent version after a managed-image update (archie)
2026-09-18 23:16:32 +10:00
sam 18bbd699c1 fix(update): write the agent version sidecar with a real newline
printf '%s\\n' emitted the literal characters backslash-n, which
archie-update-check's release-version check rejects, so every managed-agent
update left the installed agent version reported as unknown.
2026-09-18 23:14:34 +10:00
samcharles93 b1ec7f3ded archie-update-check reports a stale agent version after a managed-image update (archie)
Implements #856
2026-09-18 05:57:48 +00:00
sam 40851baa90 docs(prds): design the code graph as an MCP surface
Supersedes symbol-reference-index.md, which scoped only the data layer and
left the interface unstated. Deleted rather than archived: it was written
today, never implemented, and keeping both would leave two documents claiming
authority over one capability.

Three things the narrower doc did not settle.

The interface is MCP. archied consumes MCP and serves none, so exposing the
graph that way reaches Claude Code, pi, codex and Archie's own agents through
one surface with no coupling to the daemon. Diagrams are deliberately not a
tool: a model handed an accurate subgraph writes its own Mermaid, and the
valuable half was never the rendering.

Every answer declares what it could not see. RTA over-approximates interface
dispatch and reflection is invisible, so the *extract yaegi tables make
symbols look reachable regardless. An agent trusting a confident wrong graph
is worse off than one that greps.

A code graph does not power a documentation chatbot. It answers structural
questions about Go symbols; answering "how do I configure a second identity"
means retrieving prose from markdown. I had previously implied one substrate
served both. It does not, and building it that way would serve neither well.
2026-09-18 13:42:33 +10:00
sam 7b69a4df1f feat(tools): wire the workspace codesearch index into grep
internal/tools/builtin.RegisterBuiltins has always accepted a GrepIndex and
nothing ever passed one, so every grep ran the direct walk no matter what
[indexing] was set to. internal/indexing was fully implemented and tested
with zero production callers, and internal/config decoded IndexingConfig into
nothing. Two halves of one defect.

The composition root now builds an indexing.Manager and hands it to the
workspace tool provider, which forwards it to RegisterBuiltins. deadcode
confirms the result rather than the commit message asserting it: unreachable
functions drop from 88 to 73, and all 15 internal/indexing entries are gone.

Failure degrades rather than propagates. A manager that cannot build logs a
warning and grep keeps its direct walk, which is exactly what it did before
this was wired. An accelerator must never stop the daemon starting.

The context is detached with WithoutCancel rather than replaced with
Background: the index build's lifetime is the process, while the gateway
path's boot context is cancelled once startup returns, so inheriting
cancellation would kill the build mid-flight. Background would have satisfied
the linter too, but would silently drop the caller's context values, so
registerTools now takes the context its callers already had.

internal/agentexec's RegisterBuiltins call is deliberately left alone. It
registers builtins only to harvest their names for a plugin tool-name
collision check and never executes them, so there is no grep there to
accelerate.
2026-09-18 13:40:45 +10:00
sam a533810546 docs(site): close the excluded-PRD link chain and reconcile the CI section
Two fixes to the published site, both about not shipping something false.

exclude_docs held back prds/ but let ui-service-boundary.md through, because
architecture/migration-decisions.md links to it three times. That PRD in turn
links to service-decomposition.md and config-schema.md, so the exclusion was
still producing two dead links on the published site. Letting those two
through closes the chain: the build now reports no excluded-link references
at all.

generated-documentation.md's "Step 9: CI" said no workflow builds, checks or
publishes documentation. Adding .github/workflows/docs.yml made the first
clause false. Restated to say what that workflow does and, more importantly,
what it deliberately does not: it does not run docsgen, regenerate
contracts.json, or publish. Generated-artifact drift is still gated locally by
task check, which is the split that section exists to protect, since a CI job
that regenerated output could paper over uncommitted differences rather than
fail on them.
2026-09-18 13:17:02 +10:00
sam 8adc010577 ci(docs): verify the documentation site builds
Build-only. The site deploys from the Ansible control node via the
vectislabs.automation docs_site role against nebula, so CI has nothing to
publish; what it catches is a docs change that will not build at all, before
it reaches a deploy.

Path-filtered to docs sources, so the ~600 commits a month that touch no
documentation do not run it.
2026-09-18 13:16:09 +10:00
sam dcaa98cc44 docs(site): make docs/ buildable as a documentation site
Adds an mkdocs.yml, a landing page, and `task docs:site` / `task docs:serve`.
Deliberately hosting-agnostic: MkDocs is the same input Backstage TechDocs
consumes, so choosing where this lands later costs nothing.

exclude_docs holds back four subtrees, since everything under docs/ would
otherwise be published. archive/ is superseded design and would compete with
the current architecture for a reader's attention; inspiration/ discusses
other products by name; prds/ are open decisions rather than settled design;
github-token.md is credential setup. One PRD is let back through because
architecture/migration-decisions.md links to it three times, and a page
excluded out from under a live link is just a 404 with extra steps.

No nav block. MkDocs derives it from the directory layout, so a new page
under docs/architecture/ publishes without a second edit, and there is no
hand-maintained tree to drift against the repository.

Builds --strict, so a dead internal link fails rather than ships.
2026-09-18 13:16:09 +10:00
sam 38c0e485bc chore(tools): make unreachable-code analysis runnable from the Taskfile
Add `task deadcode` (whole-program RTA from ./cmd/...) and `task reachaudit`
(the existing classifier on top of it). Neither joins `task check`: both
report a standing backlog, so gating on them fails every run until that
backlog is zero, same as `task vuln`.

`task deadcode` shells to `go run ...@latest` rather than a local binary on
purpose. A deadcode built against an older Go than this module exits non-zero
and prints nothing, which reads as "no dead code" instead of "analysis
failed" -- the locally installed copy was built against 1.26 against a 1.27
module and had been silently reporting an empty tree.

reachaudit had two traps that made it answer confidently from nothing:
its --repo default pointed at a path that does not exist on either machine,
and it reused /tmp/reachaudit-deadcode.txt with no staleness check, so it
would serve a previous tree's analysis indefinitely. Key the cache on HEAD
and refuse it outright when the tree is dirty.

Also lands the design for tools/symbolrefs, the type-resolved reference
index that covers what reachability cannot: RTA treats every address-taken
function as live, so every reflect.ValueOf entry in the *extract tables
launders a dead symbol into a reachable-looking one, and deadcode reports
functions only, leaving dead package vars unrepresentable.
2026-09-18 13:15:26 +10:00
sam f86b43000a Merge pull request #860 from samcharles93/fix/855-docsgen-check-gate
feat(build): gate generated contract data in task check
2026-09-18 13:09:47 +10:00
sam d636b622ab fix(docsgen): address three review findings on the check mode
All three Greptile findings were valid against the code; each is fixed at its
cause rather than at the symptom, and each fix is covered by a test that
fails when the fix is reverted.

**Check could silently write.** `check` was matched only as the first
argument, and leftover positional arguments were never inspected. So
`docsgen --repo-root .. check` — and any misspelled subcommand — fell
through to the write path and overwrote the artifact the check promises not
to touch. That is the exact guarantee the mode exists to provide, so the
failure was silent and in the wrong direction.

Extracted argument handling into a testable `parseOptions` and made a leftover
positional argument an error with usage text. Switched the flag set from
`ExitOnError` to `ContinueOnError` so the error surfaces as a value rather
than a process exit, which is what makes it testable.

**Obsolete detection claimed files it does not own.** It treated every
sibling `.json` as docsgen's and reported it obsolete, so checking an
artifact in a mixed-use directory produced a false stale result, and the
documented target layout — which anticipates further named artifacts in
`docs/data/generated/` (catalog.json, AsyncAPI output) — would have been
reported stale as soon as a second artifact legitimately existed.

Ownership is now declared rather than inferred: `generatedArtifacts` maps each
directory docsgen owns end-to-end to the names it produces there, and a
directory docsgen does not own is never judged. A new unit test pins both
halves — the orphan inside an owned directory is still caught, and a foreign
`.json` in an arbitrary `--out` directory is not.

**Provenance traversal stopped at one level.** Refs were walked only inside
the top-level contract schemas, so a definition reachable solely through
another definition resolved to "no authoritative definition found" — the
diagnostic lying about the code it points at. Replaced the single pass with a
breadth-first walk that follows discovered definitions transitively, seeded
with every published contract first so a definition reachable from several
contracts is attributed to the alphabetically first rather than to whichever
the walk happened to reach. `walkSchemaRefs` now iterates map keys in sorted
order for the same reason.

`schemaProvenance` takes its roots as a parameter, which is what makes the
transitive case testable without real types.

Verified by mutation: with each fix reverted in turn, its test fails —
`parseOptions(["--repo-root" ".." "check"]) returned nil error`,
`obsoleteArtifacts() = [...someone-elses.json is obsolete...]`, and
`provenance[Leaf] = ""`. Control run passes unmutated, and the file is
byte-identical after restoration.

Also confirmed end to end that the previously silent invocation now exits
non-zero with usage instead of writing, and that the committed artifact is
untouched by it.

`task check`: exit 0, 0 failures.
2026-09-18 13:00:30 +10:00
sam 641c80f7d9 feat(build): gate generated contract data in task check
Closes #855 (archie-core-5gzx).

The check mode added in the preceding commit had no caller, so it prevented nothing: a
stale contracts.json still passed every gate. This wires it in and makes
drift fail the build.

- `task docs:generate` writes the committed artifact.
- `task docs:check` verifies it, non-destructively.
- `task check` runs `docs:check`, right after `proto:check`, so both
  generated-artifact surfaces are judged the same way in the same place.

The check cannot be satisfied by rewriting: it generates into a temporary
directory, so a failing gate leaves the artifact exactly as it found it and
the author applies the regenerated bytes. That keeps the regenerated diff
reviewable in the same commit as the code change that caused it, which is
what Step 9 of the architecture document requires and what a CI auto-update
would quietly bypass.

Documents that called this gap open are updated rather than left to
contradict the code:

- `generated-documentation.md` Step 8 (no `docs:*` task exists -> both exist),
  Step 9 (drift is gated locally, not in CI), and the hook/CI policy (rule 3
  is now enforced by the gate; rules 1, 2, and 4 still rely on the author,
  since nothing observes a commit).
- `contract-conformance-audit.md` gap 1, now closed.
- `config-example-drift.md` item 3, which asked for exactly this wiring.
- `CLAUDE.md`, whose `task check` description listed neither `docs:check`
  nor `test:tools`.
- The build, docs, and diagnostics skills, plus a re-baselined diagnostics
  snapshot: the `task_docs` delivery surface went 0 -> 6 and the `tools`
  module 4 -> 7 now that the tasks exist.

Verified with `task check` (green), including the new `docs:check` step.
2026-09-18 12:46:40 +10:00
sam 604c301b22 feat(docsgen): add a non-destructive check mode for generated drift
`docs/data/generated/contracts.json` sat stale since a825db28 with nothing
to notice: no task, no test, and no CI step regenerates or compares it, so
the committed contract reference quietly drifted from the Go types it
claims to describe. It was only found by hand-running the generator.

Implements Step 6 of docs/architecture/generated-documentation.md, which
already specified this command and closed the gap filed in
docs/prds/contract-conformance-audit.md ("`docsgen check` is documented and
does not exist"):

1. generates into a temporary directory;
2. normalizes line endings;
3. compares the schema trees with the committed output;
4. reports missing, changed, and obsolete files;
5. names the authoritative definition behind each mismatch;
6. exits non-zero without modifying the working tree.

The check never writes to the working tree, so the author applies the
regenerated bytes rather than the gate silently doing it. That is why this
is a `check` and not a CI auto-update: the code change that shifted the
contract surface should be reviewed with its regenerated artifact in one
commit, and a bot commit would bless an unintended contract change with no
reviewer ever seeing it. Step 9 states the same prohibition directly.

Diagnostics name the Go type, so a failure says where to look:

    docs/data/generated/contracts.json is stale; regenerate it with:
    go -C tools run ./docsgen --repo-root ..
      schema "AgentExecutionResult" changed (authoritative definition:
        github.com/samcharles93/archie-core/internal/agentexec.Result)
      schema "MediaAttachment" changed (authoritative definition:
        reached from .../internal/gateway.MessageEvent)

Nested definitions are attributed through the published contract that
references them, iterated in sorted order so the diagnostic is
deterministic when several contracts share a definition.

Usage: `go -C tools run ./docsgen check --repo-root ..`, plus the existing
`--out` to compare an arbitrary artifact.

Reuses the write path rather than reimplementing encoding, so check and
generate cannot disagree about the expected bytes.

Tests cover: the committed artifact is current (the regression guard that
would have caught this), changed/removed/missing/obsolete detection, and
that a failing check leaves the artifact's bytes, mode, and directory
contents untouched.

`task docs:check` wiring into `task check` is deliberately not in this
commit: Taskfile.yml is being edited concurrently in this working tree.

Verified with `task check` (green).
2026-09-18 12:46:21 +10:00
sam 541bd0299d docs(skills): re-verify every .agents skill against the current tree
All ten `archie-*` skills carried claims that no longer matched the
checkout. Re-verified each against code, git history, and the shipped
configuration, then corrected the drift.

Structural changes the skills had not caught up with:

- Composition root moved: `cmd/archied/main.go` is a ~30-line dispatcher
  into `internal/app/archied.Run()` with wiring in `bootstrap.go`. The
  skills still described `cmd/archied` as the wiring site, which also
  silently zeroed the diagnostics delivery snapshot.
- Config decoding moved out of `internal/config` into
  `internal/infrastructure/configuration`. `config.Load` / `config.LoadDir`
  no longer exist; the loader is `configuration.New` + `Loader.Resolve`.
- Task contract moved to `internal/domain/storecontract`, with
  `internal/store/interface.go` holding aliases only. The task type is
  `internal/domain/workflow/task.Task`.
- `internal/workflow` became `internal/domain/workflow`; `internal/storerpc`
  became gRPC `internal/infrastructure/staterpc`; `internal/policy` does not
  exist.
- `Store.Transition` now guards on `from` and writes status plus history in
  one transaction. Three skills still described the old non-atomic behavior
  as current and open.
- `internal/domain/{messaging,workflow,workintake}`, `internal/eventbus`,
  `internal/app`, and `internal/infrastructure` now exist.
  `internal/domain/{agent,identity}` and `internal/policy` remain target-only.

Tooling and environment facts:

- Go 1.27.0 (root and tools modules), golangci-lint 2.13.2, staticcheck
  2026.2.1; snapshot dates and HEAD moved to 2026-09-18 / 0ee2d27e.
- Re-ran the bundled diagnostics and re-baselined its snapshot table.
  Confirmed 78.6% store coverage, a clean race run, and zero dupl findings.
- Corrected the claim that no `.dockerignore` exists; it does.
- Replaced skill script paths that pointed at the untracked `.claude/skills`
  symlink with the canonical tracked `.agents/skills` location.
- Fixed the delivery-snapshot comment's wrong commit hash for the Gitea
  workflow removal (dd9bddc2, not e539048).

Findings the verification closed:

- The VitePress site and `.github/workflows/docs.yml` were removed
  (de150f20); the Gitea workflow was dropped (dd9bddc2).
- The changelog `vX.Y.Z`-vs-`X.Y.Z` contradiction is settled, not open: both
  changelogs and the CI gate agree on `## [<version>]`.
- Tracked `docs/node_modules` and the skill-script test regression are
  settled, not current.
- The six unmerged `origin/fix/*` and `origin/feat/*` candidate branches no
  longer exist.

Also regenerates `docs/data/generated/contracts.json`, which the
verification found stale since a825db28: docsgen emits 11 schemas now, and
`MediaAttachment.raw` plus an `AgentExecutionResult.required` field were
missing. `cmp` passes after regeneration.

Verified with `task check` (green).
2026-09-18 12:37:51 +10:00
sam 0ee2d27ebc fix(workflow): record a parked run's reason in its own log
The agent-side half of the same gap. A stage failure already logged
"stage failed -- parking" before parking, but a run whose OUTCOME was parked
(a review that could not run, a workflow that ended with no outcome) reached
the timeline as a KindParked event and the store as park_reason and never
the log an operator downloads.

park is the one place a park's reason is final, so it is now the one place
that logs it; the stage-failure branch no longer logs its own near-copy, and
the stage names itself inside the reason. The entry carries the stage as a
field so nothing is lost by dropping the duplicate line.

observability.md's "Implemented design" section documented the container's
system-log path as though it were the only source of task-log content; it
now records the daemon's and the workflow's own park writers, including why
the entry follows the transition rather than preceding it.
2026-09-18 01:49:56 +10:00
sam ff27bd03fe fix(daemon): record every park reason in the attempt's own log
An operator who asks "why did task 1 attempt 3 park?" and downloads that
attempt's log got a zero-byte file, because nothing daemon-side wrote to a
task log at all: the container's system-log subscription was the only
writer, so an attempt that parked before any container produced output --
a worktree prepare failure, an unavailable worker, a taskrun error -- left
the file the sink had created empty and the reason only in the daemon-wide
log.

Both park paths now write the reason into that attempt's sink. The entry is
written after the guarded transition lands, so a park another actor won
does not leave a log claiming an outcome the task board contradicts -- the
same race the parked event is already withheld for.
2026-09-18 01:49:49 +10:00
sam 3917afeeb3 refactor(logging): pass the caller's context to TaskRegistry.Write
Write built its own context.Background() for the handler call, which meant
any new caller with a context to offer could not hand it over. Taking the
caller's context is what the next commit's park-reason writer needs, and it
is what contextcheck requires of a daemon-side writer.

No behaviour change: the context is used for the handler's own attribute
extraction and never consulted for cancellation -- a park is recorded at
exactly the moment a run's context has been cancelled, so a cancelled
context must not suppress the entry.
2026-09-18 01:49:42 +10:00
sam 537ba9a3fb fix(agentworker): hand the worktree back on every sandbox exit
A container run only restored ownership of the bind-mounted worktree on the
CommitAll/Push success path (archie-core#520). The agent runs as root inside
the container, so every other way a run can end -- a gate failure that parks
the task, a stage error, an early return -- left the worktree owned by UID 0
on the host. The daemon is the process that later cleans and resets that
directory as its own non-root user, and it cannot even unlink inside a
root-owned directory, so the next attempt failed before it could start no
matter what the worktree refresh did.

runTask now defers the same reconcileOwnership the commit and push paths
already call, so it runs at every exit. The retry recoveries in worktree
package cannot fix this from the daemon side: a non-root process cannot
chown, and removing the directory needs write access to it.

Observed through a supplementary group -- a non-root process may move a file
it owns into a group it is a member of -- so the test proves the chown ran
without needing root.

Residual, filed as archie-core-zcg8: a container that is SIGKILLed never
runs this defer.
2026-09-18 01:49:35 +10:00
sam ca833a8c7c fix(worktree): recover retries from path-type conflicts and stop masking the cause
A retry after any attempt that did not commit failed with

  worktree prepare failed: checkout branch <branch>:
  a branch named "refs/heads/<branch>" already exists

on a branch that was never the problem. refresh inferred "the branch does
not exist yet" from a failed checkout and reported whatever the Create
fallback then returned, so the real failure was replaced by a false one --
and the operator had no way to tell that the park reason was fiction.

The real failure, reproduced: a stage running in the container can leave a
path whose TYPE contradicts the tree refresh resets onto -- a directory
where the base tree has a file, or a file where the base tree has a
directory. go-git's hard reset cannot write over that contradiction and
fails with `openat <path>: is a directory` / `not a directory`, which is
exactly the failure the Create fallback then relabelled. Retry could not
recover from it, and a second path of the same class (a branch removed
while HEAD still pointed at it) failed with "reference not found".

refresh now clears the worktree against the tree it is resetting ONTO
before it checks anything out, which removes exactly those conflicts -- an
on-disk directory the tree declares as a file is untracked, and so is a
file the tree declares as a directory -- and resolves the branch's
existence from the reference store instead of inferring it. Resume gets the
same treatment, so the remediate path cannot fail the same way.

This is the third fix to this function (Force in 05944b6f was the second),
so the checkout/reset/clean sequence is rewritten rather than patched again.
2026-09-18 01:49:28 +10:00
sam 5a4a0dc6b0 Merge pull request #858 from samcharles93/fix/staterpc-nil-collection-fields
fix(staterpc): never decode a collection field to a nil slice
2026-09-18 01:06:58 +10:00
sam efff23d922 fix(staterpc): never decode a collection field to a nil slice
Every client method that decodes a repeated proto field goes through
mapValues, which returned nil for nil input. Protobuf decodes an empty
repeated field to nil, so an empty collection crossed the wire as JSON null
rather than an empty list: the field's type depended on whether it happened
to have contents, and the wire path disagreed with the local path, which
normalises its own slices.

This is the nil-slice class the contract-conformance audit deferred, arriving
by the route its own revisit condition names -- a handler that can produce
nil. The audit checked the webui handlers (clean, as it said) and did not
cover the wire mapping added afterwards, so the regressed field was the new
one: ReadTaskLog's components, observed as "components": null from the live
dashboard.

mapValues now returns []B{} for empty input, which fixes the class once at
the mapping helper rather than at each of its 36 call sites -- none of them
compares the result to nil, so nothing depended on the old behaviour.
TaskLog also normalises components, which is read straight from the proto
rather than through mapValues.

Red first: the test drives the existing local/grpc matrix and asserts the
marshalled JSON, so it fails on a null collection without depending on which
path is under test. Both collections are exercised empty -- entries present
with components empty, and a log file that exists with no lines -- because
the first shape alone leaves the entries side untested. Verified by mutation:
restoring the nil return fails it on "entries marshalled to null".
2026-09-17 14:58:14 +00:00
sam c0e81a3f76 docs(release): drop an unreleased claim from the 1.27.0 agent notes 2026-09-17 13:56:13 +00:00
sam f7420f7576 chore(release): archied v1.27.0 archie v1.27.0 2026-09-17 13:42:26 +00:00
sam 6c6f6bf30b Merge pull request #845 from samcharles93/feat/839-telegram-tool-activity-block-is-uncapped-and-crowds-out-the
Telegram tool-activity block is uncapped and crowds out the answer (archie)
2026-09-17 22:40:21 +10:00
sam 29e5e0130d Merge pull request #846 from samcharles93/feat/835-disk-readiness-probe-watches-only-work-dir-so-a-full-root-fi
Disk readiness probe watches only work_dir, so a full root filesystem goes unreported (archie)
2026-09-17 22:39:15 +10:00
sam 2fd0f23971 Merge pull request #848 from samcharles93/feat/state-store-task-log-download
feat(staterpc): read task logs through the State Store and make them downloadable
2026-09-17 22:38:16 +10:00
sam 8a886ddc38 fix(webui): do not hand back an error as a .log download
The download sets its attachment headers before the read, because the body
streams straight from the reader and a log is unbounded input -- buffering it
to size the response would defeat the reason it streams. Nothing then cleared
those headers, so a 404 for an attempt with no log went out as

	Content-Disposition: attachment; filename="task-1-attempt-0.log"
	Content-Type: application/x-ndjson

A browser treats that as a download: the caller gets a .log file containing
the text "no log recorded for this attempt". A stale or direct download URL is
enough to trigger it. The 503 for a process with no reader had the same shape.

Both error paths now clear the attachment headers before writing, so the
response is an error rather than a file. The successful path is unchanged.

Red first: the existing test asserted the status only, which is how this
passed. It now asserts the headers are cleared on a 404 and on a 503.
2026-09-17 12:33:45 +00:00
sam 3cb3cf7e62 feat(ui): download a task attempt's log, and stop blaming a setting for it
The attempt-log panel offered no way to get a log out of the dashboard, and
its failure copy asserted that task logging was not enabled for the run. The
first is the feature: the panel now links to the download route for the attempt
it is showing, so the browser owns the filename the server sets and streams the
body to disk rather than the client holding a whole log in memory.

The second is the honesty fix. "No log recorded for this attempt" is a fact
about the attempt; "this dashboard cannot read task logs" is a fact about the
deployment, and only the second is worth sending an operator to a setting for.
The panel renders them differently off the response's found/disabled markers.

Rebuilds ui/dist, which is a committed asset.
2026-09-17 12:12:47 +00:00
sam cf7cc9d891 feat(webui): read a task's log through the State Store and let it be downloaded
The dashboard's attempt-log panel answered every read with "task logging is
optional and was not enabled for this run". That message was false: logging is
wired unconditionally in the daemon, and the log files exist. The dashboard
process simply had no reader -- composition left TaskLogs absent because no
contract carried it -- so the handler saw a nil registry and reported the
disabled shape, which the page rendered as a claim about configuration.

internal/logging now answers whether an attempt has a log at all: Tail sets
Result.Found, so "this attempt has no log" is a value rather than an empty
list indistinguishable from a read that never happened. Its registry gains
TaskLog (a decoded page) and TaskLogContent (the file verbatim, streamed,
because a log is unbounded input), and an absent reader reports
ErrTaskLogsUnavailable rather than an empty page -- a process that cannot read
logs must not implicate the attempt.

Those two answers travel the State Store contract as storecontract.TaskLogStore
(ReadTaskLog, StreamTaskLogContent) and are rehydrated on the client by
(Unavailable, canonical message), so archie-ui composes the reader from its own
store client instead of opening another process's files. The daemon's registry
is wired as the server-side reader in the State Store process only.

On top of that read, GET /api/tasks/{id}/logs/download serves the attempt's log
as a Content-Disposition attachment named task-<id>-attempt-<n>.log, and the
panel offers it. The JSON route keeps its shape and gains found, so the page
states the attempt has no log instead of blaming a setting.

Task log files stay owned by their directory's owner: archiving still removes a
task's log directory, and that removal is the daemon's, not the dashboard's.
2026-09-17 12:12:43 +00:00
sam 3abee8b8ac feat(staterpc): add the task-log read contract to the State Store service
One task attempt's persisted log lives in the state directory the State Store
process owns, and no contract carried it: the dashboard process therefore had
no way to read a log at all, and answered every attempt with "task logging is
optional and was not enabled for this run" in a deployment where logging is
unconditional.

ReadTaskLog returns a decoded page and StreamTaskLogContent returns the raw
bytes server-streamed -- a log rotates at 20 MB, past gRPC's unary cap, the
same reason StreamCaptures superseded ListCaptures. found=false with no error
means the attempt has no log; a service with no reader answers Unavailable,
and keeping those apart is the point: only the second is a deployment
condition.
2026-09-17 12:09:43 +00:00
sam ea128443e0 feat(gateway): persist the channel-native sender id on messages
Slice 1 of docs/prds/memory-engine-unification.md: persist the
participant, so a later curator can address agent-user memory scope.

- messages gains sender_id: schema, ALTER migration (idempotent via
  duplicate-column detection), both inserts, and both history selects.
  Pre-existing rows default to empty.
- curator.SessionSummary gains AgentID and ConversationMessage gains
  SenderID; the sessioncurator adapter fills them from the session's bot
  identity and the stored record.

The memory contract is untouched and nothing consumes the new fields
yet. Deriving a session's participant from its user-role messages, and
failing closed on ambiguity, stays with the curator rewrite.
2026-09-17 22:06:54 +10:00
sam 9b566b8ad4 fix(readiness): keep required status when an optional target shares a path
Targets are deduplicated by path so a shared filesystem is probed once, but
the first target seen won. With root, then an optional /var, then a required
data path that resolves to /var, the optional target is the one that survived
-- so its rules were applied to a path the daemon requires. An absent /var is
skipped as "optional absent", and with another healthy target present the
probe reported OK while a required path was unavailable.

Deduplication now keeps the strictest requirement any target places on a
path, and its name, so the failure is both visible and correctly attributed
rather than reported against the optional target that happened to come first.

Red first: the new test drives the reported scenario through an injected
statfs and failed with `status = "ok", want degraded` before the fix.
Verified by mutation -- restoring first-wins dedup fails it again.
2026-09-17 11:48:23 +00:00
sam 670fcaf9d4 fix(telegram): keep every tool line that fits and mark every answer cut
Two defects in the activity/answer budget, both found in review.

The tool block returned as soon as the newest line alone fit, so a turn with
several short tool calls discarded history that was never over budget and
reported a "+N earlier" that was untrue -- those lines had room. The window
now widens from the newest line backwards while the result still fits, so
every line that fits is kept. The indicator appears only when something is
genuinely left out.

The opening frame sliced the answer to its budget without an ellipsis, so a
large first chunk -- or a turn that never opened a reply, leaving messageID 0
-- rendered text that appeared to begin mid-sentence, while later frames
marked the same cut. Telegram messages are immutable, so it could never be
corrected. Every frame now marks the cut; the special case only ever bought
one rune.

TestLiveReplyFramesStayWithinOneMessage asserted the ellipsis on the last
frame only, which is what let the unmarked opening frame through. It now
checks every frame, and the count bound follows: identical frames are
deduplicated by render(), so an unmarked opening frame was previously a
distinct body where a marked one is not. Verified by mutation -- restoring an
unmarked opening cut fails the test on frame 0.
2026-09-17 11:40:08 +00:00
samcharles93 f34c4076d6 Disk readiness probe watches only work_dir, so a full root filesystem goes unreported (archie)
Implements #835
2026-09-17 11:34:38 +00:00
sam c1ccf2f023 chore(telegram): resolve the state-store test conflict and drop dead clamp helper
Rebased onto main, which now carries an equivalent STATE_STORE_TOKEN isolation
guard in state_store_client_test.go from an independent baseline repair. The
two changes were the same fix expressed twice, so main's wording is kept and
this branch's duplicate is dropped -- the file is now identical to main and no
longer appears in the diff.

That leaves one commit, touching only internal/channels/telegram/live.go.

Removing clampToOneMessage, which this change orphaned: all three of its call
sites were replaced with clampToRunes directly, and `unused` flagged it. Dead
code left behind by a rewrite does not ship.
2026-09-17 11:31:05 +00:00
samcharles93 9faa1f14d7 Telegram tool-activity block is uncapped and crowds out the answer (archie)
Implements #839
2026-09-17 11:27:52 +00:00
sam 8ab86b86b3 Merge pull request #844 from samcharles93/fix/archied-watchdog-test-flake
fix(archied): stop the shutdown-watchdog test racing the scheduler
2026-09-17 21:24:29 +10:00
sam c3b8c6c012 Merge pull request #843 from samcharles93/feat/840-repeated-successful-tool-calls-are-never-collapsed-into-a-co
Repeated successful tool calls are never collapsed into a counted entry (archie)
2026-09-17 21:23:52 +10:00
sam c4a27ccdc4 Update internal/gateway/stream.go 2026-09-17 21:19:53 +10:00