Commit Graph
1200 Commits
Author SHA1 Message Date
sam 012964b60e 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 d7aa6b6ac6 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 ca88255715 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 c09044c486 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 98c4032285 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 2c805ef15d 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 6843cea832 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 f5987ccfa2 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 9e6ac82cd4 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 7bf9d120f9 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 04656ed8eb 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 5efa8645e7 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 b422b56bc1 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 1f975f37ad feat(docsgen): add a non-destructive check mode for generated drift
`docs/data/generated/contracts.json` sat stale since 4b340d2b 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 294b641bb7 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 / 2e1e1549.
- 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
  (84b32694); 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 4b340d2b: 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 2e1e1549ec 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 e869261109 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 a484693f11 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 353c9f7e17 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 06df575fde 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 37792c9e was the second),
so the checkout/reset/clean sequence is rewritten rather than patched again.
2026-09-18 01:49:28 +10:00
sam b2f330a867 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 c6dcfd6671 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 657e42fcff docs(release): drop an unreleased claim from the 1.27.0 agent notes 2026-09-17 13:56:13 +00:00
sam 1deac797b9 chore(release): archied v1.27.0 archie v1.27.0 2026-09-17 13:42:26 +00:00
sam 3b801af68a 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 e338473414 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 4ef56edd77 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 10c2543527 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 dc744c0b4f 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 21d8250cde 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 781358c862 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 2cd796a3a3 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 51a05c0f33 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 3b266c71ce 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 8378c92739 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 9bbce39df2 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 8dd8841a7a Telegram tool-activity block is uncapped and crowds out the answer (archie)
Implements #839
2026-09-17 11:27:52 +00:00
sam b215636f99 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 405e525c76 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
samandgreptile-apps[bot] e39b02d7ee Update internal/gateway/stream.go
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-09-17 21:19:53 +10:00
sam bd7fb053a7 fix(archied): stop the shutdown-watchdog test racing the scheduler
TestShutdownWatchdogHangingPastLeashForcesExit gave the watchdog two leash
lengths (60ms) to force an exit, but the 30ms leash only starts the timer --
the firing goroutine must then be scheduled before the injected exit is
observable. Measured margin is ~29.7ms, so the test is a wall-clock race
against the Go scheduler and fails intermittently on a loaded machine, where
it parks real work behind a gate failure unrelated to the change under test.

The assertion is now the contract that actually matters and that scheduling
jitter cannot falsify: the exit must not happen before the leash, and it must
happen. Waiting for it uses a generous ceiling, and the new elapsed >= leash
check catches an early fire strictly -- something the old test could not do,
because it only bounded lateness.

The inverse test asserts the ABSENCE of a forced exit, which load cannot
falsify (a slow runner only delays the exit being checked for), so it keeps a
tight bound and the suite stays fast.

Verified by mutation: removing the forced exit fails the first test, and
firing before the leash now fails it on the new elapsed check.
2026-09-17 11:17:19 +00:00
samcharles93 cca71a5dd6 fix: Repeated successful tool calls are never collapsed into a counted entry (archie)
Fixes #840
2026-09-17 11:13:11 +00:00
samcharles93 38036912fd test: failing repro
Refs #840
2026-09-17 11:10:30 +00:00
samcharles93 f93792d1c0 fix: baseline gate repair (go test ./... -count=1) 2026-09-17 11:03:29 +00:00
sam 884fcd0ce8 Merge pull request #838 from samcharles93/fix/telegram-output-and-bot-upgrade
fix(telegram): summarise tool results instead of quoting an arbitrary line
2026-09-17 20:31:50 +10:00
sam 5539f2b343 fix(telegram): require the truncation wrapper before treating a count as metadata
Review found that a bare "showing 3/197 lines" inside ordinary output was
accepted as truncation metadata and replaced by a summary, hiding the real
result. Both built-in producers wrap the notice as "[truncated: …]"
(internal/tools/builtin/truncate.go), so the wrapper is now required rather
than tolerated: it is the only marker separating a notice the tool printed
from content that merely mentions a count.
2026-09-17 10:13:07 +00:00
sam d783bebf37 fix(telegram): address greptile review on tool-result rendering
Four findings from review, all valid:

1. Search detection is now gated on the tool name rather than applied to every
   result. A compiler diagnostic ("file.go:42: message") has the same shape as
   a search hit, so counting it reported a build error as "N matches" and hid
   the diagnostic.

2. Only ripgrep match lines are counted. The hyphen context form
   ("path-N-text") and "--" group separators were being counted as matches, so
   a search with context requested reported the match count plus every
   surrounding context line.

3. The notice parser accepts shell's "showing last N/M lines" form as well as
   the plain "showing N/M lines" one. Shell emits the "last" form, which failed
   integer parsing and was not recognised as metadata -- so a truncated shell
   result quoted the raw truncation notice as its preview, the exact defect this
   change set out to remove. The summary now also states which end was kept
   ("97 lines total; showing last 66" for a tail truncation).

4. The renderer cases are consolidated into one table-driven test per the
   development protocol in AGENTS.md, covering all four defects above plus
   singular/plural, colons in paths, and module-cache noise.
2026-09-17 09:49:49 +00:00
sam 72bc95cc00 fix(telegram): summarise tool results instead of quoting an arbitrary line
Operator report: tool output in the Telegram channel was unreadable during
search-heavy turns -- a wall of fenced blocks each showing one arbitrary
match line ("/path/config.json-322-          }") under a heading that said
only "grep -- done".

The renderer quoted the first non-module-cache line of a result and appended
a line count recomputed from its own truncated sample, which could not agree
with the total the tool had already reported: one search rendered the tool's
"194 more lines" beside our "… 3 more lines". Two different numbers for one
result set read as noise, and the quoted line carried no context at all.

- Describe, don't quote: a search is reported as "N matches", a truncated
  result as "<total> lines total; showing <n>", and every other tool falls
  back to its first informative line. Truncation notices are skipped, since
  they are metadata rather than content.
- Never invent a count: the tool's own reported total is the only
  trustworthy source, parsed from its truncation notice rather than
  recomputed from the visible sample.
- Remove the now-dead compactToolPreview and countNonEmptyOrContentLines.

Also bump go-telegram/bot v1.25.0 -> v1.27.0, which fixes a streaming bug
that lands squarely on this path: rawRequest sent the multipart body through
an io.Pipe, which net/http cannot replay, so sendMessage/editMessageText
failed until the connection was dropped.

Remaining work from the report (collapsing repeated calls into one counted
entry, and a ring of recent activity lines with a capped frame) is tracked
in #837.
2026-09-17 09:36:28 +00:00
sam b250dc47d1 docs(release): document what a release publishes
The zip and its Release were undocumented: RELEASING.md described the
images and the gate, and nothing about dist-zip, the Release asset, or
that a gateway-only release does not rebuild the agent image. Adds that,
plus the consequence that bit this release -- Actions runs the workflow
from the tagged commit, so a deploy.yml fix must be an ancestor of the
tag rather than a commit on top of it.
2026-09-17 07:20:33 +00:00
sam 6dfbc5180d chore(release): archied v1.26.0 archie v1.26.0 2026-09-17 07:17:34 +00:00