Domain fields ParkClass/RemediationRounds landed in fe2a8e6d; this is
the wire and daemon half. Task gains park_class (32) and
remediation_rounds (33) and maps both directions; the classified park
write crosses the wire as ParkTask on a narrow TaskParker contract
(TaskLifecycle stays under the 8-method cap), with conformance
coverage local + grpc including the stale-guard sentinel and
needs_human normalization. Every daemon park site now states its
class: terminal for a repo that left config and a retired identity,
transient for the environmental parks (worktree, storage, grants,
taskrun), and identityMayAct returns the class beside its reason.
fe2a8e6d added Task.ParkClass and Task.RemediationRounds to the domain
without the wire half; the parity guard went red. Add the two proto
fields (32/33) and map both directions in values.go.
Sequencing steps 6 and 7 of pr-review-remediation.md: the consumer
landed in 33e915c5, and these are the two sources that feed it.
Webhook (decision 2, low latency): the GitHub receiver decodes
pull_request_review and pull_request_review_comment events behind the
existing HMAC verification and publishes the same typed reaction the
poller produces, keyed source-independently so PublishUnique collapses
the two sources. Only submitted/created carry a verdict to remediate;
edited and dismissed are acknowledged. Reaction deliveries are
rate-limited per source (decision 6's 'add when the receiver gains a
second event family'), and the reaction path carries no dispatch
predicate -- eligibility is the consumer's owned-PR lookup.
Poll (both forges, the no-webhook backstop): one shared scan over all
pr_open tasks, each with the forge client its own identity owns
(reconcilePRs's shape), listing reviews and comments since per-task
persisted high-water marks and skipping the owning identity's bot user
(decision 5's own-comment exclusion, which the poll is positioned to
make identity-correct).
The cursors are two, not one: review IDs and comment IDs are independent
forge sequences, and a combined high-water mark would silently skip
reviews once a larger comment ID landed. watch_comment_id -- dead since
the comment-watch design it was created for never shipped -- carries the
comment cursor; review_cursor is a new presence-gated migrator column,
and SetReviewCursors is its guarded RPC (pr_open only, so cursors never
move under a run that owns the task). forge.ReviewComment gains ReviewID
so a comment is collectable into its review's unit (decision 5) on both
forges, and forge.Review gains Body so poll-delivered reviews carry
their summary.
Note: the store/proto/facade half of this work landed early in aac31b69
under a release session's message -- a shared-checkout collision, kept
rather than rewritten; that commit carries the review_cursor migration
and the SetReviewCursors contract, this one carries the producers.
Beads sync to a Dolt remote, so anything written into one is published.
Two beads filed earlier today named an operator host, its internal
address and its filesystem paths -- the tracker was treated as a private
store, which it is not.
The rule is stated where the tracker is described, next to the existing
one about .beads/ never reaching a commit, because it is the same class:
the tracker is not a private store. Host-specific facts belong in the
operator's memos instance, which a bead may point at.
The remediate workflow was registered but had no trigger: the reaction
stream was provisioned, the envelope, resolver and owned-PR lookup all
landed, yet nothing consumed the stream (pr-review-remediation.md's
sequencing left the consumer for this step). The daemon now drains the
reaction stream each cycle, before the task drain, so a reaction can be
claimed in the same pass that carried it.
Per decision 3, the store's owned-PR lookup is the authorization
boundary: an unmatched, merged or closed PR drops with a counter, and a
public reaction can never start an agent against a foreign repository.
Per decision 5, a review is the unit of remediation -- its comment
events are appended to the unit while it is queued and dropped once the
run is claimed (the round cap bounds the exchange); a standalone comment
is its own unit of one; approved reviews never remediate; and archie's
own comments, matched on the owning identity's bot user, are excluded so
its replies cannot retrigger it.
The guarded BeginRemediation/UpdateReviewPayload store methods are the
dedup: the pr_open -> queued transition carries the review unit in the
same write, so re-delivered reactions fail the status guard instead of
starting a second round. Both are new StateStoreService RPCs following
the Requeue shape, covered by the local/grpc conformance battery.
task check's fmt pass rewrites both, so the committed tree was not
fmt-canonical. Adopted verbatim, per the repository's rule that formatting
changes from the configured formatter are law.
Lane D. The collection existed in the event-capture schema with nothing
writing it; tool calls reached only the on-disk task log, readable as text
and never queryable.
The projection is a decorator on the State Store's task store, wired in
stateStoreDeps. InsertEvent persists the event first and only then, for a
tool_call event, writes one row. A projection failure is counted and logged
but never returned: event persistence is load-bearing, the transcript is
observability, and failing a task write because its shadow failed trades
the fact for the record of it. With no event-capture store the task store
passes through unwrapped.
The event adapts to the existing collection rather than the collection to
the event; args and duration_ms stay reserved. InsertToolCall stays silent
on the notify hook, matching the dispatch tables rather than the
operator-editable ones -- tool calls are high-frequency telemetry, not
dashboard activity.
The tool_calls collection existed in the event-capture schema but nothing
wrote it. Give it its write path:
- edastore gains InsertToolCall and the minimal TaskToolCalls read, writing
only the existing collection. No new index: the collection is an
append-only transcript and the SQLite predecessor had no unique index.
- internal/app/archied composes toolCallProjectingTaskStore, a decorator on
the task store that persists the event first, then -- only for tool_call
events -- writes one row. A projection failure is counted and logged but
never returned from InsertEvent: event persistence is load-bearing,
tool_calls is observability.
- stateStoreDeps wires the decorator around deps.Tasks when both stores are
open, and passes Tasks through untouched otherwise.
The event adapts to the existing schema, not the other way round: the tool
name comes from data, a succeeded call's detail is the row's result, a
failed call's detail its error; args and duration_ms stay reserved for a
producer that reports them.
Implements docs/prds/artifact-sender.md (Approved). archie-core now sends
generated artifacts to the offloaded.dev collaborative editor, whose
POST /api/artifacts route, bearer service token, PocketBase-backed
versions and idempotency semantics are the receiving contract.
- [artifacts] config section: base_url + token SecretRef with a
token_env fallback naming WORKSPACE_INGEST_TOKEN. An empty base_url
disables the sender entirely; a base_url with an unresolvable token
disables it with a warning, because a missing credential disables a
capability rather than stopping the daemon.
- internal/infrastructure/artifactsync: one-method Publish seam in the
Courier posture, full source per publish (versions of record are
snapshots), 503 retried three times with backoff, 401/400 surfaced
immediately with the field reason, deterministic request ids
(artifact:pr-review:<owner>/<repo>#<n>).
- ReviewReport gains a pure markdown renderer in internal/domain/workflow:
summary, one subsection per finding with the failure scenario and
disposition when present, verified properties as a checked-clean list.
- The daemon's PR reviewer publishes after a completed review when the
sender is configured, records the editor deep link on the result, and
degrades a failed publish to a log line -- publishing never fails the
producing work.
The cursor change renamed the field to 'cursor' as well as widening its
type, which buf breaking flags as FIELD_SAME_NAME and FIELD_SAME_JSON_NAME
on top of the type change. The name buys nothing: the field is already
documented as an opaque cursor, and the number and name are the wire
identity. Adopt the gate's verdict and change only the type, keeping the
break confined to the one rule already recorded in proto/buf.yaml.
Lane A. EventsSince no longer relies on events.id being monotonic: it
orders by (at, id), where at is written in a fixed-width layout so
lexicographic order is chronological order, and id is only a
deterministic tie-break. The cursor crosses the wire as an opaque string
and rides the SSE id: field, so EventSource's own Last-Event-ID resume
keeps working untouched. A malformed or legacy cursor degrades to
"from the beginning" rather than failing the feed.
events.id keeps its int64 type and row-identity meaning; no
push/subscribe RPC is added.
EventsSince no longer depends on events.id being monotonic. The feed now
pages a total order over (at, id): at is a fixed-width, lexicographically
sortable UTC timestamp (storecontract.EventCursorLayout) and id is only a
deterministic tie-break for rows sharing one timestamp. The cursor is an
opaque string on the wire (EventsSinceRequest.cursor), carried verbatim as
the SSE id: field and echoed back via Last-Event-ID, so EventSource resume
needs no client change.
A new idempotent migration normalises pre-existing RFC3339Nano at values to
the fixed-width layout before finishTaskMigration, and idx_events_at backs
the new query. Legacy integer and garbage cursors degrade to "from the
beginning", preserving the old failed-ParseInt-yields-0 behaviour.
Amends the "Dashboard live event delivery" decision's cursor-cannot-skip
justification, which previously rested on commit-order id assignment.
Each successful write on the State Store's PocketBase bindings/mappings
tables emits one event (binding_changed / mapping_changed) through a
nil-safe Notify func injected at composition, so a dashboard edit is
visible without a manual refresh -- the same task-DB event path capture
arrival uses. Nil notifier keeps every existing constructor silent.
The event-capture tables (captures, mappings, bindings, binding_dispatches,
playbook_dispatches) now live in PocketBase-owned collections and their ids
are opaque record ids rather than autoincrement integers. The task lifecycle
stays on SQLite: tasks/transitions/events carry FIFO claim ordering, id-cursor
pagination and the task-grant map, none of which gain anything from being
hand-editable. binding_dispatches.task_id is the single seam and stays an
integer addressing that store.
BREAKING: CapturedEvent.Id, Mapping.Id, Binding.Id and Binding.MappingId are
strings on the wire, as are the ids in the capture/mapping/binding requests.
RecordDispatchRequest.task_id is deliberately unchanged.
What the collections buy, beyond storage: a payload nobody has modelled yet is
inspectable, a mapping is editable at runtime, and a binding's relation to its
mapping is enforced. The old schema declared no FOREIGN KEY on that link, so a
dangling mapping_id was previously possible and is now refused.
Behaviour preserved deliberately, each recovered from the SQLite version
rather than reimplemented from memory:
- draft -> pending_approval -> armed, with approval only from
pending_approval and an edit always returning a binding for re-approval
- one binding per source, guarded on insert, update and approve
- an empty secret on update keeps the stored one, so an edit form that does
not echo it back cannot silently disarm a binding
- ErrMappingNotFound / ErrBindingNotFound on a missing delete target
- sentinels are re-exported from storecontract, never redefined: staterpc
matches on exact canonical message to rehydrate them, so a second
definition would break errors.Is across the wire invisibly
Two implementation notes worth keeping:
- at-most-once dispatch is now a unique index rather than INSERT OR IGNORE.
Only the unique-violation maps to ErrAlreadyDispatched; any other save
error is returned, because treating them all as "already recorded" would
turn the ledger into a silent at-least-once dispatcher.
- captures store received_at themselves at nanosecond precision in a
fixed-width layout. PocketBase autodates are millisecond and record ids
are random, so same-millisecond captures would otherwise order
arbitrarily; the old store got insertion order free from autoincrement.
- ListUndispatchedCaptures is raw SQL: the anti-join is a subquery and
PocketBase's filter DSL is not SQL. A read fires no hooks either way.
Adds tool_calls, which had no persistence at all: tool calls only ever reached
the on-disk task log, readable as text but never queryable or watchable.
Nothing writes it yet.
The binding secret cipher moves with the bindings it protects.
The schedules feature no longer runs on it: jobs live in the state store
as the schedules control-plane document, read and written through the
control-plane client (scheduleResourceStore), and the legacy jobs.json
migration into that document has run its course. What remained of
internal/infrastructure/cronstore was 1,600 lines of file store, OS-level
cross-process locking and schema-versioned JSON envelope -- plus the
schedule vocabulary held hostage inside it.
The vocabulary moves to internal/domain/scheduling, which is where
migration-decisions already said a schedules vocabulary belongs: a domain
vocabulary package must not import infrastructure. JobSpec, Target,
Payload, the kind constants, Schedule and Duration move unchanged -- same
wire shape, same JSON tags -- with the two sentinel errors callers
matched outside the package (ErrJobNotFound, ErrScheduleUnsupported) and
ErrInvalidSpec, which the schedule arithmetic itself raises. The store's
own sentinels die with the store.
The legacy migration path (migrateLegacySchedules, readLegacyJobs) goes
with it: its only dependency was cronstore.Open, and its work is done.
crondelivery keeps its consumer-owned contracts; the compile-time
assertions that pinned *cronstore.Store move to the production
implementation, scheduleResourceStore, in internal/app/archied. The
package's fixtures swap the real file store for an in-memory one with
the same Get/MarkRun/Due semantics, so the run-recording acceptance test
still asserts against real schedule arithmetic.
A future storage backend (PocketBase) implements the same vocabulary.
First slice of the persistence migration, taking the event-capture tables
rather than the task lifecycle. These five tables hold no production rows and
their feature (archie-core-t2db) is unfinished, so they migrate at zero data
risk and the remaining work lands natively instead of being written against
hand-rolled SQL and ported later. They are also the tables that actually want
what PocketBase gives: inspecting a payload nobody has modelled yet, mapping
fields against it, and editing a binding at runtime are the epic's acceptance
criteria, not incidental conveniences.
The task lifecycle deliberately stays on SQLite. tasks/transitions/events
carry FIFO claim ordering, id-cursor pagination and the task-grant map, none
of which gain anything from being hand-editable. binding_dispatches.task_id
is the single seam and stays a plain integer addressing that store.
Idempotency moves from INSERT OR IGNORE on a composite primary key to unique
indexes, so the at-most-once ledgers are enforced by the schema rather than by
each caller remembering the pattern. A save that fails for any other reason is
returned rather than swallowed: treating every error as "already recorded"
would turn a broken ledger into a silent at-least-once dispatcher.
Adds tool_calls, which had no persistence at all. Tool calls were only written
to the on-disk task log (internal/logging), readable as text but never
queryable, filterable or watchable.
Both collection lookups treated any error as "not present". For the users
collection that returned nil on a real failure (caught by nilerr); for the
views it was worse but unflagged, because creating a fresh view collection on
the strength of a transient lookup error is a schema change made for the wrong
reason. Only sql.ErrNoRows now means absent.
PocketBase creates a "users" auth collection on first bootstrap whose
createRule is open, so an unauthenticated caller could POST a record and write
a row into the State Store's database file. This surface authenticates
superusers only and has no notion of end users, so the collection is deleted
rather than given a tighter rule: one that is absent cannot be loosened again
by a later PocketBase default.
Also re-applies the modernc pin. It was applied while developing the previous
commit but a concurrent go.mod resolution reverted it before that commit was
taken, so the tree has been running 1.59.0/1.77.1 against a PocketBase built
and tested on 1.57.0/1.74.4, printing the mismatch warning on every start.
Note for future dependency work: go get -u will undo this pin, and
modernc.org/libc does not follow semver, which is why PocketBase checks.
The claim in the previous commit message that the pin landed there is wrong.
Serve an optional PocketBase surface over archie.db from the process that
already owns it, behind archie-state-store -admin-addr. It co-tenants on
<db_path>-tasks.sqlite via PocketBase's DBConnect hook rather than opening a
database of its own, so the single-owner ownership claim covers it and
PRAGMA user_version stays archie's.
Every archie table is exposed as a view collection, which is read-only by
construction. Views alone do not hold that line: PocketBase also ships
POST /api/sql, which executes write statements as well as reads, and
/api/backups, which would put a second snapshot and restore semantics beside
store.Backup's VACUUM INTO. Both routes are refused rather than left behind a
superuser check, because a superuser writing task state is still a second
writer. The gRPC contract remains the only writer.
apis.NewRouter binds the JSON API but not the dashboard (apis.Serve mounts the
embedded UI itself), so /_/ is mounted here and the caller keeps the listener.
The dependency pin and the Taskfile/README changes for this landed with the
preceding commit, which swept up the staged files.
The index built google/codesearch over the chat workspace on every daemon
start, for the process lifetime, through a child-process helper and a
SQLite metadata DB -- and grep consulted it only for searches confined to
the workspace root, which the analysed sessions showed was a small
fraction of searches. The compute was continuous; the benefit was not.
Removes internal/indexing, the workspace-codesearch helper subcommand,
the [indexing] config section, and the GrepIndex accelerator seam from
the grep tool, which returns to its direct walk. google/codesearch
leaves go.mod with it.
The live path recorded actor_id, actor_kind and principal_id as empty while the
actor was named inside the event's detail text. The daemon records the event and the
State Store holds it, and the contract between them did not carry the three fields,
so the columns were empty by the time anything could query them. An audit query
reading actor_id found nothing and "who approved this" meant parsing a
human-readable string -- the transient, unqueryable attribution this work exists to
replace.
The in-process test passed throughout because it used the local store and never
crossed that hop. The new test runs the same insert through the local adapter AND a
bufconn-backed gRPC client and asserts the columns on both, so the two paths cannot
disagree again.
Verified: task check exit 0 on this tree; the new test passes in both modes. The
grpc mode is reasoned to have failed before this change -- the field did not exist on
the contract, so it could not be set or read -- but that is inference from the
mechanism, not a run I performed against the old code.
Phase 1 of dynamic curator definitions (archie-core-trnd.1):
- ToolBuilder implementation resolves declared tool names from the
daemon's process-wide tool registry, returning exactly the declared
set and failing closed on an unknown name.
- curatorLLMRunner now carries ChatRequest.Tools and MaxSteps into
core.GenerateOptions and widens ChatResult with the executed tool
calls so a pass can attribute its actions.
- One generic DefinitionEngine interprets a Definition (Manifest +
name/enabled/instructions): its pass composes instructions with the
built declared tool set, runs the model loop, and records an action
per tool invocation.
- [[curators]] config definitions carry the Manifest shape verbatim plus
name/enabled/instructions; a definition missing interval is refused,
never defaulted.
- Idle curators are observable: the runtime logs a debug line when Check
reports not-due.
The last gap in the identity boundary: enabling a provider used to lock browsers
out, because nothing could turn a sign-in into the credential the dashboard already
verifies. Now a browser completes the authorization code flow with PKCE and the
identity reaching the request context is the person who signed in.
The audience is requested AT THE AUTHORIZATION ENDPOINT, not only at the token
endpoint. Infra measured that a provider asked otherwise returns the audience empty,
and this dashboard then refuses a perfectly valid token -- a failure that reads as a
signing fault and is actually a missing query parameter. A test asserts the
parameter is present, so it cannot quietly go missing.
The flow is the libraries': discovery, the code exchange, PKCE generation and the
challenge transformation are go-oidc and x/oauth2, so archie writes no protocol. The
token returned by the exchange is verified through the SAME Verifier a presented
token goes through, and the identity is then resolved through the same rule -- one
Resolve now shared by Authenticate and the callback, so a browser sign-in cannot be
accepted on terms a presented token would be refused on.
Archie still issues no session. The callback stores the PROVIDER's token in an
HttpOnly cookie and every later request re-verifies it, so what archie holds cannot
outlive the provider's own decision. The callback checks the state it issued, and
expires the state and PKCE verifier cookies on use.
The sign-in routes mount on the bypass mux because they are how a caller becomes
authenticated; gating them behind the credential they obtain would make signing in
impossible. The client secret is never a flag: -oidc-client-secret-env names the
environment variable holding it, so it cannot reach a process listing or a log line.
No client id means no sign-in route and token verification is unaffected, which is
what an agent-only deployment wants.
Evidence, produced by driv·ng the flow rather than the seam:
internal/webui/api_tasks_actor_test.go's TestBrowserSignInRecordsTheSignedInPerson
walks sign-in -> callback -> cookie -> action and asserts the recorded actor is the
signed-in person with human_approved. TestCallbackRefusesAMismatchedState asserts a
replayed state is refused before any credential is verified.
internal/infrastructure/oidc/flow_test.go runs the real flow against a test
provider's own authorize and token endpoints, asserting the audience parameter, the
PKCE challenge, a successful exchange, and a refused wrong verifier.
Verified: task check exit 0 on this tree.
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.
The verifier was a library nothing called. A request now carries a credential or
is refused: webui.Server.Authenticate resolves a presented bearer token to the
identity that may act, and requireIdentity attaches it to the request context.
With a provider configured that check replaces the shared token, so every request
resolves to a named identity or is refused; with none, the shared-token gate stays
for a loopback instance.
Nothing about the caller is read from the request. The subject comes from the
credential the provider signed and the identity is the record that subject is bound
to, which is what makes attribution possible at all: a caller cannot assert who it
is, it can only present what the provider gave it. A test sends an
X-Archie-Identity header and an actor field in the body alongside a valid token and
asserts the resolved identity is still the credential's.
Refusals follow HTTP's own distinction: absent or unverifiable credentials are 401
and name the scheme, while a credential that verified for an identity that may not
act is 403. Each is covered, because a refusal path with no test is a path nobody
has watched refuse.
The two state-store RPCs the dashboard needs to resolve a subject exist:
ResolveIdentitySubject and BindIdentitySubject, with the client implementing
identity.SubjectBinding (a narrower contract than Repository, so the administrative
facade keeps its shape) and the server answering Unavailable rather than pretending
when a process has no binding store.
chat.proto carries the actor for the next step: actor_id, actor_kind and
principal_id on ApplyOperatorTaskActionRequest, regenerated here. The transport can
now carry an attribution and nothing fills it yet, which is why the dashboard still
records task_approved rather than a human attribution.
Not wired in production yet, and worth stating plainly: dep.Authenticate is a seam
nothing sets, because the dashboard is served only by the UI process and that
process is documented to take endpoint references only -- there is deliberately no
config.Config in it. OIDC settings must therefore arrive as flags there, which is an
existing design boundary I did not want to cross unilaterally. config.Oidc exists
so the daemon-side wiring has somewhere to read from.
Verified: task check exit 0 after this commit; focused webui run records the
resolution and all four refusals.
Infra decoded real tokens from both clients, and two of the three facts changed
this code.
A machine token carries NO sub at all: it names its caller by client_id, and the
identity is that client. A person's token carries sub, the provider's stable
identifier for the person. The subject is now derived explicitly -- sub when
present, else client_id -- and a verified token asserting neither is refused
rather than accepted as an anonymous caller, because accepting it would let any
token the provider ever signed act as whoever the binding happened to hold. A
machine identity is therefore per client registration, one identity per client,
which is what makes per-agent identity a configuration decision rather than a code
change.
Scopes are read from either claim shape. The standard is a space-delimited scope
string and this provider also emits an scp array; reading only one shape yields no
scopes at all, which is worse than reading none deliberately.
The audience-at-authorisation-endpoint trap is pinned by a test: a token minted
without the requested audience arrives with aud empty, and the audience check
refuses it. That refusal is correct and the fix is the request the human flow
builds, not a weaker check here -- a test now fails if anyone weakens it.
The PRD records both as constraints: a person's client and an agent's client are
registered separately because a shared registration collapses the distinction the
attribution rests on, and a person's token requests the audience at the
authorisation endpoint as well as the token endpoint.
Verified: task check exit 0; internal/infrastructure/oidc passes, including
subject derivation for both token shapes and every refusal.
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.
archie-core-8cda.6.8's carrier. The service now records channel lifecycle and has
nowhere to put it: /api/channels answered with nothing because
webui.Server.Channels had no production source, and reload answered 501 for the
same reason. This adds the surface the register decided on, following the split
archie-core-ymut established for config snapshots -- a pair of administrative RPCs
whose writer is one process and whose reader is the UI -- and wires both ends.
Wire and store: PutChannelStatus / ListChannelStatus, with ChannelStatus carrying
id, name, state, detail, configured, reload_supported and observed_at. The store
holds one row per channel and replaces the reported set, so a channel the reporter
no longer mentions is deleted rather than left standing as a stale "running"; an
empty report clears the table, because hosting no channels is a fact worth
reporting. A row without an id is refused: it could never be replaced or removed
by a later report.
Writer: the service publishes on every lifecycle transition through a coalescing
signal -- a burst of transitions is one write, since a reader only wants the latest
state of every channel -- plus a start-up report and a final report after shutdown,
so a stopped service leaves the store honest. A failed write is logged and retried
on the next signal; the dashboard losing channel state is worth a warning and never
worth failing a channel start over.
Reader: webui.Server.Channels becomes a source rather than a concrete manager, and
webui.RemoteChannelStatus reads the store the way RemoteConfigView reads the config
snapshot. A store it cannot reach reports nothing rather than a stale "running",
and a state the reader does not recognise is carried through rather than dropped.
The contract's own index gains the group in the same change that adds the RPCs --
a surface the grouped table does not list is one nobody finds -- and the count moves
to 51. The register records why the surface is the State Store rather than a
resource kind, and why reload gets its own surface rather than a field here: reading
status must not be able to retrigger an action, a transient request is not
distinguishable from state once anything polls it, and it would invert the
writer/reader relationship the precedent establishes.
Verified: task check exit 0. New coverage: the store's replace-the-set semantics
and its refusal of an id-less row, the reader's mapping including an unknown state,
and the publisher's start-up, transition and final reports.
The PRD's deletion gate for the Messaging Service could not pass: go list -deps
./cmd/archie-messaging linked modernc.org/sqlite, internal/store,
internal/domain/workflow and internal/agentexec -- all through one import,
archiemessaging/run.go -> internal/app/controlplane, from which the service used
three symbols. The decision was to sever rather than amend the gate, because a
boundary you whitelist around is no longer a boundary (archie-core-1ng1, recorded
in docs/architecture/migration-decisions.md).
Measured before touching anything: internal/app/controlplane was the ONLY direct
import of the service that dragged those runtimes -- every other one was clean --
so severing this one dependency is sufficient for the gate.
Moved into the new internal/infrastructure/controlplanerpc: the generic resource
client (NewRPCClient, Query), the RuntimeChatConfig projection, the reader
interface (now the exported ResourceReader), the wire sentinels, the status
mapping (now ClientError), and the channel-settings document with its decode --
ChannelSettings, TelegramSettings, WebhookChannelSettings, EmailSettings,
RateLimitSettings, ChannelDuration, DecodeRenamingLegacyKeys.
internal/app/controlplane keeps the store-backed server, the Definition registry,
every kind's seed/validator/Normalize, the schema derivation, and its
resource-specific reads and watches. Its Client embeds the new one, so the read
path has one implementation while the workflow, persona and cronstore reads stay
with the processes that already link those engines. The documents are type-aliased
back into this package so the store-backed side reads them by the names it has
always used: one definition, not a copy on each side of the boundary.
The gate is now enforced by cmd/archie-messaging/architecture_test.go, measuring
the linked binary against the PRD's banned list, with one exception checked in
both directions: internal/domain/workflow/task, the Task status and view
vocabulary whose own dependency set holds none of the banned runtimes. The UI gate
carries the same entry for the same reason, and the fleet skill names it as the
precedent.
Verified: task check exit 0. The gate was red-proofed twice -- banning
internal/channels fails it, and removing the workflow/task exception fails it --
so neither the loop nor the exception is decorative.
Add the playbook_dispatches at-most-once ledger (docs/prds/eda-playbook-engine.md
gap 2) and the record-then-invoke coordinator helper, with the cross-process
plumbing the State Store boundary requires.
- proto: RecordPlaybookDispatch and DeletePlaybookDispatches RPCs (string keys)
- storecontract: PlaybookDispatcher interface (no *sql.Tx, reuses ErrAlreadyDispatched)
- store: playbook_dispatches table + INSERT OR IGNORE dedup + delete-by-playbook
- staterpc: client/server methods and Deps field; error sentinel survives the hop
- eda/playbook: InvokeOnce record-before-invoke helper, keyed on
(playbook, version, event, action) with a "1" action-position fallback
The ledger is administrative-only: task-scoped grants never reach it, matching
TaskGrants' Update/Transition/InsertEvent allowlist. Not wired into the daemon
workflow pin; the production call site arrives with the first side-effecting
position.
One Router serves every channel and named itself "web", so Source.Platform -- the
FIRST component of the session natural key, and the platform GetByChannel filters
on -- was a constant, true of no channel but the dashboard. Two consequences
followed: the per-user identity policy was real code that no production call site
reached with a real channel name, and a curator pass's write to agent-user memory
could not be read back by the turn that wrote it, because that turn resolved no
UserID.
The channel now travels with the message. Frontends name the channel they carry
(pb.Message.platform: telegram, email, webhook, web), and the Gateway stamps the
session from it, falling back to its own name when a sender names none -- which is
what every existing row holds and what a frontend that does not participate keeps
doing.
Identity resolution reads the platform off the inbound rather than closing over a
channel name, so carriesPersonIdentity finally decides something in production:
telegram and email resolve a person, the dashboard and a webhook resolve nothing,
and an unknown platform fails closed.
Deliberately NOT changed, because it is where this could quietly widen scope:
TurnRunnerConfig.Channel still keys tool availability, so no channel gains or
loses a tool here. Only session lookup and identity follow the message's platform.
Consequence the maintainer accepted: a chat whose active session came from /new or
/branch re-resolves once, since GetByChannel now filters on the channel's name. A
chat with no /new re-resolves onto the same deterministic session id and heals
silently.
Verified: gateway, archied, gatewayrpc, messaging, webui, channels and cmd suites,
go vet ./..., go build ./..., golangci-lint run ./... (0 issues), docs:check.
New contracts: TestResolveSessionKeyStampsTheMessagesPlatform, the per-platform
identity table, and the transport-context wire round trip.
The schedules document stored interval as a bare time.Duration, so its JSON was
the nanosecond count -- 1800000000000 for thirty minutes -- and the Web UI, which
now derives field metadata from the document type, correctly rendered a number
input. Same defect 02rm fixed for rate_limit.window, in the second stored time
this tree has. Nobody should be asked for a count of nanoseconds to configure a
schedule.
cronstore.Duration writes the string time.ParseDuration reads and reads that, a
nanosecond count, and nothing else: every schedule stored before this shape
existed carries a count, in both the control plane's schedules resource and this
package's own jobs table, which persists the spec as JSON. A value that parses as
neither is refused rather than decoding as zero, because a zero interval is a job
that never fires.
The derived schema needed no change and gets it for free -- which exposed a fix
the derivation itself needed: it classified durations by NAME, so cronstore.Duration
derived as an integer. durationLike now asks the type instead -- does it expose the
standard duration, and does it marshal as a quoted string -- so the next duration
type is classified correctly rather than silently rendering as a number box. That
failure mode was invisible until a live daemon showed it.
normalizeSchedules already re-marshals, so a stored document converges on its next
write while reads keep tolerating the count.
Verified: cronstore, crondelivery, controlplane, scheduling, webui and archied
suites, go vet ./..., go build ./..., golangci-lint run ./... (0 issues),
docs:check. Against a live daemon (8484): the catalog serves schedule.interval as
{type: string, format: duration}.
Five files named a specific host's service and the port it holds as the
reason a deployment might move the state store's listen address, including
config.example.toml, which ships to every operator. The guidance keeps its
point -- move the listen/target pair together when a port is already taken
on the host -- without naming a service the reader may not run, or have
heard of.
Also corrects the Taskfile's dev-stack summary, which still described the
state store as binding 127.0.0.1:9090. deployments/dev.toml pairs it with
9091, and has since the pair became configurable, so the comment described
a stack that does not start.
IdentityConfig.Forge is the same type as the root [forge] block, so
[identities.forge].intake, .webhook_secret and .webhook_addr all decode --
but every intake read is of the root block (validate.go,
bootstrap.setupForgeWebhook) and per-identity intake never reached
validateForgeIntake. The setting parsed, was ignored, and was not even
validated. Separately, root intake = "webhook"/"both" with [[identities]]
started the daemon, logged "forge webhook disabled" and polled instead.
Extend validateForgeIntake to fail closed on both shapes: a per-identity
webhook/both intake (or webhook_secret/webhook_addr) is rejected naming the
identity, the setting and the reason, and root webhook/both intake alongside
[[identities]] is rejected naming both settings and the supported
alternative. Poll and empty stay valid per identity; the two shipped forge
profiles still validate.
A webhook set SenderID to its configured route path. The turn path reads that
field through a per-channel resolver which refuses webhook, but the session
curator derives its participant from the raw field with no channel filter, so a
webhook session with exactly one distinct sender and one extracted fact wrote
agent-user memory addressed to User: "/hooks/...". Nothing reads it, and every
pass added more, because the facts are identical strings with no dedup.
docs/prds/memory-engine-unification.md criterion 7 requires that a route path
never become a user identity.
Clear it at the producer rather than teaching every consumer which channels are
lying: a route path is a source, not a person, so it no longer enters SenderID.
It still keys the inbound rate limit, where it is the documented per-source
budget for webhooks (config.RateLimitConfig), so it travels in the new
transport-only Inbound.BudgetKey -- carried on the wire beside Page, never
persisted, and never read as an identity.
pb.Message gains budget_key (field 9) for the same reason page (field 7) exists:
transport context that rides with an inbound message and is deliberately absent
from storedProto's rendering of a canonical record.
The curator needs no change. An empty SenderID already fails closed as an
unidentified user message, which is the path a dashboard session takes, and
sessionParticipant's existing skip covers it; the test name now says so.
The keepalive agreement was guarded only by the 50s stream case, whose control
tears down 41s in: a revert of the server policy cost the whole window to
detect. stateStoreServerOpts's options are now checked in microseconds -- a
loopback listener installs exactly one option, the enforcement policy, and that
policy is 5s with PermitWithoutStream false, strictly below the dialer's ping
interval and at least a factor of two under it.
staterpc exports ServerKeepalivePolicy and ClientKeepaliveParams so both halves
of the agreement are read from the package that owns them rather than restated
in the test: changing either side alone (the floor, or the dialer's interval)
fails it. ServerKeepaliveOption is now the policy wrapped in an option.
The stream pair is unchanged and still proves the tear-down and the survival end
to end; its two cases already run concurrently (t.Parallel, 214f9bd9), so the
package pays the longer case (50s) rather than the sum (91s).
The dialer's keepalive pings a server running grpc's default enforcement policy (MinTime 5m), which counts every ping arriving less than five minutes after the previous one as a strike and answers the third with GOAWAY too_many_pings. The dialer pings every 10s, so a connection that carries no write for ~40s -- a watch while the watched resource's version is unchanged -- was torn down, where before the client keepalive it stayed up.
ServerKeepaliveOption returns MinTime 5s, half the client's ping interval, so every ping lands 5s clear of a strike; stateStoreServerOpts installs it on the loopback and token listeners alike.
The curator derived the agent half of its agent-user scope from the
session record's BotUser, which is the router's session-resolution match
key: empty when no [[identities]] are configured (the shipped default),
identities[0].Name when they are. The engine validates the scope and
refuses an empty agent, so every pass in a single-identity deployment
failed on its first session and wrote nothing, forever; in a
multi-identity deployment the write landed at an agent no chat turn
reads.
A turn addresses its own memory with cfg.BotUser, so the composition now
hands the curator that same value through NewAdapter. The record's
BotUser stays exactly what it is, the match key resolution compares
against.
A session the pass cannot address is now skipped with a memory.skipped
action naming why, at the point the scope is produced, instead of
aborting the pass and dropping the actions already collected: one
session with no address must not starve the rest. Real infrastructure
failures -- an unregistered engine, an unreadable store -- remain pass
errors.
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.
task.WorkflowDefinitionVersion/Digest/YAML had no pb.Task field and no
taskProto/taskValue mapping, so over gRPC the pin was never persisted and
any pin already in the row was zeroed by the same Update. The production
daemon's Store is the gRPC client, so the digest guard in pinWorkflowDefinition
was dead there: WorkflowDefinitionYAML was never non-empty for a task read
back over the wire, and each retry re-resolved from the active control-plane
resource instead of the version it started with
(docs/prds/runtime-control-plane.md:95).
The SQL store already wrote and read all three columns; only the contract
dropped them. Adds proto fields 28-30 and the mapping both ways.
Field parity was untied, which is why this was invisible: the task still
crossed, just with those fields silently zeroed. TestTaskProtoCarriesEveryDomainField
fills every domain field and requires the round trip to return it, so the
next forgotten field fails by name. The conformance battery now carries the
pin through Update and back out of TaskByID, failing in grpc mode only.
Resolves archie-core-xrux and archie-core-i3qm. The -config-overlay file path
(and the overlay-directory path) now fold a partial map-valued entry instead of
replacing it wholesale, so an overlay that sets one sibling key no longer clears
services.state.target_token. The file load path stops judging settings the
control plane owns, so a stale TOML value in a database-owned field can no
longer stop archie-state-store starting; boot.runtimeConfig remains the one
layering call and still validates the merged document. A kind with no stored
value leaves the file's value in force.
The fix-closure review found the previous pass moved the failure instead of
ending it. A seed the resource validator refuses leaves the kind ABSENT, and
RuntimeConfig treated an absent kind as fatal, so archied and the Gateway
refused to start with "control-plane resource not found" -- a database-named
error that editing config.toml cannot clear. Reproduced before the fix: every
kind in the new table failed that way.
Two changes, one on each side of the seam:
- Client.RuntimeConfig (and RuntimeChatConfig) now treat a kind with no stored
value as "the file document's value stays in effect", which is what the
skip-and-report comment already claimed. The version map records no version
for such a kind, so nothing is reported as applied. A value the file layer
also refuses still fails closed, at configuration.Validate, with a message
naming the file's own field -- and the file is the fix.
- Which repository lists are valid can no longer differ between the layers.
configuration.ValidateRepositories is now the single rule set (owner and name
present, no duplicates, compilable test glob) and the repository-policies
resource validator delegates to it. The file layer had no duplicate rule
while the resource layer did, so a duplicate [[repos]] entry passed the loader
and then vanished into a skipped seed.
Also, from the same review: the scheduling validator's "0s" carve-out is gone,
so a zero poll interval is refused at write time as configuration.Validate
refuses it (there is no defaulting behind a stored value); applyOverlayFile's
doc now says which overlay forms fold (a conf.d extra does not, and nothing
reads cfg.Extra); and plugin-settings' no-op validator is a named function with
the reason it accepts everything.
Review of the two previous commits found the split was incomplete in both
directions: the checks moved off the file load path were still enforced
anywhere the value could enter the system, and the fold reached only one of the
three overlay paths.
A stale database-owned TOML value could still stop archie-state-store. The
process seeds every control-plane resource from the same file config on a fresh
database, and the seed runs the resource's own validator; three of the five
values the loader now accepts aborted the boot there (verified by booting
RunStateStore before the fix). A seed that does not validate is now SKIPPED and
reported instead of fatal: the resource stays absent, so the file's value is the
one in effect and editing config.toml is still the fix -- the daemon and the
Gateway are where it fails closed, at boot.runtimeConfig.
The resource validators were weaker than configuration.Validate for exactly the
fields the split reclassified, so a value the file path used to refuse at load
became storable in the database, and then un-fixable by editing config.toml.
The trigger enum and the test-glob rule now come from the configuration package
rather than being restated, the container image is required there as it is in the
file, and a table test ties the two layers together value by value.
The directory form of -config-overlay kept the archie-core-e2e2 failure: it
decoded each overlay file straight into the populated config, so a map-valued
entry it only partly addressed still cleared the fields it did not name. Both
the overlay layer's main file and its feature files now fold, which is what
Loader.Dir's documented parity with Loader.Overlay has always claimed.
The overlay file's key report is derived from the apply's own view of the file as
well as the file decode's, because TOML matches keys case-insensitively and the
fold's yaml decode does not: a key only the file decode matched was consumed by
the report and dropped by the apply, a silent no-op that worked in the base file.
Tests: the state-store boot is asserted against the real process, the directory
overlay and the case-mismatched key each have one, and ImportConfig pins that a
refused seed is not stored.
Loader.finalize ran the whole validation over the file document, so a stale
TOML value in a setting the control plane owns failed startup -- including
archie-state-store, which resolves its file config and opens the store without
ever layering a database resource over it. docs/prds/runtime-control-plane.md,
"Bootstrap, migration, and recovery": after migration, settings in TOML are
ignored and cannot block State Store startup.
The checks over the settings a control plane resource is seeded from and
replaces wholesale now run only on the effective document: providers
(provider-settings), poll_interval and dispatch (scheduling-policy), containers
(container-runtime-policies) and the repository lists (repository-policies).
They moved from validate to validateDatabaseOwned; validateBootstrap keeps the
checks over settings no resource carries (forge intake, identities, nats,
memory, image, capture). File sources pass validateBootstrap and
Loader.ApplyOverlay, which layers overrides onto an effective document, passes
Validate.
Nothing stops being judged: the daemon and the Gateway both run the full
Validate in boot.runtimeConfig, the one place database resources are layered
in, before any capability starts -- so a stored value that will not validate
still stops the process rather than being published. Cases that asserted the
load path rejects a database-owned value now assert both layers, and
TestRuntimeConfigFailsClosedOnAnInvalidDatabaseValue pins the second.
Loader.overlayFile decoded the overlay file straight into the config the
base file produced, and a decode replaces a map-valued entry wholesale:
[services.state] target = ... in an overlay cleared the target_token the
base file set. That is archie-core-e2e2 on the user-visible -config-overlay
path -- deployments/dev.toml is the documented argument and sets
[services.state] target/listen, while target_token lives in the installed
config.toml. An enabled image.hosted entry lost its class and api_key_env
the same way, silently turning the provider off.
apply.go's foldOverrides is the fix that path was missing, so the file
overlay now goes through the same fold as the map overlay: the overlay file
parses to its raw mapping (decodeFileMapping), the fields of each partially
addressed map entry are folded forward out of the base config, and the
completed mapping is decoded over it. Loader.ApplyOverlay, ApplyOverlayValues
and apply.go stay: the hazard they were written for is this one.
An overlay file still reports its own unknown keys, from a separate decode
into a scratch value.
steps.go's StageYaegiGate tells the operator to migrate the deleted
.archie/gate.go hook to a registered YAML workflow step, and
BuiltinStepRegistry() exposed only the six shipped workflows' own stages,
so there was nothing to migrate to. What that hook did, from 924b02a1
which deleted it: it read the worktree's repository-authored Go,
exporting Check(GateContext{Diff, ChangedFiles, Dir, BaseRef, Repo})
[]Finding, where each Finding carried a level ("error" blocked the run,
"warn" was advisory) and an optional file and line, and it inspected the
committed diff.
gate.diff-rules is that behaviour as a typed step: operator-written rules
in a stored definition -- per-rule level, RE2 pattern, optional path and
exclude_path scope, message -- matched against the ADDED lines of the
diff against the base branch, reported with their new-file line numbers.
An error-level finding parks the run with the findings in the park
reason; a warn-level finding is logged and nothing else. Unlike the hook
it replaces, no code is read out of the repository being worked on, and
the rules are versioned and audited with the definition they live in.
The settings are validated at the factory, which runs where a definition
is validated and again where it is compiled: a missing level, pattern or
message, an unknown level or settings key, and an expression that is not
a RE2 all refuse the definition rather than load and check nothing.
It arrives through the extension point archie-core-fwmp landed: a
repo-hooks provider in internal/infrastructure/workflowsteps, so both
roots that resolve a step type (the State Store's validating side and the
daemon's workflow-definitions client) register it at once.
Deliberately not landed: a step type for .archie/stages/*.go, whose
faithful equivalent is running a configured command. That would make the
stored workflow-definitions resource a command-execution surface on the
agent host, which is a maintainer's trust decision, not this lane's; it
is escalated, so steps.go's repo-stages error stays as it is.