a7d6f71d5a2c9da170a46bfc4471f9979189de87
45
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
59cc831ff7
|
feat(tools): add per-server parallel_tool_calls to the MCP client
MCPServer gains ParallelToolCalls (default false). The client's per-server callMu is now nil for a server that opted in, so CallTool stops serializing that server's calls and the caller's own concurrency decides; every other server keeps exactly one tools/call in flight. The flag is threaded from config through the provider constructor - the only place MCPServer configs become Client instances - into NewClient, in both the daemon and the agent worker. |
||
|
|
0263bf4e0d
|
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. |
||
|
|
08df95684c
|
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. |
||
|
|
fe733b9bd1
|
refactor(archied): fold the daemon's state surfaces into one boot step
Run's added openDaemonWorkflowDefinitions guard pushed it to gocyclo 21 (.golangci.yml's budget is 20). openDaemonStateSurfaces owns the pair -- adapter, then the definitions client on its transport -- so Run keeps one branch for the whole sequence and no suppression is added. step_vocabulary_test.go's pin moves with the sequence: it still asserts adapter before client, client before buildDaemon, and now also that Run opens neither half directly, so the ordering has exactly one call site. Behaviour is unchanged; the gateway root still calls openStateStoreAdapter alone and resolves no step vocabulary. |
||
|
|
b4aa56dcb3
|
fix(archied): register the step vocabulary only where a root resolves it
Review pass on the step-vocabulary shape. The gateway root shared openStateStoreAdapter with the daemon, so it registered a step vocabulary and built a workflow-definitions client it never read: the same dead vocabulary the previous commit removed from internal/app/archiemessaging, reintroduced through the shared adapter, and able to fail the gateway's boot the day a provider set can fail to load. The vocabulary and the client now belong to the daemon root alone (openDaemonWorkflowDefinitions, called by Run before buildDaemon captures it), which is what Client's "a process that never reads or writes a workflow definition needs no provider set and cannot be failed by one" already claimed. The root guard was weaker than its own comment: it asserted that a root calls stepVocabulary(), not that the manager returned is the one handed to NewServer/NewWorkflowDefinitionsClient, so a root could call it and inject an empty manager and keep every test green. The pin now asserts the data flow (both halves mutation-checked), plus Run's ordering -- after openStateStoreAdapter, before buildDaemon. Three root guards asserted exact equality with workflow.BuiltinStepRegistry(), which contradicted the extension path they guard: adding a provider to workflowsteps.Providers() -- the documented way a step type arrives -- failed all three, and the expectation could not be satisfied by editing it. They now assert what their doc says (every shipped stage present) plus provenance (every name resolved is declared by the shared provider set), and the workflowsteps guard derives its expectation from Providers() so both sides move together. New guard on the defect class the bead exists for: TestNoProductionSiteReaches- ForTheBuiltinStepRegistry scans the module and fails if any non-test file outside the domain declaration and the shipped provider names BuiltinStepRegistry, which the agreement test cannot see for a sixth resolution site added later. Claim-vs-code corrections: openStateStoreAdapter "reads and replaces" -> the daemon only reads, and ReplaceWorkflowDefinitions has no production caller yet; workflowsteps' package/Providers docs no longer claim every Archie binary registers the set (archie-gateway, archie-messaging, archie-playbooks and archie-ui do not); the shipped-provider test no longer says production does not call BuiltinStepRegistry, which is false -- production calls it only there. |
||
|
|
9accf112c6
|
feat(controlplane): report which settings version each process is running
Every process that layers database-owned settings now publishes the version it applied, and re-stamps it every 30 seconds so the report time doubles as a liveness signal. A record older than 90 seconds belongs to a process that has stopped, which is the only way this surface can tell a live process from one that applied a version and then died. RuntimeConfig returned the merged config and discarded the versions it read, so no caller could report what it had applied. It now returns them, and archied and archie-gateway report each kind through boot.runtimeConfig at boot and on SIGHUP. A validation failure reports every kind with the error, because the layering is all-or-nothing, and leaves the recorded version alone so a rejected edit does not erase the fact that an older one is live. The daemon also reports workflow execution settings as the watch applies them, and archie-messaging reports channel settings at startup. Reporting is best-effort by construction: the configuration a report describes has already been applied, so a failed write is logged and never returned. That keeps it off the reload's error path, where it would have raised a banner saying a reload failed when its config took effect. applystatus.New refuses a process name Processes() does not list. The reader renders known names, so an invented one would be invisible rather than wrong, which is the same thing the page means by a process that never started. Relates to archie-core-pskb. |
||
|
|
31622ec5c2
|
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. |
||
|
|
924b02a1b0
|
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. |
||
|
|
f6397af7f4 |
fix: address the Greptile findings on the merged PRs (#902)
* fix: address the Greptile findings on the merged PRs Four valid review findings from PRs #892, #893, #898 and #899, which were merged without the comments being read. - Config.Clone left the new diff-cap pointers aliased (#899, mine). Clone deep-copies every reference field, including the *bool beside it, so a clone could write the cap through to the published snapshot. Both the top-level field and the identity overrides are copied, with the clone test extended to cover them. - providerOutcomeRecorder.record could report an older call as the latest (#892). The completion time is taken before the lock, so two concurrent calls can reach the lock in the opposite order to their completion and the unconditional store overwrote the newer outcome. It now keeps the newer, via a recordAt seam that makes the reordering testable. - Curator model calls bypassed the recorder (#892). curatorLLMRunner calls the runtime directly, so a daemon whose only recent model traffic was curator work reported "no calls attempted yet" while the provider was demonstrably reachable. It records at its own adapter, and sendChatTurn's "single choke point" comment is corrected to say there are two. - A provider error reached /status raw (#892), unlike channel details, so a multiline or oversized error broke the one-line-per-fact layout. Both now share one bounded formatter. Found while fixing the curator path: agentexec.NewRuntime returns nil when no provider is configured, and a nil *runtime.Runtime panics on its first method call, so a curator asking for a completion took the daemon down. It now returns an error, and records nothing -- a local misconfiguration is not a provider call. Not fixed, filed instead: the shared lastPollAt masking a stuck identity, the container max-uptime callback resurrecting teardown bookkeeping, the dashboard dropping a served-only status filter on cold load, and the route registry test's line-by-line parser. * fix(build): drop goimports from the gate's formatter set `task check` spent 136 of its 167 seconds in `task fmt`, and 134 of those 136 in one formatter: goimports alone over the tree. golangci-lint's goimports formatter calls imports.Process once per file, which builds a fresh x/tools ProcessEnv each time, so internal/imports.getFixesWithSource re-reads modindex.Read($GOMODCACHE) per file. On this machine that index is 62.7 MiB / 2,081,070 lines (an 11 GiB module cache), and modindex's in-process memo does not take effect: 3 files read 187.9 MiB back, 15 files open the payload 15 times. That is ~53 GiB of I/O and CSV parsing per run, and it is linear at ~155 ms per file (122 files -> 18.8s, 864 -> 133.8s). Pointing the index cache elsewhere drops the same command to 3.9s. The same analyzer runs under `golangci-lint run`, so a cold cache pays it again: 169s cold with goimports, 31s without -- which is what CI and archied's own PR gate see, since only `fmt` never caches locally. Removing it costs no enforcement. gofumpt and gci remain, `task lint` still reports formatter drift as an issue, and the whole-tree fmt is now 2.2s with the tree byte-identical. What is given up is goimports' convenience of adding and removing import lines, which compile errors already cover. The examples/secret-engines exclusion stays: gofumpt and gci leave those Yaegi programs alone today, but the exclusion is the stated invariant that a formatter must not rewrite the imports of files it cannot type-check, and TestFormattersExcludeInterpretedSecretEngines holds it. Its comment no longer pins the reason to the formatter that was dropped. * fix(gateway): stop /status promising and mis-reporting health it cannot see Two findings from the cloud review of #892. Title generation no longer records chat-model health. It runs detached after a first turn under its own 30s bound and its error is swallowed by the caller, but it shared the process-wide outcome recorder, so a title that merely timed out overwrote the health line with "failed" -- reporting a broken provider on the strength of a call no user was waiting for. The /status command description no longer claims "workers" and "channels". Neither can render: newStatusHealth reads the container pool and the poll loop from boot, but the only production router.Health assignment is in setupGatewayChat, which runs solely in the archie-gateway process, where neither exists; channels is nil since the Messaging Service took the front-ends. Only the broker and chat-model lines actually appear, so that is what the help text now says. The underlying split -- daemon owns the facts, Gateway owns the Router -- is filed rather than patched here: it needs either a cross-process health contract or a ratified two-section /status, not a quick wire-up. |
||
|
|
e0b6aa6105 |
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. |
||
|
|
04d4d8f1d8 |
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.
|
||
|
|
cc7c23a58c |
feat(gateway): chat memory read path (unification slice 3) (#887)
Wires the durable-memory engine into the chat turn: prepareTurn resolves a
per-channel Subject (BotUser as AgentID, TurnRunnerConfig.UserIdentity for
the user), runs a scope-only Query over Subject.Scopes(), and renders the
result into a new <memory purpose="durable_context" trust="data"> block
between <tools> and <env>, following the same untrusted-data framing as
those two blocks. The read is synchronous, total, and never surfaces an
error: a nil engine, a failing Query, or a panicking provider all degrade to
no memory block (recovered in gateway.renderMemory).
UserIdentity is supplied per channel by the composition
(userIdentityResolver in internal/app/archied): telegram and email resolve
their native SenderID, the dashboard ("web") and webhook resolve nothing, so
a webhook's route-path SenderID can never become a user identity and the
dashboard's shared bearer token can never impersonate a person.
Fixes the composition-ordering bug that left every turn runner holding a nil
memory engine: setupMemoryAll now runs before setupGateways in main.go, and
before setupGatewayChat in gateway.go's startGatewayRuntime, so
boot.memoryStore() has a live engine at every turn-runner construction site.
Named constants bound the read: memoryRecordsPerScope per scope, and
memoryBlockByteCap on the rendered block, which drops (and logs) trailing
records rather than truncating one mid-line.
|
||
|
|
7ee5025d3c |
feat(memory): four-scope contract and builtin engine CRUD (unification slice 2) (#886)
* feat(memory): four-scope contract with CRUD and revisions
Seam for memory unification slice 2 (docs/prds/memory-engine-unification.md
§1, §2, §7): internal/domain/memory is now a scope-addressed CRUD contract.
- Scope{Kind,Agent,User} with the four ratified kinds, Validate rejecting a
component present where it is not required, and a length-prefixed Key so
opaque channel-native ids cannot collide.
- Subject{AgentID,UserID} with Scopes()/WritableScopes(): global is never
writable, and an absent user id removes every scope requiring one.
- Store becomes Create/Get/Query/List/Update/Forget/Revisions over
NewRecord/RecordUpdate/Record/Revision, with ErrNotFound/ErrStaleRevision.
Observation, Identity and Metadata are deleted.
- The content scanner moves into the family (internal/domain/memory) so every
engine applies it in Create and Update; internal/memory re-exports the types
until slice 5 deletes it.
- The markdown store moves to internal/infrastructure/memory/builtin, its
correct home per organisation.md.
WIP: internal/infrastructure/memory and internal/infrastructure/sessioncurator
are converted in the lanes that follow this commit.
* feat(memory): builtin engine CRUD, retained revisions and the curator's agent-user write
Slice 2 implementation (docs/prds/memory-engine-unification.md §1, §2, §6,
§7), on top of the contract seam in the previous commit.
- internal/infrastructure/memory: per-scope markdown heads with a JSON
provenance marker, per-scope HISTORY.md retaining superseded and deleted
states, Update superseding before replacing the live block, ErrStaleRevision
via RecordUpdate.Expected, idempotent Forget, and the family scanner applied
in Create and Update. Scope directories are hex(sha256(Scope.Key())).
- internal/infrastructure/sessioncurator: the participant is derived from the
session's user-role senders; exactly one writes agent-user scope, zero or
several write nothing and return ActionSkipped naming the count.
- docs/architecture: the settled decision recorded in migration-decisions §5
(superseding the 2026-09-02 marker entry) and agent-system.md pointing at it.
Draft: to be squashed and reviewed before publication.
* test(curator): conform the registry's fake memory engine to the CRUD contract
The fake still implemented the pre-CRUD Store surface (Write taking an
Observation, List/Forget keyed by a bare string), so the package's test
binary no longer compiles: fakeMemoryEngine is missing Create, Get, Update
and Revisions, and domainmemory.Observation no longer exists. That took
`go fix ./...`, `go vet ./...` and `go test ./...` down with it, which is
what `task check` runs first.
Missed by the same commit that updated internal/infrastructure/sessioncurator's
own fake to the new interface. Repaired on the fake, not by loosening the
interface: the fake is the only thing out of date.
* fix(sessioncurator): refuse to attribute a session with unidentified user messages
sessionParticipant skipped user-role messages with an empty SenderID and
counted only the identified ones, so a session holding one identified sender
plus any number of unidentified user messages yielded that sender as the
single participant. Those messages are still part of the excerpt the
extraction model reads, so facts derived from content of unknown provenance
were written into the identified sender's agent-user scope: user A's memory
can end up crediting content that may belong to someone else. It is exactly
the case the function's own doc comment claims to handle, which it only
caught when no message at all was identified.
An unidentified user message now makes the session unattributable outright,
beside any number of identified senders, and the skip action's reason names
the count instead of reporting a sender count that no longer explains the
skip. Assistant-role messages are unaffected: they carry the bot, so they
still cannot manufacture a participant.
Fixed in sessionParticipant rather than at the write, because it is the
single producer of the attribution decision: it now returns the participant
or the reason there is none, so the caller cannot print a reason that
disagrees with what it decided. The fail-closed path (nothing written, one
ActionSkipped) and the extraction flow are unchanged.
* fix(memory): carry record content through the block format intact
builtin.Store's format ends a block at a blank line and starts a section at a
"## " line, but storeContent only trimmed the content and rejected an empty
one. Content holding either delimiter was accepted, written, and answered back
to the caller in full -- then read back truncated at the delimiter by Get,
List, or a process restart, with the remainder unaddressable and no error
anywhere along the path.
Fixed at the producer, in the render/parse pair that owns the block format:
renderBlock escapes the two delimiter shapes (an empty line becomes a single
backslash, a line already starting with a backslash or "## " gains one) and
parseBlocks undoes it on the way back, so a record's content survives the
write whole. Rejecting the content instead would have made an ordinary
multi-paragraph note or a quoted heading unrepresentable; escaping every line
would have changed the on-disk shape of every record. Only the lines that need
it are escaped, so a one-paragraph record is byte-identical to what the
unfixed engine wrote and the document stays hand-editable.
Reachable from both producers: the chat tool's note and the curator's
model-extracted fact are free text, and neither is constrained to one
paragraph.
Tests: TestBuiltinEngineRenderedBlockRoundTripsContent asserts
parseBlocks(renderBlock(c)) == c for eleven content shapes, and
TestBuiltinEngineContentSurvivesTheWriteAndAReopen carries the same shapes
through Create, Get, and a second engine reading the file a restart would.
* fix(memory): compare Update's expected revision against the file, not the cache
Update read the record to compare against out of findBlock(stores.live, ...)
-- the engine's cached copy of the scope document -- and checked Expected
against that copy. This engine caches one document per scope and rewrites it
whole, so a second engine over the same scope file (archied and the gateway,
or a restart) holds a copy taken when it last read the file: its view of the
record's revision is superseded, Expected matches the revision it remembers,
ErrStaleRevision never fires, and the rewrite that follows writes that stale
copy back over the file -- discarding the other writer's update and every
record written since the copy was loaded. The field existed and could not
fire.
Reload the scope document before anything is decided from it, so the check
answers about the revision actually on disk and the rewrite starts from the
current document. That is the smaller of the two fixes the PRD leaves open
("Not determined": a reload-before-mutate or an advisory lock); no locking
scheme, no retry loop, and no change to the read paths.
Still unsolved, and deliberately: the whole-document rewrite is
last-writer-wins between the reload and the write, so two engines writing one
scope concurrently can still lose one of the two writes, and HISTORY.md is
rewritten from the cached copy the same way.
Tests: TestBuiltinEngineSecondEngineCannotReuseAStaleRevision asserts the
second engine gets ErrStaleRevision and the first writer's state survives;
TestBuiltinEngineUpdateDoesNotEraseRecordsItHasNotLoaded asserts the record
written after the second engine loaded is still there after its update.
* fix(memory): emit the scanner's warning instead of dropping it
scanContent returned nil for every result that was not ThreatBlock, so a
ThreatWarn result -- documented in the scanner as "allow the write but emit a
warning", and what every sensitive-data match produces (API keys, passwords,
tokens, private keys) -- was stored with no audit signal anywhere. The
comment justified the silence by pointing at Bind, but Bind's argument is
about Registrar.Events: internal/events declares no memory kind and the
composition binds no memory event sink, so an invented kind would look wired
and not be. A scanner warning is a diagnostic rather than an event, and there
was nothing else to carry it: the registrar had no logger.
Bind now takes Registrar.Log, optional and mirroring the curator family's
Registrar for the same reason, scanContent emits the warn-level result
through it before the write is allowed, and bootstrap passes the daemon's
logger so the line reaches archied's configured sinks instead of only the
process default. The write is still allowed: only the silence changed.
Tests: TestBuiltinEngineScanWarnsWithoutRefusingTheWrite runs Create and
Update over warn, clean and block content, asserting the write lands either
way, that a warn-level scan result logs exactly one warning carrying the
scanner's own message, that clean content logs none, and that a refused
block-level match logs none.
* test(memory): carry every content shape through Update and Revisions
Update replaces the block it read out of the document by that text, and
retains the superseded state in HISTORY.md, so an escaped block has to be
found, superseded and retained exactly like an unescaped one. Covered here
rather than left to the Create path: without the escaping, every shape in
this table came back truncated after an update, including the plain
one-paragraph record whose replacement holds a blank line.
The test asserts values only: the updated record as a second engine reads it
off disk, and the superseded content as Revisions returns it.
* style(memory): apply the linter's gofumpt form to the Update revision error
golangci-lint's bundled gofumpt wants the closing paren of that wrapped
fmt.Errorf on its own line; the standalone gofumpt binary the fmt task uses
(0.7.0, a different version) leaves it as it was. The text is unchanged from
before the engine fixes in this branch, so this is pre-existing drift inside a
function these commits already touch -- taken so the file is clean under both
formatters rather than only one.
|
||
|
|
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. |
||
|
|
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. |
||
|
|
6ecde5cc24
|
feat(archied): wire the scheduling ticker engine at boot
schedulingConfig translated [scheduling] config into a domain EngineConfig but nothing ever called it in production: the whole scheduling/cron family (ticker engine, cronstore, crondelivery) was built and tested but reachable from no binary, so an operator setting scheduling.interval etc got a silently inert section. setupScheduling opens a cronstore.Store as the engine's JobSource, builds a crondelivery.Router with a workflow-kind runner backed by the same non-forge gateway.TaskCreator chat's /spawn already uses, and constructs the scheduling.Engine from schedulingConfig. startServices starts it alongside every other subsystem; Stop is registered via addCleanup on the same Background-timeout pattern as the curator runtime. No chat task creator configured leaves the engine unstarted rather than running with no reachable job kind -- the "chat" delivery kind stays unmapped for the same reason (no unified cross-channel outbound sender exists at this composition root yet). |
||
|
|
17689e4911
|
fix(archied): stop advertising review_pr when no reviewer can run
review_pr was registered on every channel and failed on every call with "worktree manager is not configured". Two independent causes, one contract: The daemon ran setupGateways before buildTreesAndIdentities, so setupGateways reached prReviewer() while b.trees was still nil and captured it; the memoised reviewer then held that nil for the process lifetime. Build the worktree manager before the gateways, which is the ordering the reviewer depends on. Ordering alone cannot fix the standalone Gateway, which calls prReviewer() and never builds trees at all. Have prReviewer() return nil when b.trees is nil, so a reviewer that can never run is not produced. That is what gateway.ReviewTools' existing nil-reviewer guard always intended -- "a tool that cannot run must not be advertised" -- but the guard never fired because the daemon never passed nil. TestPrReviewerIsMemoized asserted a trees-less boot yields a non-nil cached reviewer, encoding the broken precondition as expected behaviour, which is why a green suite hid this since review_pr shipped. It now gives the boot a real worktree manager so its actual subject -- one shared in-flight set across channels -- stays pinned, and two tests are added: one for the nil-trees invariant, and one that composes the real wiring (prReviewer -> ReviewTools) and asserts review_pr is registered only when the reviewer can run. Found by an adversarial package sweep (temp tracker: app-archied-5, .local/issue-tracker/). |
||
|
|
19062a702d |
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.
|
||
|
|
da28ddb5e6 |
refactor(ui): sever the archie-ui binary from every daemon runtime package
Completes the objective deletion gate for the UI Service (archie-core-8cda.5.6): go list -deps ./cmd/archie-ui now links zero banned packages -- no modernc.org/sqlite, no internal/store, gateway, channels, memory, secret, agentexec, tools, skill, yaegiutil, curator, or the workflow engine. The closure shrinks from 68 to 26 archie-core packages. Each cut is a producer-side move; no consumer-side defensive shims. - Store contracts (TaskStore family, value types, sentinels) moved from internal/store to internal/domain/storecontract -- the approved contract location per state-store-contract rev. 2d, and NOT internal/contracts: that tree is buf generate output and tools/proto.sh check deletes hand-written files there. internal/store keeps aliases; sentinel message strings are byte-identical and remain the wire contract. - Chat contracts (ChatContract, sessions, turns, streaming, commands) moved from internal/gateway to internal/domain/messaging; gateway keeps aliases. ToolCallEvent rendering helpers become gateway functions (methods cannot live on alias types). - Task vocabulary (Task, statuses, mid-run Store, Definition) split into internal/domain/workflow/task; the pipeline engine stays in package workflow with aliases, so daemon-side callers are unchanged. - overlay.DeniedKeys moved to internal/infrastructure/configuration: webui referenced the constant and that dragged the overlay SQLite store in. - webui.Server's concrete runtime handles become webui-owned view interfaces with daemon-side bootstrap adapters: channel lifecycle (internal/channels/status), MemoryStatus, CuratorStatus, and a SkillCatalog seam replacing the direct skill.DefaultRoots/CatalogRoots calls. Each degrades to an empty page when unwired. - config.SecretRef moved into internal/config (config vocabulary); internal/secret keeps an alias and Registry.Resolve absorbs the zero-value short-circuit. Docs: state-store-contract rev. 2d relocation record; ui-service-boundary deletion gate marked satisfied; ARCHITECTURE.md package map rows. |
||
|
|
3699f51f9b |
refactor(store): move the producer-owned contracts to internal/contracts/store/v1
The deletion gate for the UI Service (archie-core-8cda.5.6) is objective: go list -deps from cmd/archie-ui must show no SQL/store implementation. internal/store's hand-written contract surfaces (TaskStore and its component interfaces, CaptureStore, MappingStore, BindingStore, BindingDispatcher, BindingTaskCreator, ConfigSnapshotStore) move to internal/contracts/store/v1 (package storev1), alongside the value types they carry (CapturedEvent, ConfigSnapshot, WorkflowStat, StageStat, DayTokens) and the sentinel errors -- whose canonical message strings are the wire contract and are byte-identical after the move. internal/store keeps type aliases, so daemon-side callers (archied, the daemon, staterpc's server side, taskactions) are unaffected. The UI-facing packages switch to storev1 directly: webui, archieui, captureintake, gatewayrpc, and staterpc's client/values -- which drops internal/store and modernc.org/sqlite from the archie-ui binary's import closure. overlay.DeniedKeys moves to internal/infrastructure/configuration for the same reason: webui referenced the constant and that dragged the overlay package's SQLite store in. The chat-contract and remaining runtime-handle decoupling continues under the same bead. |
||
|
|
27bc40332f |
refactor(archied): cut the dashboard over to the archie-ui process
PRD gate 7 (docs/prds/ui-service-boundary.md): the daemon's in-process webui.Run listener is deleted in the same change that wires the UI process, so no fallback or second HTTP authority remains. The daemon's webui.Server stays only as the configuration snapshot's renderer (archie-core-ymut): it keeps the config Holder, provenance, reload status and the override list, and drops the store surfaces, event broadcast, chat/task wiring that only fed the listener. The bus drain becomes persistence-only -- the store is the single fan-out point the UI process reads through its event pump. The dashboard's configuration write path (PATCH /api/config, per-row reset, per-repo field update) is deleted rather than left as dead policy: the writes are descoped for the UI process (archie-core-ymut) and no route reaches them. Editing is config.toml plus reload; the overlay store stays for reload wiring. |
||
|
|
29b074ef77 |
refactor(archied): move the update relay to the process that owns updates
The dashboard's Run read the watchdog's phase-2 report off local disk and put it on the activity stream. That is a host-local file read in the process that is moving off the host: the watchdog restarts archied and leaves its verdict beside archied, so archied is what can read it. The daemon now polls and relays it, publishing the same event through the same bus, so it persists with every other event and reaches whichever dashboard is watching. The event builder moves to releaseupdate, which owns Report and its verification; the dashboard keeps only what it needs to tell an installer where to write. The startup poll stays: the watchdog writes its result only once the process answers /healthz, so a single read at boot can always miss the report describing that very boot. persistAndBroadcastEvents takes the daemon context and detaches it for the insert, which is what it always did with context.Background() -- the last events of a run are the ones an operator reads afterwards. |
||
|
|
6f34e34adb |
feat(webui): render configuration from a published snapshot
The configuration page had exactly one source: this process's own config.Holder. The UI process has no holder and is not permitted one, so the page was empty there and the shared-holder assumption was the thing blocking the cutover. GET /api/config now reads a ConfigViewSource. The daemon builds the projection from the configuration it owns, as before, and publishes that same document to the State Store on boot and on every republish -- reload, a dashboard edit, a repository field change -- since those are exactly the moments it changes. The UI process renders what it reads there and nothing else; an unknown schema is refused rather than half-rendered, and nothing published yet is the documented empty response, not an error. Editable is a property of the process, not of the configuration, so each source sets it: the daemon holds the update path, the reader does not. The settings page honours it, rendering values where it would otherwise offer controls whose PATCH would answer 503 -- the deliberate feature reduction archie-core-ymut recorded, made visible instead of discovered by clicking. A failed publish is logged and degrades to a stale page. It must never fail the reload or the edit that produced the configuration, both of which have already taken effect. |
||
|
|
1ffdedc62e |
feat(archied): serve the daemon's own health endpoint
The update watchdog verifies archied's restart, so archied has to be what answers. It was probing the dashboard's /healthz, which belongs to the dashboard: switch [web] off and nothing answers, and in the extracted UI topology that endpoint reports a different process entirely, which would confirm a release while the daemon it was meant to verify is down. [health].listen (127.0.0.1:8485, defaulted, always on) serves /healthz, /health and /health/detailed for the life of the process. Liveness answers 503 until the daemon reaches its run loop: the listener binds before the subsystems do, so an unconditional 200 would tell the watchdog a half-booted release came up. Failing to bind is fatal, because a daemon nothing can probe gets every update rolled back. The State Store's readiness surface now shares the listener plumbing, keeping its log and error text verbatim. Closes archie-core-exbz, which asked which of two bad options to take when the dashboard is off. Neither: the daemon owns its own liveness. Also deletes TestInstallUpdateDetachesInstallerFromCallbackContext. It has failed intermittently under load more than once, racing its fake bot server's multipart parse against the cancellation it induces. |
||
|
|
47d78afae7 |
feat(gateway): give the dashboard operator its own task-action contract
archie-core-8cda.5.4 requires /api/tasks/{id}/action to go through
ChatContract rather than a task-action service the UI process composes
itself. The contract could not carry the request: ApplyTaskAction's identity
is a scope, and the daemon's action service distinguishes a named identity
from a nil one, which is the authenticated operator acting across
identities. Sending "" would not have expressed it either -- that is a real
identity in a single-identity deployment (chatTaskProfiles).
ApplyOperatorTaskAction is that case, additively: a separate RPC, so buf
sees no cardinality change on a shipped field, and no request that can carry
both an identity and operator authority. ChatTaskActor's identity becomes a
pointer end to end, from the Gateway's local adapter through the NATS hop to
taskactions.Service.Apply, which has always taken one.
The conformance test now covers both scopes through the local adapter and
the gRPC hop; the chat tool test pins that a chat action is never unscoped.
No caller passes nil yet -- the dashboard handler switches over with the
rest of the cutover.
|
||
|
|
8fef2e7eed |
fix(state-store): task-scope container credentials, stream large capture lists, validate Update, wire dev's state-store (archie-core-8cda.4.7)
Closes six review findings against .4.6 (PR #775): - daemon.StateStoreGrantIssuer + staterpc.TaskGrants: containers get a per-task credential authorized only for their own Update/Transition/ InsertEvent, never the daemon's administrative token. Issued before Acquire, revoked on Release; fails closed if no issuer is wired. - StreamCaptures/StreamUndispatchedCaptures: new streaming RPCs so a batch of large capture bodies can't exceed gRPC's 4MiB unary cap. The original unary RPCs are kept, unmodified (deprecated) rather than reshaped, so buf breaking stays green for an in-flight rolling deploy. - Update rejects a nil Task with InvalidArgument instead of panicking in the store layer. - RequireHostGateway only forces on for embedded NATS, so an externally reachable NATS/State Store no longer requires a local Docker bridge. - Client-side token resolution now matches the server's (target_token, then STATE_STORE_TOKEN secret/env). - task dev now runs archie-state-store (dev:state-store) alongside archied/archie-gateway/vite; deployments/dev.toml points them at it. |
||
|
|
3a0dfa924d |
refactor(state-store): cut daemon/Gateway over to the remote State Store (archie-core-8cda.4.6) (#774)
* refactor(state-store): delete NATS storerpc; agent store is gRPC-only (archie-core-8cda.4.6) The agent is fully on the gRPC State Store contract, so the legacy NATS storerpc path is dead (docs/prds/state-store-contract.md §12 step 4): - delete internal/storerpc (Server, Client, subjects) and its tests - drop the storerpc registration from registerTaskRPCServers and the now-unused store param - make the agent transport's State Store URL required and Store() return only the gRPC staterpc.Client (no NATS fallback) - rework agentworker/agent transport tests to back the store with a real gRPC State Store server instead of the deleted NATS storerpc server The agent binary now fails fast when STATE_STORE_URL is absent. Agent store calls (workflow.Store) go over gRPC to the archie-state-store service. * refactor(state-store): delete daemon/gateway in-process store ownership (archie-core-8cda.4.6) The daemon and gateway no longer open archie.db in-process: the single SQLite file is owned by the standalone archie-state-store process, and both consumers dial its gRPC State StateStore contract (docs/prds/state-store-contract.md §12 step 7, no dual-store ownership). - openStores no longer opens the production task store or seeds b.st; it only wires secrets/forge and the gateway conversation store - openStateStoreAdapter now requires [services.state].target (the old local default is deleted) and resolves b.stateStore as the remote *staterpc.Client - delete the in-process startStateStoreServer (the multiplexed gRPC server and its per-task bearer-token registry) from the daemon composition - RunGateway now resolves the same remote State Store adapter; its session SQLite stays Gateway-owned and untouched - daemon.ConnectedStateStore carries the configured target plus the resolved bearer token, which containerEnv injects as STATE_STORE_URL / STATE_STORE_TOKEN so archie-agent authenticates to the same remote service - readiness store probe reads b.stateStore PRD-consistent choice (noted): with the in-process server gone, per-task token generation is removed; the daemon/gateway/agent all present the single [services.state].target_token (or STATE_STORE_TOKEN secret) that the standalone store validates. * docs(webui): require [services.state].target in config and deployment templates (archie-core-8cda.4.6) After the in-process store path is deleted, archied and archie-gateway dial the standalone archie-state-store gRPC service via [services.state].target and never open archie.db themselves (docs/prds/state-store-contract.md §12 step 7). - config.example.toml documents [services.state].target as required, with the loopback vs Docker-bridge gateway + target_token rule - deployment templates set [services.state] per topology: bridge gateway + token for container-mode agents, loopback for host-only - deployments/README.md and systemd-user-service.md describe start commands for both topologies and drop the stale "not yet consumed by the daemon" note * style: gofumpt alignment for State Store daemon literal; appease noctx/staticcheck (archie-core-8cda.4.6) * docs(state-store): refresh stale in-process references post-cutover (archie-core-8cda.4.6) |
||
|
|
48033ccbf8 |
refactor(state-store): migrate workflow/intake/task lifecycle consumers to State Store (archie-core-8cda.4.5) (#773)
Route the daemon's task-lifecycle / work-intake / workflow consumers (the TaskStore composite) through b.stateStore instead of reaching into b.st directly, the same additive composition pattern .4.4 used for the capture/mapping/binding contracts (docs/prds/state-store-contract.md §10/§12 step 6). b.stateStore is the in-process *store.Store by default and a remote *staterpc.Client dialed to the standalone archie-state-store gRPC service when [services.state].target is set, so this is behaviour-neutral until an operator flips the seam. Consumers migrated: daemon.Daemon.Store, webui.Server.Store, the message gateway routers, the chat task lister/log-reader adapters, the operator task action service, event persistence (persistAndBroadcastEvents), the manual requeue path, and the chat task creator/controller. openStores now seeds b.stateStore = b.st so it is never nil in either the daemon (Run) or the gateway (RunGateway) composition; the gateway never calls openStateStoreAdapter, so it stays on the local adapter and never dials a remote store (preserving the .4.4 fail-closed intent). The in-process State Store gRPC server keeps fronting b.st (the agent's gRPC and NATS storerpc handoff paths both stay on the daemon's local store) and the in-process serving path is untouched (deletion is .4.6). Adds focused composition-regression tests asserting the daemon, webui and task-actions consumers resolve their store from b.stateStore, plus the existing bufconn conformance suite (grpc adapter) already proves contract fidelity for the TaskStore surface. |
||
|
|
c644a70d5b |
refactor(state-store): migrate capture/mapping/binding consumers to State Store (archie-core-8cda.4.4) (#772)
* feat(state-store): add daemon composition path for remote store adapter ($services.state) Add the additive composition path the daemon's own capture consumers use (archie-core-8cda.4.4, docs/prds/state-store-contract.md §10/§12 step 6). bootstrap.go opens production store then resolves b.stateStore: the local *store.Store by default, or a remote *staterpc.Client dialed to the standalone archie-state-store gRPC service when [services.state].target is set. Wire the dashboard CaptureStore surface from b.stateStore. The in-process StateStore gRPC server keeps serving the daemon's SAME local store (stateStoreDeps from b.st), not the consumer-facing b.d.* adapters: task lifecycle (b.st) stays in-process until .4.5/.4.6 and there is no dual-store ownership. Fail-closed on a non-loopback target without a bearer token mirrors the standalone server's confinement (§9). * feat(state-store): route daemon mapping consumers through the state store adapter Migrate the MappingStore consumer to the State Store contract adapter (archie-core-8cda.4.4 step 6, Mapping swap): the dashboard's mapping editor (web.Mappings) and the daemon's dispatch loop (d.Mappings) resolve from b.stateStore instead of reaching into b.st directly. Local by default, remote *staterpc.Client when [services.state].target is set. * feat(state-store): route daemon binding consumers through the state store adapter Migrate the BindingStore/BindingDispatcher/BindingTaskCreator consumers to the State Store contract adapter (archie-core-8cda.4.4 step 6, Binding swap): the dashboard's binding editor (web.Bindings / web.BindingDispatcher) and the daemon's dispatch loop (d.Bindings / d.BindingDispatcher / d.BindingTaskCreator) resolve from b.stateStore instead of b.st. Local by default, remote *staterpc.Client when [services.state].target is set. * refactor(state-store): resolve daemon state store adapter only in daemon composition openStores is shared with the standalone archie-gateway (RunGateway), which does not consume the capture/mapping/binding surfaces. Resolve b.stateStore from the daemon's own Run() composition instead, so a gateway config that happens to carry [services.state].target can never dial (or fail closed against) a state store it does not use. openStateStoreAdapter takes no ctx: grpc.NewClient connects lazily, and the adapter resolution is synchronous. |
||
|
|
2b102b04a2 |
feat(state-store): generalize storerpc as the State Store gRPC contract (archie-core-8cda.4.2) (#770)
* feat(state-store): generalize storerpc as the State Store gRPC contract Implements archie-core-8cda.4.2 against docs/prds/state-store-contract.md rev. 2c: generate protobuf/gRPC client and server adapters for every ratified store contract (proto/state/v1/state.proto, 40 RPCs, one StateStoreService), add internal/infrastructure/staterpc with a bufconn conformance suite exercising both local and remote adapters, serve the service in-process (bridge address + mandatory per-task bearer token when agent containers exist, loopback-only otherwise), and flip archie-agent's workflow.Store to a long-lived gRPC client when the daemon injects STATE_STORE_URL/STATE_STORE_TOKEN (falling back to the legacy NATS storerpc path otherwise -- one agent process is never both). Also drops the *sql.Tx parameter from store.BindingDispatcher.RecordDispatch (a required wire-blocker fix: a transaction cannot cross a gRPC boundary, and production always passed nil). fix(store): drop RecordDispatch's unusable *sql.Tx parameter feat(config): add services.state contract-adapter selector * fix(state-store): apply no-mistakes review decisions - Drop StreamTokenInterceptor (unused; the State Store service has no streaming RPCs and nothing calls it). - Make StateStoreTokens.Validate compare tokens in constant time (crypto/subtle) per the auto-fix hardening.ing finding. - Amend config.example.toml / config.Services.State doc text so it frames [services.state].target as the ratified surface consumed by the upcoming standalone archie-state-store binary (.4.3), not active today. |
||
|
|
5e94cef784 |
refactor(workflow): relocate Task/Status/Source and define workflow.Store (#754)
* refactor(workflow,store): relocate Task/Status/Source and define workflow.Store Move store.Task, store.Status*/store.Source*, and the 3-method workflow store interface out of internal/store into internal/domain/workflow as workflow.Task/workflow.Status/workflow.Source plus a consumer-owned workflow.Store, superseding store.WorkflowStore. internal/domain/workflow now imports zero internal/store symbols; internal/store persists the domain type instead (infrastructure depends on domain), and its Store satisfies workflow.Store. Updates every production and test caller of the relocated symbols across daemon, webui, gateway, agentworker, agenttransport/nats, storerpc, taskrun, and worktreerpc, and removes TestRecordDispatchViaExplicitTx per docs/prds/state-store-contract.md (rev. 2c) sections 4 and 12 step 2. Two workflow-package integration tests that exercise the real *store.Store move to an external workflow_test package (store_integration_test.go) to avoid a workflow(test)->store->workflow(prod) import cycle now that store depends on workflow. * no-mistakes(document): docs(state-store): mark §4.8 relocation done in state-store-contract |
||
|
|
bec9caa24e |
feat(gateway): delete in-process ChatContract path, make remote the only mode
archie-gateway is now the sole owner of ChatContract; the daemon always dials it over gRPC for webui chat, no in-process fallback left. Telegram and email keep their own in-process routers unchanged (their streaming responder is a callback that can't cross the wire-safe contract). - composeChatContract only accepts mode="remote"; config defaults Services.Gateway to remote + 127.0.0.1:8585 when unset - deleted taskActionsActor (dead code once the local branch is gone) - task dev now launches archie-gateway alongside archied + Vite Verified end-to-end: archie-gateway + archied booted against a shared NATS/store, webui's /api/chat/sessions round-tripped through the gRPC hop. |
||
|
|
10e76e7528 |
feat(gateway): consolidate task actions and repair daemon default path
Phase 1 (extract the Gateway Service), first stage. Repairs the half-migrated working tree so the default (inproc) daemon path works again while keeping the WIP's direction: - chatTaskActorAdapter is contract-only (no HTTP detour); nil contract returns ErrChatCapabilityUnavailable instead of panicking. - openStores opens the conversation store for both processes again; the standalone gateway no longer owns it exclusively. Phase 1 keeps the daemon's Telegram/email routers and session-memory curator reading the same SQLite file; remote conversations arrive when a process that cannot open the file needs them. - setupLLMAndChat composes the local gateway (setupGatewayChat) in default mode and a remote gRPC client in mode=remote; the returned contract is never nil, and Run handles the error. - taskactions.Service is now the single task-mutation implementation shared by the dashboard (webui TaskActionService), the daemon's local gateway actor, and the NATS responder. The daemon registers taskactions.Register so the standalone Gateway's client can forward actions; transport follows the repo's natsrpc pattern. - uncommitted sessions.proto / SessionStoreService gRPC contract deferred: it has no wired consumers (scope creep for this stage). - task_action_adapter_test.go rewritten against the contract chain. task check passes; archied and archie-gateway both build. |
||
|
|
79375f33e9 | feat(gateway): extract ChatContract service | ||
|
|
afba5800b2 |
feat(gateway): wire progressive tool disclosure (bridge tools)
Compose the base registry with per-turn extras into a turn-local registry and let ContextPressureGate decide full-vs-bridge disclosure per chat turn. The three bridge tools (tool_search, tool_describe, tool_call) are now wired into the chat toolset and only disclosed under context pressure, keeping the LLM's schema footprint small while preserving full arsenal access on demand. Per-turn extras are identity-bound per channel and cannot live in the process-wide registry (agentexec.BuildToolSetFrom invariant), so the bridge is composed turn-locally rather than registered globally. Thread the model's context window through TurnModel.Prepare (TurnPrepareContext) so the gate activates with a real window. Refs #167 |
||
|
|
e39467b83e |
feat(drain): honour external drain marker with instantiation epoch (#718)
Implement drain control via an external marker file. The daemon polls
$XDG_CONFIG_HOME/archie/.drain_request.json (the repo's config-home
convention) for a drain request, validates it against the current
instantiation epoch (kernel boot id + PID 1 start time) and, only when
the marker is live, cancels the boot context to trigger the same
graceful shutdown an operator SIGTERM does.
A marker written against a prior instantiation (reboot or PID 1/container
restart) is stale and ignored, so a leftover request never drains a
daemon that came up after it was written. An unreadable marker or epoch
fails closed to no drain. The daemon never invents a new shutdown path.
domain/drain owns the pure decision (Epoch, Marker, Decide);
infrastructure/drain reads the marker file and /proc boot facts;
app/archied wires a poller that cancels the root context on a valid
request.
Path note: the epic named ~/.archie/.drain_request.json, but archied
resolves every per-user path under ${XDG_CONFIG_HOME:-~/.config}/archie
(see AGENTS.md 'Config path'), so the marker lives there too rather than
at a path this daemon never uses.
Refs bead archie-core-1786637496817-266-06b64a72 (drain control: marker
file and instantiation epoch), part of the operations epic
archie-core-1786637496703-262-1e49aef1.
Tests: table-driven Decide (epoch mismatch -> stale, matching -> valid,
nil -> none, unreadable -> stale), marker round-trip from operator JSON,
and monitor (valid -> shutdown, stale/none/error -> no shutdown).
|
||
|
|
ff740689cd |
feat(archied): add shutdown watchdog that force-exits a hung graceful shutdown (#716)
Once graceful shutdown begins (SIGINT/SIGTERM cancels the daemon's signal context), start an out-of-loop watchdog timer for the drain window plus a 60s grace period. If the shutdown chain has not completed by the time that leash expires, force-exit the process (os.Exit) as a backstop against a hung shutdown. The watchdog runs in its own goroutine outside the daemon's event loop and graceful-shutdown machinery, so it fires even when that machinery is itself the thing that is stuck. It is disarmed via the FIRST registered cleanup so it runs LAST in the LIFO shutdown chain: it stands down only after every subsystem has shut down cleanly, and a hung subsystem never reaches the disarm, letting the watchdog force-exit. A shutdown that completes within the leash does not trigger the watchdog; a shutdown that hangs past the leash results in a forced process exit. The leash uses a test-only short timeout in tests. Reference bead archie-core-1786637496842-267-8b2984f9. |
||
|
|
e077b13640 | fix(archied): preserve ephemeral gateway ports (#707) | ||
|
|
b698322505 |
fix(gateway): split /status (health) and /tasks (work) apart
/status conflated two unrelated concerns: a thin per-status task count that duplicated information belonging to a task view, and runtime config already visible via /model. Worse, a bare status count actively misled -- "Running: 1" read the same whether that task was making progress or stuck in a failure loop, because a count carries no age or identity. /status now reports one aggregate queue-depth line (in-flight work: running/waiting/parked, health signal only) instead of an itemized breakdown -- queued and terminal states are excluded as neither actionable nor a health concern. /tasks is new: the live, per-task view with enough identity and state to act on it (id, title, status, workflow/stage, age since last transition, attempt once a retry has happened, and a parked task's reason). Age comes from Task.UpdatedAt, already persisted and now threaded through ChatTaskSummary and chatTaskListerAdapter -- no new instrumentation needed. Tasks sort actionable-first (running, waiting, parked, ...) ahead of terminal states, stable within a status group so the lister's own recency order survives. Wired via the existing configureTaskCommands call sites (web, telegram, email, webhook) using the same chatTaskListerAdapter already built for the task_list LLM tool -- no parallel data path. Note: internal/gateway's separate /agents command (AgentReader) is NOT touched here and remains dead in production (Router.Agents is never wired by any composition-root call site) -- tracked as its own finding, not folded into this fix. |
||
|
|
7ee6ee5554 |
feat(store): encrypt playbook binding secrets at rest
binding.Binding.Secret was persisted as plaintext in the bindings.secret column, so anyone with the SQLite file saw sender-side HMAC secrets. Seal it with AES-256-GCM transparently inside the store: encrypt-on-write, decrypt-on-read. - cipher: AES-256-GCM, 12-byte random nonce, SHA-256-normalised 32-byte key resolved through the secret registry ([bindings].encryption_key). - envelope 'arcie-binding:v1:<fingerprint>:<b64(nonce||ct||tag)>' so a future cipher/KDF change is a version bump and old rows stay readable. - rotation via previous_encryption_keys; key identity is the material's SHA-256 fingerprint embedded in each row. - legacy plaintext rows written before a key was configured stay readable; encryption is not retroactive. - nil cipher (no key configured) preserves the pre-t2db.7 plaintext path. Deferred: captured_events.body redaction upgrade (separate concern, see docs/prds/binding-secret-encryption.md). Refs archie-core-t2db.7 |
||
|
|
96184a0e27 | fix: resolve golangci-lint funlen, nilerr, and empty branch issues | ||
|
|
a4fbd8d6ef |
feat(webui): inline editing for per-repo allow_concurrent/max_retries/review_enabled
Adds PATCH /api/config/repos/{owner}/{name}, a dedicated seam distinct
from the generic dotted-key PATCH /api/config path: a repository is
one element of []config.Repo, not a flat key. Traced the mechanism
before adding any new plumbing -- overlay.Nest/ApplyOverlayValues
already handle "repos" as a single whole-slice key with no dot, so
the fix is a webui handler plus a bootstrap seam that reads the
daemon's live, untrimmed Repos (never webui.RepoView, which omits
Preflight/TestGlob), mutates the one matched field via the pure
applyRepoFieldUpdate helper, and republishes through the existing
UpdateConfig(ctx, {"repos": repos}) path unchanged.
config-row.js's row() gains an opts.save override so an edit can be
redirected to a different persistence call. The repositories table
renders an autosaving checkbox for the two booleans and a
save-on-blur/Enter input for max_retries, via api.configRepoUpdate.
Closes archie-core-b6ew.6, and with it archie-core-b6ew.
|
||
|
|
c4871569ce |
feat(curator): session-memory curator reference implementation
Closes archie-core-1786637499114 (persistent session-memory curator), the last open item in the curator engine epic. docs/prds/session-memory-curator.md records the decisions this needed before coding, most notably: Observation.Identity is the session ID, not a user or cross-session identity. migration-decisions.md#5's memory-scope mapping (global/agent-wide/user-wide/agent-user relationship) is still explicitly open, and this issue has no business deciding it unilaterally -- session-as-identity is the narrowest unambiguous scope available today and is forward-compatible with a later, properly-decided identity resolution. curator gains ConversationSource (RecentSessions/Messages), gated in Registry.validateDeclared/filter exactly like Skills/MemoryEngines, plus Manifest.Conversations. internal/infrastructure/sessioncurator/adapter.go adapts gateway.SessionStore's full CRUD/branch/search surface down to those two read-only methods -- curator must not import gateway.Message, so role derivation (message.From == botUser -> assistant) is copied from gateway.compressTurnHistory's existing logic, not shared. sessioncurator.go: Check is a cheap RecentSessions bool. Pass takes each session's last 40 messages, asks the model for a JSON array of durable facts (capped at 5/session), and writes each through Registrar.MemoryEngines.Get(name) -- resolved by name at call time, the same trust model every other curator capability already uses. A response that fails to parse degrades to "nothing extracted" for that session (not a Pass error); a real model-call failure propagates as one (these were originally conflated into the same swallowed-error path -- caught by TestPassPropagatesALLMFailure, fixed by splitting the model call from the parse step). PassInput.Since zero resolves to a 24h lookback, not the beginning of time, so a cold-start first pass can't read a session's entire history. Manifest.OnInput = true wakes it via the existing WakeOnPrimaryInput wiring (events.KindTurnCompleted), which already excludes every curator-derived event kind from the forwarded set -- the trigger- accounting invariant (archie-core-1786637489768) needed no new code to hold here. Wired into bootstrap.go:setupCurators via a new curatorLLMRunner adapter (main.go) over the shared ai-sdk runtime, and sessioncurator.NewAdapter over b.chatSessionStore/b.cfg.BotUser. Model resolves from b.chatModels.ActiveModel() -- not b.defaultChatIdentity, which names a task-routing identity, not a model reference (the same source telegram_setup.go's sendChatTurn already uses for a real chat turn). task check is green (full Go suite + dashboard tests). |
||
|
|
538b29aa0f |
feat(daemon): wire the domain/memory engine registry at boot
Completes archie-core-1786637499480 (ship the file-writing store as the default memory engine): cfg.Memory.Engine now actually selects and starts an engine, closing the gap the previous commit's message called out as remaining. setupMemoryEngine builds a domain/memory.Registry, registers infraMemory.BuiltinEngine for "builtin" (and the empty/unconfigured case, matching applyMemoryDefaults' resolution) rooted at workDir/memory-engine -- separate from the legacy provider's workDir/memory, so the two can never collide on the same files while both exist -- starts the registry, and stops it on daemon shutdown. cfg.Memory.Engine is already validated against the same set at config load (configuration.validateMemory), so the switch's default case only guards the two lists drifting apart, not live operator input. setupMemory and setupMemoryEngine are both called through a new setupMemoryAll from Run(), which was already at its cyclomatic complexity budget -- a genuine grouping (both are memory-subsystem startup), not two unrelated steps merged just to hit a number. setupMemoryEngine deliberately does not thread Run()'s ctx through to registry.Start, matching setupMemory's own existing choice for the same reason (Start is a synchronous startup step, not a subscription that needs the daemon's lifetime the way setupCurators' WakeOnPrimaryInput does) -- also what avoids a contextcheck trip that threading ctx through setupMemoryAll produced during development. Not yet done: internal/memory.Manager (the live system-prompt/tool-call path) does not read through this registry -- the two memory systems run in parallel, per archie-core-1786637490069-11-e245c170's explicit "do not extend the legacy system in place" scoping. That convergence is future work, not part of this issue. |
||
|
|
5fa010c9c2 |
fix(plugin): add missing CLAUDE.md reference to plugin engine rule
Test TestPluginEngineRuleIsCanonicalAndSharedByAgentInstructions was missing entirely, letting CLAUDE.md drift out of sync with ARCHITECTURE.md#plugin-engine-rule-strict. Added the test and the missing reference. |