4ffebb855d625d8ff2e06db4eb2cd7ef0586fa66
10
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e3ee044c5e
|
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. |
||
|
|
8e4e353805
|
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. |
||
|
|
a7d6f71d5a
|
feat(identity): verify provider tokens and attribute task actions to their actor
Two halves of one boundary: a credential resolves to an identity, and an action records which identity acted and whose authority it used. resource server. internal/infrastructure/oidc verifies a provider-issued bearer token against the provider's published keys, using an OSS OIDC library: archie compares no signature, validates no claim and rotates no key itself, holds no client secret and issues no session, so a compromised archie cannot mint an identity. Audience is required rather than optional -- a token minted for another service must not authenticate here -- and discovery happens at construction, so an unreachable provider is a startup failure rather than a request-time surprise. identity.Authenticate is the single place a credential becomes an identity, and it refuses in four distinguishable ways: no credential presented, a credential that did not verify (wrong key, expired, wrong issuer, wrong audience, malformed), a verified subject with no identity bound to it, and an identity that may not act. The order is deliberate: verification happens before any field of the token is used, so nothing an unverified token carries can select an identity. A suspended identity is refused even though its credential verified, because suspension is archie's decision and must not depend on the provider withdrawing a token. The binding is the second bridge beside the legacy-name alias: identity_subjects keys (issuer, subject) so the same subject string from another issuer is a different caller, and rebinding moves a subject so two identities can never claim one provider subject. The contract Authenticate needs is SubjectResolver, narrower than Repository, so a consumer that only authenticates does not take the whole identity CRUD surface -- and staterpc.Client, which asserts Repository, does not need a new RPC to satisfy it. attribution. taskactions now records two identities per action: the acting identity and the authorising principal, both on the event row as new columns added through the existing migration table. The rule that the bug turned on is enforced by the event kind describing the actor: a person's approval is human_approved, an agent's is agent_approved, and an action with no verified actor is task_approved, a task-level event that credits nobody. An agent acting under a person's standing approval records itself as the actor and that person as the principal, so "approved by came from me" is answerable from the record rather than asserted. Scope and actor are separated: scope decides which task a caller may touch and is never promoted into an actor, because the dashboard's credential is a shared token and possession of it is not evidence that a person was at the keyboard. That last point is a deliberate fidelity trade, and the reason the transport is not wired: the dashboard action path passes no actor yet, so dashboard approvals are now recorded as task_approved rather than claimed as a human's. Recording nothing false is the requirement; naming the human verifiably needs the dashboard to authenticate a token and resolve it, which needs two new state-store RPCs (ResolveIdentitySubject, BindIdentitySubject) -- the next piece, not a rewrite: the verifier is a one-method interface, so introspection would be a second implementation of it. Verified: task check exit 0; focused runs recorded in the handoff. Opaque authelia_at_ tokens were inspected rather than assumed and cannot be verified against public keys; infra is configuring access_token_signed_response_alg RS256 on the archie client, with audience https://archie.catlow.cloud and issuer https://auth.catlow.cloud. |
||
|
|
2ef962912a
|
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. |
||
|
|
fb945fec41
|
fix(taskactions): resolve max_retries from the task's owning identity
WIRE, not delete: per-repo max_retries is a configured field with a real consumer (the retry gate), and it works for the legacy single-identity [[repos]] list. In a multi-identity deployment repositories live under [[identities.repos]] and there is no global [[repos]] at all, so the resolver never saw the override and a parked task was killed at the global cap rather than the configured one. MaxRetries now consults the identity named on the task before the legacy list, then falls back to the global cap. Identity name is the only thing that says which repository list owns a persisted row. Red-then-green: TestMaxRetriesResolvesFromTheOwningIdentity gained the multi-identity cases; "identity repo override wins over the global cap" failed with `MaxRetries = 3, want 7`. Two neighbouring cases keep the fix honest: another identity's override must not leak, and the legacy path must still resolve. Mutation-verified by deleting only the identity lookup, keeping the extracted helper and the API intact. |
||
|
|
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. |
||
|
|
d0b5be1491 |
feat(webui): route dashboard task actions through the Gateway contract
The dashboard composed its own taskactions.Service over whatever handles happened to be set on webui.Server. In the extracted UI process those are all nil, and each nil silently removes a guarantee: no Cfg means max_retries stops being enforced, no Issues means a rejected task's forge issue stays open and the poller re-enqueues it, no Events means operator actions never reach the timeline, no TaskStopper means Stop cannot interrupt running work. The handler now asks whoever owns task execution, through ApplyOperatorTaskAction, and Issues/TaskStopper leave the dashboard entirely. That path crosses two hops that both flatten errors, so the sentinels the handler maps to 404/409/503 travel explicitly: a kind beside the message on the NATS envelope, a gRPC code on the Gateway contract, each restored on arrival. Without them a task that simply moved on reports as a broken daemon. The action tests keep running the real service, now behind a local contract the way the daemon serves it in production, so retry limits, forge closure, events, archiving and log removal stay covered where they were. |
||
|
|
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.
|
||
|
|
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. |