cd22fce26635fdacff7ebbe6784de291c6549262
205
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
928d7041e6 |
feat(agentexec): serve capture tools to harnesses over MCP
archie-agent mcp is a stdio MCP server, on the official go-sdk, serving a stage's capture tools and appending accepted calls to a captures file. The harness runner writes the tool spec and a standard mcpServers config, registers it through HarnessSpec.MCPConfig, and reads the captures back into the stage result. The captures file is writable by the harness user, so the worker validates every record again with the same acceptCapture the built-in loop now shares, and forged, undeclared or over-cap records are dropped. A stage with capture tools on a harness without MCP is refused before it runs. |
||
|
|
2f866ac6d8 |
feat(egress): relay forwards the proxy, NATS and the State Store
A Kit task's worker shares the sandbox network with its harness, so it reaches NATS and the State Store through the relay like the harness reaches the proxy. archie-agent relay takes repeated -forward listen=target pairs, binds them all before serving so a port conflict fails at start, and stops every forward when one fails. RelayArgs builds the command from the fixed relay ports. |
||
|
|
3394d36086 |
feat(egress): relay forwarding a sandbox network to the egress proxy
archie-agent relay listens on the sandbox's isolated network and joins every connection to one fixed target, the proxy. The relay holds no secrets and can reach nothing else, so the host needs no address on a sandbox network at all. |
||
|
|
8c55b5d4e4 |
chore(state-store): remove the one-time SQLite import and db_path
Every install serves from Postgres, so the legacyread/legacyimport packages, the archie-state-store import command, the boot gate that refused to serve over unimported SQLite files, and db_path (which only located those files) go. Migration 0010 drops the import_completion table. |
||
|
|
f68355ca77 |
Merge branch 'pg/foundation' into worktree-agent-a96503bc8828fc104
# Conflicts: # docs/data/generated/dev-docs.json # internal/app/archied/state_store_test.go # internal/app/archied/state_store_toolcalls_test.go # internal/contracts/state/v1/state.pb.go # internal/daemon/dispatch_bindings_test.go # internal/infrastructure/bindingcipher/cipher_test.go # internal/infrastructure/captureintake/receiver_test.go # internal/infrastructure/edastore/contracts_binding.go # internal/infrastructure/edastore/testsupport_test.go # internal/infrastructure/postgres/edastore.go # internal/infrastructure/postgres/edastore_test.go # internal/infrastructure/staterpc/error_test.go # internal/store/store.go # internal/webui/api_binding_test.go |
||
|
|
0495af7c3d | docs(store): drop residual SQLite references; fix lane lint findings | ||
|
|
bf3e688bfe |
refactor(store)!: remove the SQLite task store, the PocketBase event store and the SQLite session store
The State Store, event capture and Gateway conversations already serve from PostgreSQL. This deletes internal/store and internal/infrastructure/edastore, the SQLite gateway session store and openProductionTaskStore, and the -db recovery path on a legacy task file; backup, restore, validate and rollback work on the database database_url names. - The binding-secret cipher moves to internal/infrastructure/bindingcipher and ToolCall to internal/infrastructure/postgres. - NewSessionStoreMemory is now a pure in-memory store that passes the shared SessionStore conformance suite. - Tests run against PostgreSQL through internal/infrastructure/postgres/pgstore; legacyimport/legacyfixture writes the legacy files the import and the boot gate read. - The cron dialect is owned in internal/domain/scheduling, so github.com/pocketbase/pocketbase and pocketbase/dbx leave go.mod. modernc.org/sqlite stays for the one-time import (legacyread). - The UI and Messaging architecture gates ban the Postgres and legacy readers in place of internal/store. |
||
|
|
3fce04bf5d |
merge: t2db.40 sources and signing into pg/foundation
Resolves against t2db.36: captures carry both event_type and unsigned (proto field 10), the State Store serves sources and event types from the Postgres EDA store, the capture row shows event type and signature together, and the staterpc sentinels map both ways from one table. |
||
|
|
963f967c56 |
feat(eda): sources own signing, with UUIDv7 paths and approved unsigned option
A source is the capture endpoint: a UUIDv7 path by default or a unique URL-safe custom path, signed by default with an Archie-generated secret (encrypted via the bindings cipher), or unsigned after an approval. Intake verifies X-Hub-Signature-256/X-Signature-256 against the source secret before redaction; an unauthenticated event on a signed source is captured but never dispatched, an event on an approved unsigned source dispatches and is marked unsigned. The binding secret is retired; migration 0006 derives sources from existing binding and capture source strings, moving each binding's secret onto its source. SourceStore crosses the State Store gRPC contract. The dashboard gains a sources panel and flags unsigned in the capture inspector, binding list and task timeline. |
||
|
|
a31ac8f675 |
Merge branch 'worktree-agent-a2b33953bdffebf56' into worktree-giggly-marinating-lamport
# Conflicts: # docs/data/generated/dev-docs.json # internal/app/archied/state_store_pool.go |
||
|
|
970a65fe36 |
feat(archied): serve the State Store, event store and Gateway conversations from Postgres
The State Store's task and event-capture stores and the conversation store read by archied and served by archie-gateway now open on database_url. Every serving process refuses to start when legacy SQLite data exists and no import completion is recorded, naming archie-state-store import; a fresh install records completion itself. The Gateway holds its Postgres serve claim for its lifetime and releases it before the pool closes. |
||
|
|
9f5f072fe7 |
Merge branch 'worktree-agent-a091696d945ed3377' into worktree-giggly-marinating-lamport
# Conflicts: # cmd/archie-state-store/recovery.go |
||
|
|
fe819d489a |
feat(archied): recovery commands on PostgreSQL; fail-closed pre-update snapshot, no automatic schema rollback
Without -db, backup/restore/validate/rollback resolve database_url from the config and work on the whole PostgreSQL database. Restore claims every service role; rollback claims the State Store role; validate refuses a schema newer than the binary. The installer refuses a daemon update it cannot snapshot first; the watchdog never restores the database and prints the explicit offline restore instead. |
||
|
|
cdb34e2295 | fix(state-store): real-process tests give the State Store a database_url | ||
|
|
42dcc80754 |
feat(state-store): one-time import of the legacy SQLite stores into Postgres
archie-state-store import copies the State Store task database, the PocketBase event store and the Gateway conversation store, all named from db_path, into Postgres in one transaction. The bead asked for an archied command; offline maintenance of a store belongs to the binary that owns it, so it sits beside backup/restore/validate/rollback instead. It refuses rather than guesses: while the state-store or gateway ownership claim is held, when a domain it imports already holds rows (an allowlist of that domain's tables, checked after Migrate), on a completed prior import, on FK orphans, alias case collisions, duplicate bindings, events whose (at, id) order microsecond storage would change, schema gaps, and any value the target column cannot hold, naming table, row, value and rule. Historical ids are kept and every identity sequence is set from AUTOINCREMENT's high-water mark. After loading it compares key sets, event order, resource blobs and binding secrets byte for byte and the next id of every sequence, checks the source files were not written while read, and only then writes an import_completion row (migration 0005) in the same transaction. postgres.ImportComplete and legacyimport.HasLegacyData are the two halves of the boot gate: legacy data without a completed import must not serve. |
||
|
|
65697bd4ae |
refactor(state-store): remove the PocketBase admin view
stateadmin served read-only PocketBase views over the SQLite task file on -admin-addr. PocketBase is SQLite-only and the State Store moves to Postgres (archie-core-7r0x), so the view goes; operators use a Postgres tool of their choice. |
||
|
|
62645d1a93 | feat(playbooks): archie-playbooks serve, a language server publishing lint findings as diagnostics | ||
|
|
0ad5d2acd9 | feat(playbooks): lint an EDA playbook directory with -eda-dir | ||
|
|
1b28bba234 | feat(workflow): routing and playbook findings carry the key's file:line | ||
|
|
89c074d213 |
feat(edastore)!: move event capture and bindings onto PocketBase collections
The event-capture tables (captures, mappings, bindings, binding_dispatches,
playbook_dispatches) now live in PocketBase-owned collections and their ids
are opaque record ids rather than autoincrement integers. The task lifecycle
stays on SQLite: tasks/transitions/events carry FIFO claim ordering, id-cursor
pagination and the task-grant map, none of which gain anything from being
hand-editable. binding_dispatches.task_id is the single seam and stays an
integer addressing that store.
BREAKING: CapturedEvent.Id, Mapping.Id, Binding.Id and Binding.MappingId are
strings on the wire, as are the ids in the capture/mapping/binding requests.
RecordDispatchRequest.task_id is deliberately unchanged.
What the collections buy, beyond storage: a payload nobody has modelled yet is
inspectable, a mapping is editable at runtime, and a binding's relation to its
mapping is enforced. The old schema declared no FOREIGN KEY on that link, so a
dangling mapping_id was previously possible and is now refused.
Behaviour preserved deliberately, each recovered from the SQLite version
rather than reimplemented from memory:
- draft -> pending_approval -> armed, with approval only from
pending_approval and an edit always returning a binding for re-approval
- one binding per source, guarded on insert, update and approve
- an empty secret on update keeps the stored one, so an edit form that does
not echo it back cannot silently disarm a binding
- ErrMappingNotFound / ErrBindingNotFound on a missing delete target
- sentinels are re-exported from storecontract, never redefined: staterpc
matches on exact canonical message to rehydrate them, so a second
definition would break errors.Is across the wire invisibly
Two implementation notes worth keeping:
- at-most-once dispatch is now a unique index rather than INSERT OR IGNORE.
Only the unique-violation maps to ErrAlreadyDispatched; any other save
error is returned, because treating them all as "already recorded" would
turn the ledger into a silent at-least-once dispatcher.
- captures store received_at themselves at nanosecond precision in a
fixed-width layout. PocketBase autodates are millisecond and record ids
are random, so same-millisecond captures would otherwise order
arbitrarily; the old store got insertion order free from autoincrement.
- ListUndispatchedCaptures is raw SQL: the anti-join is a subquery and
PocketBase's filter DSL is not SQL. A read fires no hooks either way.
Adds tool_calls, which had no persistence at all: tool calls only ever reached
the on-disk task log, readable as text but never queryable or watchable.
Nothing writes it yet.
The binding secret cipher moves with the bindings it protects.
|
||
|
|
6f43bc5f3b |
feat(stateadmin): read-only operator dashboard over the State Store
Serve an optional PocketBase surface over archie.db from the process that already owns it, behind archie-state-store -admin-addr. It co-tenants on <db_path>-tasks.sqlite via PocketBase's DBConnect hook rather than opening a database of its own, so the single-owner ownership claim covers it and PRAGMA user_version stays archie's. Every archie table is exposed as a view collection, which is read-only by construction. Views alone do not hold that line: PocketBase also ships POST /api/sql, which executes write statements as well as reads, and /api/backups, which would put a second snapshot and restore semantics beside store.Backup's VACUUM INTO. Both routes are refused rather than left behind a superuser check, because a superuser writing task state is still a second writer. The gRPC contract remains the only writer. apis.NewRouter binds the JSON API but not the dashboard (apis.Serve mounts the embedded UI itself), so /_/ is mounted here and the caller keeps the listener. The dependency pin and the Taskfile/README changes for this landed with the preceding commit, which swept up the staged files. |
||
|
|
a9f5667d62 |
refactor(indexing): delete the workspace codesearch indexer
The index built google/codesearch over the chat workspace on every daemon start, for the process lifetime, through a child-process helper and a SQLite metadata DB -- and grep consulted it only for searches confined to the workspace root, which the analysed sessions showed was a small fraction of searches. The compute was continuous; the benefit was not. Removes internal/indexing, the workspace-codesearch helper subcommand, the [indexing] config section, and the GrepIndex accelerator seam from the grep tool, which returns to its direct walk. google/codesearch leaves go.mod with it. |
||
|
|
a7028067f1 | chore: cleanup incorrect phrasing on package comments. | ||
|
|
98052f785f |
feat(webui): let a person sign in and act as themselves
The last gap in the identity boundary: enabling a provider used to lock browsers out, because nothing could turn a sign-in into the credential the dashboard already verifies. Now a browser completes the authorization code flow with PKCE and the identity reaching the request context is the person who signed in. The audience is requested AT THE AUTHORIZATION ENDPOINT, not only at the token endpoint. Infra measured that a provider asked otherwise returns the audience empty, and this dashboard then refuses a perfectly valid token -- a failure that reads as a signing fault and is actually a missing query parameter. A test asserts the parameter is present, so it cannot quietly go missing. The flow is the libraries': discovery, the code exchange, PKCE generation and the challenge transformation are go-oidc and x/oauth2, so archie writes no protocol. The token returned by the exchange is verified through the SAME Verifier a presented token goes through, and the identity is then resolved through the same rule -- one Resolve now shared by Authenticate and the callback, so a browser sign-in cannot be accepted on terms a presented token would be refused on. Archie still issues no session. The callback stores the PROVIDER's token in an HttpOnly cookie and every later request re-verifies it, so what archie holds cannot outlive the provider's own decision. The callback checks the state it issued, and expires the state and PKCE verifier cookies on use. The sign-in routes mount on the bypass mux because they are how a caller becomes authenticated; gating them behind the credential they obtain would make signing in impossible. The client secret is never a flag: -oidc-client-secret-env names the environment variable holding it, so it cannot reach a process listing or a log line. No client id means no sign-in route and token verification is unaffected, which is what an agent-only deployment wants. Evidence, produced by driv·ng the flow rather than the seam: internal/webui/api_tasks_actor_test.go's TestBrowserSignInRecordsTheSignedInPerson walks sign-in -> callback -> cookie -> action and asserts the recorded actor is the signed-in person with human_approved. TestCallbackRefusesAMismatchedState asserts a replayed state is refused before any credential is verified. internal/infrastructure/oidc/flow_test.go runs the real flow against a test provider's own authorize and token endpoints, asserting the audience parameter, the PKCE challenge, a successful exchange, and a refused wrong verifier. Verified: task check exit 0 on this tree. |
||
|
|
6a3b350915 |
feat(update): let every host binary report its version, and refuse skew
The updater is component-driven: it compares the daemon and agent versions and
acts only when they differ, so a host whose individual binaries disagree looks
healthy. Carina ran a hand-installed archie-messaging 1.35.0 against a 1.30.0
state store and crash-looped on an RPC the older store does not serve, while
the updater reported "no approved component changes; nothing to install".
The reason a comparison was impossible: three of the six host binaries carried
no version at all. archie-ui, archie-messaging and archie-playbooks did not link
internal/app/archied, so the release ldflags never reached them; the gateway and
state store linked the variable but exposed no flag. Only archied could say what
it was.
- internal/buildinfo carries Version, stamped by all three build sites: the
zip, install.sh, and the updater itself.
- Every host binary answers -version ("<name> <version>"). archied's existing
two-line output is unchanged, because something parses it.
- archie-update-install reads each installed binary before it can report
"nothing to install" and refuses, naming every binary that disagrees with the
daemon's version; after an install it verifies the same set against the
release it just installed, so a binary the release did not rebuild is skew
rather than success.
- TestDistZipShipsEveryHostCommand pins stamping across the three build sites
and requires each cmd/ to report, so a seventh command cannot arrive unstamped.
|
||
|
|
28128eb4ed |
feat(identity): attribute a task action to the identity that acted
The transport could carry an actor and nothing filled it. It does now, so a dashboard approval is recorded as the person whose credential verified, and an agent's token is recorded as the agent's action -- for an agent, agent_approved; for a person, human_approved; and for a caller whose identity archie could not verify, task_approved, which claims nothing about who did it. The actor travels the path the action takes: webui reads it from the request context the middleware resolved, carries it in the gateway request, the daemon passes it through the in-process adapter, and the NATS request body carries it to the service that records it. Scope stays separate from actor at every hop, because scope is which task a caller may touch and the actor is who touched it. A chat channel's bound identity is an actor too: a bot acting on its own channel's task is recorded as an agent's action rather than a person's, via ActorFromScope, whose empty kind is what keeps it out of human_approved. The agent-facing task_action tool passes that identity and never input["identity"]. The UI process's credential check is now filled by endpoint references rather than by configuration: -oidc-issuer and -oidc-audience on archie-ui, two URLs the process already understands the shape of, with the verifier built in Run because cmd/ parses flags and nothing else. The UI package still never reads config, and a configured provider that cannot be reached fails boot rather than falling back to the gate that names nobody. Evidence for this change, stated as measured: go build ./... and go vet ./... are clean, and every package this touches passes -- webui, domain/taskactions, infrastructure/taskactions, infrastructure/gatewayrpc, gateway, app/archieui, app/archied, domain/messaging, channels/telegram, cmd/archie-ui. task check could not be run to completion: it fails in cmd/archie-messaging on an untracked internal/buildinfo package another lane has in flight, which is not this change and was left untouched. The end-to-end flip is covered in internal/webui/api_tasks_actor_test.go: a person's credential produces a record naming that person with human_approved, an agent's produces agent_approved, an unverified request produces task_approved with no actor, and a request carrying forged actor fields cannot name one. |
||
|
|
b4358c5324 |
refactor(messaging): sever the Messaging Service from the store and workflow runtime
The PRD's deletion gate for the Messaging Service could not pass: go list -deps ./cmd/archie-messaging linked modernc.org/sqlite, internal/store, internal/domain/workflow and internal/agentexec -- all through one import, archiemessaging/run.go -> internal/app/controlplane, from which the service used three symbols. The decision was to sever rather than amend the gate, because a boundary you whitelist around is no longer a boundary (archie-core-1ng1, recorded in docs/architecture/migration-decisions.md). Measured before touching anything: internal/app/controlplane was the ONLY direct import of the service that dragged those runtimes -- every other one was clean -- so severing this one dependency is sufficient for the gate. Moved into the new internal/infrastructure/controlplanerpc: the generic resource client (NewRPCClient, Query), the RuntimeChatConfig projection, the reader interface (now the exported ResourceReader), the wire sentinels, the status mapping (now ClientError), and the channel-settings document with its decode -- ChannelSettings, TelegramSettings, WebhookChannelSettings, EmailSettings, RateLimitSettings, ChannelDuration, DecodeRenamingLegacyKeys. internal/app/controlplane keeps the store-backed server, the Definition registry, every kind's seed/validator/Normalize, the schema derivation, and its resource-specific reads and watches. Its Client embeds the new one, so the read path has one implementation while the workflow, persona and cronstore reads stay with the processes that already link those engines. The documents are type-aliased back into this package so the store-backed side reads them by the names it has always used: one definition, not a copy on each side of the boundary. The gate is now enforced by cmd/archie-messaging/architecture_test.go, measuring the linked binary against the PRD's banned list, with one exception checked in both directions: internal/domain/workflow/task, the Task status and view vocabulary whose own dependency set holds none of the banned runtimes. The UI gate carries the same entry for the same reason, and the fleet skill names it as the precedent. Verified: task check exit 0. The gate was red-proofed twice -- banning internal/channels fails it, and removing the workflow/task exception fails it -- so neither the loop nor the exception is decorative. |
||
|
|
55ea071092 |
docs: drop one host's service names from port guidance
Five files named a specific host's service and the port it holds as the reason a deployment might move the state store's listen address, including config.example.toml, which ships to every operator. The guidance keeps its point -- move the listen/target pair together when a port is already taken on the host -- without naming a service the reader may not run, or have heard of. Also corrects the Taskfile's dev-stack summary, which still described the state store as binding 127.0.0.1:9090. deployments/dev.toml pairs it with 9091, and has since the pair became configurable, so the comment described a stack that does not start. |
||
|
|
856e2eef71 |
fix(configuration): resolve the default config path in one place
Four binaries derived the default with os.UserConfigDir while the daemon resolved it from its own config home. The two agree on Linux with an absolute XDG_CONFIG_HOME and diverge everywhere else, so one deployment booted from a different config file depending on which binary started. Move the rule into the package that owns configuration resolution (internal/infrastructure/configuration, which already owns xdgDataHome and DefaultWorkDir) as DefaultConfigDir/DefaultConfigPath, and have every -config default take it from there: archie-gateway, archie-messaging, archie-state-store (serve and recovery) and archie-ui, plus the daemon's own parseArgs, setup generator and drain-marker path. Fence the claim at the source, since the resolved value is only observable by starting a process: no source under cmd/ or internal/app/archied may call os.UserConfigDir, and every -config registration must default to the helper. |
||
|
|
042a86ce4a |
fix(config): judge a database-owned setting at the layer that owns it
Review of the two previous commits found the split was incomplete in both directions: the checks moved off the file load path were still enforced anywhere the value could enter the system, and the fold reached only one of the three overlay paths. A stale database-owned TOML value could still stop archie-state-store. The process seeds every control-plane resource from the same file config on a fresh database, and the seed runs the resource's own validator; three of the five values the loader now accepts aborted the boot there (verified by booting RunStateStore before the fix). A seed that does not validate is now SKIPPED and reported instead of fatal: the resource stays absent, so the file's value is the one in effect and editing config.toml is still the fix -- the daemon and the Gateway are where it fails closed, at boot.runtimeConfig. The resource validators were weaker than configuration.Validate for exactly the fields the split reclassified, so a value the file path used to refuse at load became storable in the database, and then un-fixable by editing config.toml. The trigger enum and the test-glob rule now come from the configuration package rather than being restated, the container image is required there as it is in the file, and a table test ties the two layers together value by value. The directory form of -config-overlay kept the archie-core-e2e2 failure: it decoded each overlay file straight into the populated config, so a map-valued entry it only partly addressed still cleared the fields it did not name. Both the overlay layer's main file and its feature files now fold, which is what Loader.Dir's documented parity with Loader.Overlay has always claimed. The overlay file's key report is derived from the apply's own view of the file as well as the file decode's, because TOML matches keys case-insensitively and the fold's yaml decode does not: a key only the file decode matched was consumed by the report and dropped by the apply, a silent no-op that worked in the base file. Tests: the state-store boot is asserted against the real process, the directory overlay and the case-mismatched key each have one, and ImportConfig pins that a refused seed is not stored. |
||
|
|
21c6aca513 |
fix(statestore): build the recovery control-plane server on the shared step vocabulary
After the rebase onto main, controlplane.NewServer takes the step vocabulary it resolves definitions against (controlplane.ResourceStore, *workflow.Manager) and returns (Server, error). Both offline call sites still passed the store alone, so internal/app/archied stopped compiling -- and with it cmd/archie-state-store, cmd/archied and cmd/archie-gateway. validate and rollback now build their server through openStateStoreControlPlane, the root helper the served path already uses, so the offline checks resolve the same shared provider set (internal/infrastructure/workflowsteps) as the process whose verdict they predict, and the constructor's error is returned as a refusal rather than dropped. No second vocabulary call site: the fwmp pin on openStateStoreControlPlane covers these paths unchanged. The test's seeding helper builds its server from the same shared set (workflowsteps.NewManager) because it cannot call the unexported root helper; an empty manager there would seed values the served path never validates against. That is not merely a claim: with an empty manager the three validate tests fail with `workflow "bootstrap" step 1: unknown type "bootstrap.prepare"`, so they already pin that the offline path resolves a live, shared vocabulary. |
||
|
|
b5b58c370a |
fix(statestore): read a kind the store does not hold as its seed, and stop validate touching the daemon's log
Four defects from the re-run contract review, all in the recovery path. A store missing a control-plane kind was refused while a store with no resources table at all was accepted -- two stances inside validateStore for states the daemon cannot tell apart. The State Store seeds every kind from its own config before it serves (RunStateStore -> ImportConfig), so a kind the file does not hold yet is one archied reads the seed for: an upgrade that adds a kind, and a validate before the State Store has started again, exited 1 with "read provider-settings: resource not found" for a store the daemon boots on fine. StoredRuntimeConfig now reads a missing kind as the seed the State Store would write for it (Definition.seededValue, shared with ImportConfig so the two cannot drift), and the missing-table branch is the same stance taken to its extreme. defaultConfigPath() derived the daemon's config with os.UserConfigDir, which disagrees with archied's configHome on darwin and rejects a relative XDG_CONFIG_HOME outright -- leaving validate with an empty path and no verdict, on a host where archied boots from relative-dir/archie/config.toml. It is now the daemon's own rule, exported as archied.DefaultConfigPath and used by the daemon's own -config default too, with a test pinning the equality. -h exited 2, the code documented as "the command line was wrong", while the serve path in the same binary exits 0 and main.go advertises -h for these subcommands. ErrHelp now returns 0. validate resolved the boot config through loadConfig -> setupLogging, which created cfg.Log.File's directory, opened the log, and wrote a line stamped component="daemon" -- a diagnostic editing the deployment it inspects, and rotating a log the daemon is writing. boot.stderrLog keeps setupLogging on the stderr logger for the recovery path: no feed, no task-log registry, no durable copy. Tests: TestRecoveryValidateRunsTheGateBootRuns now asserts the unseeded and the missing-kind stores are accepted (both exited 1 before), while the bogus-policy case still refuses; TestRecoveryHelpExitsZero, TestRecoveryValidateLeavesTheDaemonLogAlone and TestRecoveryDefaultConfigFollowsTheDaemonsConfigHome are new. Each was run red first, and the seed fallback and stderrLog were mutation-checked. |
||
|
|
8d015db7c1 |
fix(statestore): make validate run boot's gate, and stop backup replacing the database
Two P1 findings from review, both about a claim outrunning the code.
validate answered a different question from boot's. Boot refuses on
configuration.Validate over the file config with every stored resource
layered onto it (internal/app/archied/control_plane.go:27), which is a
stricter check than the write path's per-resource Decode: validateScheduling
never inspects dispatch.trigger and explicitly permits "0s", while boot
rejects an unknown trigger and a non-positive poll interval. A store holding
such a value printed "is a valid store ... N stored resources validate" and
exited 0 while archied exited 1 on it -- a false green pushing an operator
toward the blunt restore instead of the surgical rollback.
validate now runs both layers and reports both, in boot's order:
store.ValidateFile, then the write path's ValidateStored, then the config
gate. The layering itself is now one implementation: controlplane's
runtimeConfigFrom takes a resourceReader, which the gRPC client and a new
Server.StoredRuntimeConfig (reading its own store) both provide, so the
offline check cannot drift from the daemon's. validate takes -config /
-config-overlay (default: the path the serve subcommand uses), because the
question is about the stored values layered onto that document.
backup had no guard against -out naming the database. It renames its
snapshot over the target, so `backup -db F -out F` replaced a database a
serving State Store may still have open and orphaned the WAL of the file it
just unlinked -- the state Restore refuses up front and maintenance.go's own
comment calls unrecoverable. backup now refuses with the same message
Restore uses, which is what makes its exemption from the ownership lock
sound.
Claims corrected where they ran ahead of the code: ValidateStored now says it
is the write path's check and not boot's, the Restore comment no longer
promises "never a mixture" for the sidecars it removes first, the usage text
advertises validate's -config, and the architecture table drops "must be
stopped" for validate (nothing enforces it; read-only opens skip the lock by
design) and states which two layers validate reports.
Tests: TestRecoveryValidateRunsTheGateBootRuns fails on the pre-fix code
("validate accepted a stored policy the daemon refuses to boot with") and
covers a store the State Store never seeded; TestRecoveryBackupRefuses-
TheDatabaseAsItsOwnSnapshot fails on the pre-fix code ("backup over the
database itself succeeded"). The validate-accept test now seeds the store
through ImportConfig and asserts the reported count is non-zero, and the
stored-resource case uses a value both gates refuse instead of one only the
write path does.
|
||
|
|
014868eda8 |
feat(statestore): offline backup, restore, validate and rollback
archie-state-store gains the offline recovery commands
docs/prds/runtime-control-plane.md ("Bootstrap, migration, and recovery")
asks for. They work on the task database file directly -- <db_path>-tasks.sqlite,
not db_path -- and need neither archied nor the Web UI, which matters because
the failure they exist for is the one that stops archied starting:
backup -db F -out F consistent snapshot (VACUUM INTO), verified as a
usable store before it is published; safe against
a serving store
restore -db F -from F replace the database with a snapshot, dropping the
replaced file's -wal/-shm
validate -db F readable, not corrupt, schema no newer than this
binary, every stored resource decoding under the
definition that owns it
rollback -db F -kind K replay an earlier revision of a stored resource
[-revision N] through the ordinary replace, recorded as a new
revision
No rollback RPC is added and none is needed: a revision carries its own value,
so restoring one is the same replace the dashboard and the channels already
use, by hand, with the store stopped.
"The State Store is stopped" is checked rather than assumed. The serving
process now takes an exclusive flock on <db>.lock for its whole life
(store.AcquireOwnership), and restore/rollback refuse with
`task database is owned by another process` while it holds it. backup is the
deliberate exception: the update installer runs inside the process it is
replacing and cannot stop the State Store.
scripts/archie-update-install takes its pre-flight snapshot through
`go run ./cmd/archie-state-store backup` from the release being installed
instead of its own sqlite3 shell, so the installer and an operator run one
implementation. The watchdog's refusal semantics are unchanged: an update that
cannot back up still must not start.
Docs: safe-change-and-recovery.md's "Recovery: not yet built" now describes
what exists.
|
||
|
|
2311529def |
refactor(config): delete the runtime config overlay
The control plane replaces this, rather than extending it (docs/prds/runtime-control-plane.md, "First implementation"). Until now both paths existed: overlay kept dashboard edits in its own SQLite file beside archie.db and layered them over the file config at boot and on every reload, which is the duplicate configuration authority the PRD set out to remove. Gone with it: the --no-config-overlay flag and ARCHIE_SKIP_CONFIG_OVERLAY recovery hatch, which existed because a bad overlay row could brick the boot; ReloadStatus.OverlayUnavailable; and the reload controller's overlay source. The -config-overlay file overlay is a different thing and stays. The dashboard's three write seams went too. UpdateConfig, ResetConfig and UpdateRepoField were assigned only in internal/webui's own tests, so in production they answered 503 and ConfigView.Editable was permanently false (archie-core-j28m). Removing Editable would otherwise have flipped the SPA's controls on, since configEditable read a missing field as true, so the config pages become what they already were in practice: a read of what each process is running with. Configuration is written through the control plane. apply.go survives this deliberately; archie-core-xrux carries the question of whether its map merge is still guarding the file overlay path. |
||
|
|
3944f544e8 |
feat(controlplane): runtime administration over the State Store's gRPC server
The Web UI and messaging channels now read and write Archie's runtime settings through one versioned, audited control-plane API hosted on the State Store's existing gRPC server: catalog, query, command, watch. Each feature owns its resource, validation and commands; storage only writes versions and audit records. Workflows move with it. Definitions become portable YAML compiled through a closed, typed step registry and stored as a control-plane resource, so the yaegi interpretation paths (internal/gate, wfeval, wfextract, gateeval, gateextract, skillbuild) are deleted rather than carried. The UI process reads definitions as data: the JSON projection lives in internal/domain/workflow/task so a dashboard decodes the stored collection without linking the workflow engine, which cmd/archie-ui's deletion gate forbids. Shipped definitions ride the catalog descriptor rather than a bespoke REST route, keeping the API to its four operations. archie-messaging gains -state-store-target/-state-store-token and reads channel settings from the database, failing closed when the State Store is unreachable: the database is authoritative for those settings. |
||
|
|
c29cdf6f79 |
feat(workflow): post line-anchored review comments with suggested fixes (#891)
* feat(workflow): post line-anchored review comments with suggested fixes Bead archie-core-q9au (docs/prds/inline-review.md). A review's findings reached the operator only as a flat list in the PR body, so the author had to map every finding back to its line by hand and apply mechanical fixes by hand. Now the line-anchored findings are also posted as inline review comments, carrying a one-click suggestion when the reviewer could state the fix. Domain (internal/domain/workflow): - ReviewFinding gains Suggestion; Validate rejects one on anything but a confirmed finding, so the agent's record_finding call is refused with something it can act on. Validate splits into validateAnchor / validateClassification / validateDisposition, which also brings it back under the cyclop limit the gate enforces. - StagePostReviewComments runs after StageOpenPR in the implement workflow. It posts only line-anchored findings (Line > 0); a whole-file finding has no line to attach to and stays in the body list, which remains the complete record. It is best-effort: the PR is open and the body already lists every finding, so a failed comment is logged, never a park -- the same reasoning as OpenPR's existing best-effort LinkBranch call. - The suggestion fence is gated on Verdict == confirmed where the fence is written, because it is a one-click apply: a wrong suggestion breaks the code and the author has to notice. Forge (internal/forge): ReviewCommentWriter + GitHub/Gitea implementations, type-asserted like PullRequestReader so a forge that cannot is skipped rather than faked (NoopForge is pinned as not satisfying it). GitHub loops one CreateComment per comment and joins the failures, so one refused anchor cannot drop the rest; Gitea carries them on a single COMMENT-state review. Two deliberate departures from the PRD's sketch, both recorded in it: - The interface is batch (CreateReviewComments), not one call per comment: Gitea's only inline shape is one submitted review, and the set then crosses NATS once instead of once per finding. - The head SHA is resolved inside each forge implementation rather than by the caller. The stage runs in archie-agent, which holds no forge credentials and has no PullRequestReader; the daemon-side forgerpc handler is the only place that does. Transport (internal/forgerpc): workflow.Forger gains the method, so the agent reaches the daemon over the new create_review_comments subject; the server type-asserts the writer and answers an incapable forge with an error the stage logs. This is the one proxied method whose absence on an image skew does not park a task. The reviewer prompt and record_finding schema ask for a suggestion on a confirmed, mechanically fixable defect only. Regenerating the wfextract symbol table -- the documented way a new exported workflow symbol reaches interpreted stage plugins -- also picked up symbols that were missing from the committed table (the Status* and Source* constants, ReviewCheck, Store, Task, and the _Store wrapper). Nil-guards were re-applied to every wrapper afterwards, as that file's header requires. Evidence: task check exit 0 (incl. 229 UI tests). Three mutations of the new stage logic each fail a test that names the behaviour -- dropping the confirmed-only gate, dropping the Line > 0 filter, and letting a posting failure escape -- so the tests discriminate rather than passing vacuously. * fix(build): drop the Dockerfile pin assertion The guard fetched golangci-lint's go.mod at image build time to fail the build when GOLANGCI_LINT_VERSION and GOFUMPT_VERSION disagreed. It only ever tripped on self-inflicted pin drift, but it added a network fetch and a new failure mode to the release build, which is not where that belongs. The pins stay correct (golangci-lint 2.13.2, whose vendored gofumpt v0.11.0 equals GOFUMPT_VERSION) and the comment above them still states the invariant, so the reasoning survives without the build-time machinery. The pin change itself reaches the agent image through the normal release path: CI rebuilds and pushes archie-agent on an archie/vX.Y.Z release, and a gateway-only release deliberately does not. * feat(workflow): add the remediate workflow for PR review remediation Implements step 5 of docs/prds/pr-review-remediation.md: a remediate workflow that resumes the task's existing worktree onto its PR branch (worktree.Manager.Resume, not Prepare's refresh), runs a builder agent against the review's actionable comments, commits and pushes to the same branch, and replies via the forge's ReplyToReview. Task.RetryCount doubles as the remediation round counter, capped by the repo's max_retries; the round-cap stage parks the task and posts one comment when it's hit. Task gains a ReviewPayload field (JSON-encoded review unit) with full store/proto/staterpc plumbing. workflow.Forger gains Comment and ReplyToReview, proxied to archie-agent via a new forgerpc RPC. Resume and its Dir lookup are added as an unexported optional Trees capability rather than widening the exported interface, which is already at golangci-lint's interfacebloat cap and is projected into wfextract's Yaegi symbol table for repository-authored stage plugins. The daemon-side reaction consumer that dispatches into this workflow (subscribing ARCHIE_REACTIONS, grouping comments by review, enforcing per-task serialization) is tracked separately in archie-core-8li9.4. * feat(messaging): extract standalone messaging service binary and process composition * feat(messaging): adapt channel frontends to consume Gateway ChatContract * feat(messaging): remove in-process channels and Router from daemon bootstrap Telegram, email and webhook now run only in the Messaging Service, which reaches this process through the Gateway's ChatContract. The daemon builds no channel and no gateway.Router, so the wiring that existed only to serve them goes with it: setupGateways, setupEmailGateway, setupWebhookGateway, setupTelegramGateway, buildTelegramRouter, makeTelegramReload and the release-announcement path helper. The seams those paths owned move to where they can still be honoured: - Channel ValidateConfig runs in archiemessaging.compose, which now returns an error, so a configured-but-invalid front-end fails the service rather than being dropped silently. - The inbound rate limiter moves to the Gateway process, which owns the only Router and therefore the only place a per-sender budget applies to every channel's turns. - The daemon's gateway readiness probe becomes a ContractProbe against the Gateway. It cannot observe a channel lifecycle it no longer runs, and a channel-count probe would have reported every daemon degraded. - telegramSetup is now chatSetup (in chat_setup.go), trimmed to the fields a chat turn runner actually reads. Telegram operator features that were wired only in the daemon (/update, release announcements, version reporting, SIGHUP reload) are not yet wired in the Messaging Service: archie-core-8cda.6.6. Channel lifecycle reporting: archie-core-8cda.6.8. The Gateway process builds no worktree manager, so review_pr is unadvertised on every channel: archie-core-8cda.6.7. * feat(messaging): re-wire the Telegram operator surface in the Messaging Service setupTelegramGateway satisfied eight telegram.Gateway seams from the daemon's own process. Each is resolved by where the fact it needs is owned, not by where it used to be built; the decision table is in docs/architecture/migration-decisions.md. Wired here: /update (built from this service's own [chat.telegram] check and install commands), the update-report relay (same sha256(bot_user)[:8] path the daemon wrote, so a pending report is found rather than written afresh), show_tool_calls, and /restart's config reload, which re-resolves the token and allowlist from this service's own file and refuses a reload that resolves to an empty token. /version is sourced from the Gateway: ChatSnapshot gains a Version field carrying the Gateway's rendered build block, read per call and bounded by the dependency timeout. cmd/archie-messaging deliberately takes no version ldflags, so it cannot report a partial upgrade as a matched one. RunningVersions and ReleaseAnnouncements stay nil. Both need a component's real running version, and the only versions this process can obtain are a different binary's stamps -- reporting them would manufacture exactly the false success the update check exists to catch, and the announcer without parseable versions is a no-op that reads as configured. archie-core-8cda.6.9 carries the contract that unblocks them. Dangerous stays nil: no composition has ever supplied a command authority. Enrich is dropped from the update service: componentInstallTypeEnricher read [nats], which this service must not decode, so the check command's own reported install type stands. * fix(workflow): guard inline review comments against head drift Two findings from the review of q9au. A comment's line numbers describe exactly one revision of the branch, but the forge resolved the pull request's head at posting time -- after the review had already read the worktree. A push in that window (a collaborator, a retry) meant the findings were anchored to whatever now occupied those lines, mislabelling instead of failing. The revision the review measured now travels with the comment set: OpenPR records it from the same worktree read it already performs (TaskContext.ReviewedHeadSHA), StagePostReviewComments threads it through Forger to forgerpc, and the forge refuses the whole set once the head it reads has moved off it -- which the best-effort stage logs, the PR body remaining the record. An unmeasured revision posts unverified rather than dropping every finding, so a worktree that cannot report one degrades instead of regressing. Suggestion was documented single-line only, because GitHub applies a suggestion fence up to its first line and a multi-line replacement would silently corrupt the file. Only the verdict was validated, so a multi-line suggestion reached the renderer and posted as that truncated fence. Validate now rejects an embedded newline, which makes record_finding refuse it with feedback the model can act on instead of the reviewer discovering the corruption later. |
||
|
|
10e7d0301c |
chore(memory): delete internal/memory (unification slice 5) (#889)
Deletes internal/memory (Manager, builtin.Provider, memory_edit tool) now
that slices 2-4 built the CRUD engine family and its per-turn read/write
seams. Also deletes internal/infrastructure/memory/builtin/provider.go (the
memory_edit adapter over the old package -- its markdown store already
relocated in slice 2), internal/tools/provider/memory (the old tool
registration, redundant with slice 4's memory_create/update/delete/list),
config.Memory.{Provider,ProviderConfig} and the validateMemory rejection
that existed only to complain about Provider, and webui.MemoryStatus/
MemoryProviderHandle plus its dashboard page -- never wired in production
(s.Memory was always nil), confirmed by /api/capabilities always reporting
"memory": false.
Rewrites ARCHITECTURE.md's "Memory engine family" section to describe the
current engine (internal/domain/memory contract, internal/infrastructure/
memory builtin engine + its builtin/ markdown store, the per-turn read seam
in gateway/turn_memory.go, the per-turn write tools in
gateway/turn_memory_tool.go) instead of the deleted Manager. Fixes two
docs/architecture/configuration.md rows that described the deleted
manager's literals and SaveConfig mechanism.
|
||
|
|
b09be5515d |
feat(config): let the State Store and Gateway listen addresses be configured
Both gRPC listeners took their bind address from a -listen flag default alone, with no config key. The port a service binds and the port its clients dial were therefore two separate facts -- the flag default, and [services.<name>].target -- with nothing keeping them in step. On a host that already owned the default the effect read as a code fault rather than a port collision: the store died with "bind: address already in use" while every client reported "state store: connection error ... error reading server preface: EOF". Cockpit binds 9090 by default, so this is not hypothetical. Verifying the dashboard on such a host needed a hand-written overlay plus a matching -listen, two things to keep in step by hand. - [services.state].listen and [services.gateway].listen now name the bind address. Precedence is -listen, then config, then a default applied by the loader. An empty result is a startup ERROR, never a fallback: net.Listen reads "" as "any free port", so defaulting there would bind the service somewhere no client looks and still report success. - Both flag defaults become "" so configuration can win, mirroring how archie-ui already prefers [web].listen over its flag. - Gateway listen defaults to the same constant as the gateway target, so a default deployment's client and server cannot drift onto different ports. [services.state].target still has no default: an empty target stays a startup error in the daemon and gateway, which no longer serve a local store. - ServiceConnection gains the field. Its doc now says clients read only Target and TargetToken, and Listen belongs to the process that owns the service -- the previous wording claimed the struct starts no listeners while carrying one. - deployments/dev.toml states each port once, beside the target it must match, so `task dev` is retargetable on a host that owns 9090 by editing one overlay. Tests. Unit: config defaults, explicit values, and precedence. Process: the existing real-process smoke test now takes its listen from configuration instead of -listen, so the end-to-end wiring is proven by the test that already starts the binary, with no extra process. Both were verified load-bearing by mutation -- inverting the precedence fails the unit test, and making the app layer ignore config fails the process test with "state: no listen address". Verified: task check exit 0. Also documented in config.example.toml, the configuration architecture table, and the `task dev` summary. |
||
|
|
862ac46e8b |
feat(tasks): attribute events, changes and config to the attempt that produced them
The events table had no attempt column, so two attempts of the same task were indistinguishable: a retried task's stage events interleaved into one timeline and nothing could say which run produced a given result. - events gains an `attempt` column through the existing presence-gated migrateTasks loop rather than a version bump, so user_version stays 3 and an existing archie.db is migrated in place. A legacy-database test builds the pre-change schema and proves both that existing rows survive unattributed (attempt = 0) and that a new value round-trips. - Event.attempt = 11 and ReadTaskLogRequest.stage = 9 are field additions to existing messages: no new RPC, no new table, and no change to any canonical error message that crosses the state-store wire. - Every task event the workflow engine emits now carries the attempt. Producers that have no attempt yet (task_queued, binding_dispatch_failure) stay unattributed rather than guessing one. - Changed files are captured as a durable changes_captured event at commit and push time, reusing the existing three-dot diff primitive: paths from FilePatches(), counts from Stats(), base_sha recorded as the merge base actually diffed rather than the base tip, a 200-file cap with totals kept complete. Consumption goes through an unexported optional interface so workflow.Trees -- the yaegi capability surface for interpreted stage plugins -- is not widened. A capture is also taken once the pull request exists, so the capture can link it. - The per-attempt configuration is captured as a durable config_captured event carrying the non-secret config.TaskConfig, instead of a new table plus two new state-store RPCs: events are already this system's per-attempt provenance stream, so a table would have given one feature two provenance mechanisms. Redaction is proven against canary secrets. Measured payload: 539 bytes typical, 2333 bytes at 20 models. - Captures carry a schema marker and are refused unless their key set matches the declared payload shape, so drift surfaces as "recorded but could not be read" rather than as a capture of zeroes. - Three read endpoints serve the attempt rail, the changed-file captures and a raw debug view, mapping to UI-owned response types rather than dumping store types. - The task-log read gains a stage filter, bound to the stage logger for that stage's own lines; agent and tool output records no stage. A task-scoped grant may already insert events on its own task, so this provenance is exactly as trustworthy as the rest of that task's event stream. That limit is documented rather than papered over. |
||
|
|
ef0d61782b |
feat(configuration): add archied setup, the caller the first-run flow was built for
docs/architecture/configuration.md decides that "install.sh must stop generating
config.toml; archied setup owns it", and gives the reason: the installer
hand-rolling TOML already drifted from the schema once, and "the durable fix is
that the code writing the config is the code that reads it". setup.Run,
tomlwrite, configtemplate.Example and terminalprompt were all built for that and
had no production caller between them. This adds the caller.
setup.Run's own doc comment states the obligations, and they are the shape of
installValidatedConfig: render the edits, prove the result loads through a real
configuration.Loader, and only then install the file and commit the secrets. A
validation failure returns before either write, so a bad config leaves neither a
config nor a secret on disk. The rendered bytes are proven from a temp file, so
a load failure cannot have already installed anything. The config is written
0600 via same-directory temp and rename.
Parameterisation is typed, not matched against prompt text. A flag-to-prompt
mapping would have to match strings, which is the brittleness removed in
|
||
|
|
8301a949ee |
Merge pull request #827 from samcharles93/fix/webui-config-projection-chat-setup
fix(webui): count every chat front-end in the published projection |
||
|
|
b2bf33e5db |
test(archie-ui): drive the projection through the real producer in the smoke suite
The real-process suite hand-wrote the ConfigView document into the store, so it asserted on a shape it built itself and could not have caught a producer that forgot to publish a field. Both values GitHub #821 named -- chat.show_tool_calls and the setup operator name -- arrive in the extracted process through that projection and nowhere else. seedStore now renders the document with webui.BuildConfigView, the same function the daemon calls, from a config.Config, and a helper republishes between turns the way a config reload does. The suite additionally streams a turn through the fake Gateway's tool event and asserts the resulting frames twice: with show_tool_calls on the frames carry the tool, and with it off they do not. That is the browser-visible behaviour the issue described, asserted on what the UI process actually sends. Verified the new assertions are sensitive rather than vacuous: emptying ConfigView's chat section makes the "on" case fail on a missing tool frame and the checklist case fail on an empty operator, which is the original bug. |
||
|
|
87d8d39321 |
fix(webui): publish per-identity forges so multi-identity task rows keep their links
Task rows in a deployment configuring [[identities]] rendered no forge links. ConfigView carried the default identity's forge alone, so resolveForge (api_tasks.go) withheld the links entirely rather than pointing every row at the wrong forge -- production behaviour since the UI process cutover (archie-core-8cda.5.4), where the dashboard runs in a process with no config.Holder. archie-core-ml30 then removed webui.forgeConfigForTask and its test, which resolved a task's forge from config.Config and had no reachable caller once the holder was gone. Fix at the producer, not the renderer. ConfigView gains `identities`: each configured identity's forge type and host, plus the repositories it owns. That is the whole answer to "which forge owns this task", and it is a projection the daemon already rebuilds and republishes on boot and on every reload, so nothing new is needed on the publish side. Only coordinates and repository names cross -- an identity's token is a secret reference and stays out, which the new test asserts alongside the existing leak guard. resolveForge ports the matching rules recovered from 5b91a3a's forgeConfigForTask onto that projection: an exact identity name first, then repository ownership, and an ambiguous repository -- two identities claiming the same owner/name -- falling back to the default forge rather than inventing a link. Two deliberate departures from the recovered shape: it indexes the identity list once per request instead of rescanning config per task, since the projection supplies repo slices it can key on directly; and a document that reports multi-identity but carries no per-identity forges still withholds, because that is what an older daemon published and guessing there is the original bug. The recovered code's first-wins scan for a duplicated identity name is preserved. Tests: the projection's per-identity forges and their secret-freedom; the three matching rules and both fallbacks through resolveForge; every row of a multi-identity GET /api/tasks carrying the right forge's link; and the real archie-ui binary driven over HTTP against a multi-identity projection, which fails on the pre-fix resolver with three unlinked rows. |
||
|
|
c2ebcb8298 |
test(archied): stop racing state-store startup against a wall clock
TestRunStateStoreAcceptsEnvironmentToken wrapped the whole of RunStateStore --
SQLite schema init and the serve loop -- in a 200ms context deadline, so
whether it passed depended on how fast the disk was. Measured before the fix:
6 failures in 12 consecutive runs. A gate that fails half the time teaches
people to ignore it, and the failure it reported ('store: init schema:
context deadline exceeded') named a time budget, not a defect.
Cancellation is the assertion, so the test now cancels and then asserts:
the call must not return before cancellation (that would mean startup refused
the config, the thing this test exists to catch) and must return within a
generous grace once cancelled. The graces bound 'did startup reject us', not
'machine speed'. Measured after: 12 passes in 12 runs.
Also applies the canonical gofumpt and 'go fix' output to
internal/infrastructure/staterpc/dial.go, cmd/archie-ui/main_test.go and
internal/releaseupdate/check_script_test.go. task check runs gofumpt -w over
the tree, so leaving these unformatted made the gate rewrite unrelated files
mid-run and report dirty state for changes it had made itself.
|
||
|
|
03afd2e8ad |
refactor(webui): take configuration off the dashboard server
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.
|
||
|
|
9d9c79a22f |
fix(staterpc): attach the bearer token to State Store streams
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. |
||
|
|
50845430e3 |
test(ui): smoke the archie-ui process against live dependencies
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. |
||
|
|
51234eaed4 |
test(ui): enforce the UI process deletion gate on every check
The severance that cut archie-ui's package closure from 68 to 26 was a one-time measurement: nothing re-ran go list -deps, so the next import of a type sitting beside a runtime would have relinked that runtime silently and left the suite green. TestUIProcessLinksNoDaemonRuntime re-measures the closure and fails on any package in a banned category, with the categories named as the PRD names them. Its two exceptions are checked in both directions so the allowlist cannot decay into an open prefix. database/sql is matched exactly rather than as a subtree: database/sql/driver arrives from google/uuid's Valuer/Scanner and brings no driver with it. Verified by violation: one blank import of internal/store relights eleven banned packages across three categories. |
||
|
|
eafb58e1c0 |
feat(webui): deliver live dashboard events by polling the State Store cursor
archie-core-za9f. The UI process owns no event bus, so after the .5.4 cutover the activity feed would show history at page load and then go silent: live delivery is a Server.Broadcast call made only from the daemon's bus subscription. Decided against the push-subscription RPC the bead assumed, on three findings: * store.Open sets SetMaxOpenConns(1), so writes serialise and the event id is assigned in commit order. The gap-skipping failure that normally rules out polling an autoincrement cursor cannot happen here, and SSE catch-up already depends on the same property. * sseStream.drain treats a broadcast as a wakeup, not a payload: it fills the persisted gap via catchUp and delivers the event only if catch-up missed it, deduplicating on the since watermark. A poller substitutes for the bus with no change to sse.go and no new SSE semantics. * The events table is the only complete fan-out point. ArchiveTask writes an audit event inside its transaction and daemon.go inserts binding-dispatch failures directly, neither touching the bus. A push hub needs a hook at every write site and misses any added later. So: no proto change, no new auth surface, no backpressure policy. The pump primes past existing history (a client's own catch-up serves that), then ticks EventsSince into Broadcast. One pump serves every browser. A failed fetch leaves the watermark intact, so a State Store restart costs latency, not events. Wired into archieui.Run in the background so priming a large events table cannot delay the listener, with -event-poll-interval (default 1s). Decision recorded in migration-decisions.md; ui-service-boundary.md's /events route-owner row moves to RESOLVED, and /api/logs splits out of it as still unresolved and host-local. |