merge(sams-cleanup): the PocketBase event-capture migration and its follow-ups
Moves event capture, mappings and bindings onto PocketBase-owned collections in internal/infrastructure/edastore, and adds the read-only stateadmin surface over the task database. Follow-ups included: - the event feed cursor becomes a total order over a fixed-width timestamp with an opaque string cursor, so it no longer depends on rowid monotonicity; - cron schedules get next-run arithmetic, so a cron job fires instead of returning ErrScheduleUnsupported; - binding and mapping edits announce on the activity stream, so a dashboard edit is visible without a manual refresh; - an unresolvable task identity fails closed rather than falling back to the root forge's credential; - tool_call events project into the tool_calls collection, which had a schema and no writer. Also: the branch is brought back to a passing task check, which it had not been for the whole migration -- two pre-existing failures, an unrecorded int64-to-string proto break and a stale generated docs artifact.
This commit is contained in:
152 files changed
+5479
-6880
No files matched your search
@@ -0,0 +1,83 @@
|
||||
# Artifact sender
|
||||
|
||||
**Status:** Approved
|
||||
**Revision:** 1
|
||||
**Authority:** this document
|
||||
|
||||
## Purpose
|
||||
|
||||
archie-core publishes artifacts — design documents, review reports, research briefs,
|
||||
runnable pages — to the offloaded.dev collaborative editor. A person reads the
|
||||
artifact, comments on it, and the artifact page is the shared surface for iteration.
|
||||
|
||||
The receiving contract is owned by the editor: `POST /api/artifacts` with a bearer
|
||||
service token, a closed field set, and server-side idempotency on `requestId` plus
|
||||
last-write-wins on `sentAt`. This document owns only what archie-core sends.
|
||||
|
||||
## Scope
|
||||
|
||||
Version one publishes one-way: archie-core sends, the editor receives. The first
|
||||
producer is the pull-request adversarial review: a completed `ReviewReport` is
|
||||
rendered to markdown and published after the review completes.
|
||||
|
||||
Chat-surface tools (`create_artifact`, `update_artifact`), comment read-back, share
|
||||
tokens, and runnable-format producers (`html`, `react`, `vue`) are later slices. The
|
||||
receiving contract already carries them; version one does not exercise them.
|
||||
|
||||
## Configuration
|
||||
|
||||
- New `[artifacts]` section: `base_url` (site origin), `token` (`SecretRef`) with
|
||||
`token_env` fallback naming `WORKSPACE_INGEST_TOKEN`.
|
||||
- An empty `base_url` disables the sender: no client is constructed, nothing is
|
||||
registered, and publishing degrades to a log line.
|
||||
- The token is runtime configuration. It is never baked at build time.
|
||||
|
||||
## Sender
|
||||
|
||||
- New package `internal/infrastructure/artifactsync` exposing one method,
|
||||
`Publish(ctx, Artifact) (string, error)`, where the string is the artifact URL.
|
||||
One-method injected seam, concrete client constructed by the boot path when the
|
||||
configuration resolves — the `crondelivery.Courier` posture.
|
||||
- The client POSTs the frozen contract body. Each publish sends the complete
|
||||
source: versions of record are full snapshots, never diffs.
|
||||
- A `503` response is retried three times with backoff. `401` and `400` are not
|
||||
retried; they are logged with the field reason the response names.
|
||||
- `requestId` is `artifact:<task-id>:<version>` when the producer is task-backed,
|
||||
otherwise `artifact:<identity>:<sentAt-utc>`. Sending the same `requestId` with
|
||||
an equal or older `sentAt` must be a server-side no-op, which makes sender-side
|
||||
retry safe.
|
||||
|
||||
## Report rendering
|
||||
|
||||
- `ReviewReport` gains a pure markdown renderer in `internal/domain/workflow`:
|
||||
the summary as the lede, one finding per subsection with file, line, verdict,
|
||||
level and the failure scenario, and the verified properties as a "checked
|
||||
clean" list. Findings carry their disposition when present.
|
||||
- The renderer performs no I/O and imports no infrastructure.
|
||||
|
||||
## Attribution
|
||||
|
||||
- `actor`: the producing identity. The reviewer publishes as `system:pr-reviewer`
|
||||
when no task identity resolves; otherwise the task's identity name.
|
||||
- `source`: the producing subsystem, `pr-review` for version one.
|
||||
- `task`: owner, repository and issue number from the task when one exists.
|
||||
|
||||
## Failure behaviour
|
||||
|
||||
- Publishing never fails the producing work. A failed publish is logged with its
|
||||
status and reason; the artifact is republished on the next production of the
|
||||
same artifact.
|
||||
- A successful publish records the artifact URL in the run report, so the PR
|
||||
description or task log links to the readable artifact.
|
||||
- The published URL is the editor deep link for the artifact, keyed on its
|
||||
immutable id. archie-core never mints share links; sharing is an
|
||||
account-holder decision made in the editor.
|
||||
|
||||
## Verification
|
||||
|
||||
- Client tests against a test server cover 201, 401, 400 with a field reason,
|
||||
and 503 retry behaviour.
|
||||
- The report renderer test covers a report with findings, checks, dispositions
|
||||
and a not-run status.
|
||||
- Configuration tests cover the disabled case, the `SecretRef` path and the
|
||||
`token_env` fallback.
|
||||
@@ -25,7 +25,7 @@ Every claim in this document is mapped to what exists in the tree.
|
||||
| Tool guardrails (repeat-failure / no-progress) | **Implemented, not on the call path** | `internal/tools/guardrail.go` engine exists. Its only non-test caller is `dispatchOne` — which is itself unreachable — so **the chat path never consults it**, and the agent path only records per *stage* (`domain/workflow/agent.go`) |
|
||||
| Structured capture tools (model reports into a typed store, not prose) | **Implemented** | `internal/app/agentworker/review.go` `record_finding` / `record_checked` — `core.NewTypedTool` appending to a caller-owned slice. This is the pattern a research source ledger should reuse |
|
||||
| Curator engine (interval, declared tool set, lifecycle) | **Implemented, tools broken** | `internal/domain/curator`; a curator declaring tools is **refused** at registration (`registry.go`, no `ToolBuilder` implementation) and `curatorLLMRunner` (`internal/app/archied/main.go`) drops `ChatRequest.Tools`. Budgets are time+concurrency only (`runtime.go`) — **no token budget** |
|
||||
| Cron / scheduling + delivery router | **Implemented, wired into no binary** | `internal/domain/scheduling`, `internal/infrastructure/cronstore` (schema v2, `Kind` discriminator), `internal/infrastructure/crondelivery` — all present and green, but `go list -deps` for every `cmd/` contains none of them, and `cron`-expression firing arithmetic is unimplemented (`schedule.go`, "slice 2"). `ARCHITECTURE.md` still asserts "**No daemon-internal cron.**" |
|
||||
| Cron / scheduling + delivery router | **Implemented, wired into the daemon** | `internal/domain/scheduling` (ticker engine), `internal/infrastructure/cronstore` (schema v2, `Kind` discriminator), and `internal/infrastructure/crondelivery`; `internal/app/archied/scheduling.go` composes them and `main.go` starts the engine. |
|
||||
| Workflow engines (multi-stage, resumable) | **Implemented, worktree-bound** | `internal/domain/workflow` — every non-triage workflow opens with `StagePrepareWorktree()` and mounts `tc.Dir` into a container; the task persists after every stage (`workflow.go`). `triage.go` documents there is "no cheaper directory-less classification primitive" |
|
||||
| Long-running chat-initiated work with progress | **Partial** | Chat turns run **once, synchronously**, inline in the channel's turn runner (`internal/gateway/turn.go`). Chat can spawn a *workflow task* (`task_spawn`) which is asynchronous — but that path is worktree/PR-shaped |
|
||||
| **Operator-push delivery of an async result** | **Aspirational — zero code** | Nothing pushes a finished result to a chat. No channel subscribes to the event bus (Telegram only *publishes* `KindTurnCompleted`); `crondelivery.Courier` is the intended seam but has **no implementation and no caller**; `send_file` works only inside the live turn. The one out-of-band notification in the tree is feasibility's n8n webhook (`feasibility.go`) |
|
||||
@@ -198,7 +198,7 @@ Reusing it would mean every ad-hoc research run leaves a permanent job row.
|
||||
| Collator | `internal/domain/research` | Model pass over `[]ChildConclusion` + source store → report body |
|
||||
| Report renderer | `internal/domain/research` | Markdown + numbered citation list rendered **from the store** |
|
||||
| Chat trigger | slice 2: `internal/tools/research`; slice 3: gateway tool + courier in `internal/app/archied` | — |
|
||||
| Durable run + delivery (slice 3) | `internal/domain/research` + `internal/infrastructure/research` + `internal/app/archied` wiring | Follows the strict plugin-engine rule in `ARCHITECTURE.md` ("Plugin engine
|
||||
| Durable run + delivery (slice 3) | `internal/domain/research` + `internal/infrastructure/research` + `internal/app/archied` wiring | Follows the strict plugin-engine rule in `docs/architecture/plugins-and-extensions.md` ("Plugin engine
|
||||
rule (strict)"): typed contract, owning registry with start/health/stop, narrow typed registrar |
|
||||
|
||||
### Why not the curator
|
||||
|
||||
@@ -42,7 +42,8 @@ long as it's implemented behind one of the typed engine families below.
|
||||
generic interface -- see "Typed positions, not one generic hook" below,
|
||||
which is how it stays compliant with the plugin engine rule instead of
|
||||
reopening that document's #4.
|
||||
- `ARCHITECTURE.md#plugin-engine-rule-strict` governs every extension point
|
||||
- `docs/architecture/plugins-and-extensions.md#plugin-engine-rule-strict`
|
||||
governs every extension point
|
||||
introduced here. Every position below is a typed domain contract with an
|
||||
owning registry, not a generic callback map. This is a hard constraint,
|
||||
confirmed against the existing rule text before writing this doc.
|
||||
|
||||
@@ -12,7 +12,8 @@ each question and saying which packages change.
|
||||
## 1. In-process typed families, not out-of-process dispatch
|
||||
|
||||
Archie has no out-of-process extension mechanism. The plugin engine
|
||||
rule (`ARCHITECTURE.md#plugin-engine-rule-strict`, mechanically checked by
|
||||
rule (`docs/architecture/plugins-and-extensions.md#plugin-engine-rule-strict`,
|
||||
mechanically checked by
|
||||
`internal/plugin/architecture_test.go`) keeps every capability family
|
||||
in-process behind a narrow typed registrar; NATS RPC exists for
|
||||
daemon<->agentexec, a different actor with a different trust boundary (task
|
||||
|
||||
@@ -25,8 +25,9 @@ in the repo defines this (`grep -ri image` over `internal/domain` and
|
||||
## Design
|
||||
|
||||
Follows the plugin engine family shape already established by
|
||||
`internal/domain/curator` and `internal/domain/memory` (ARCHITECTURE.md
|
||||
"plugin engine rule strict"): a typed contract with real domain operations,
|
||||
`internal/domain/curator` and `internal/domain/memory`
|
||||
(`docs/architecture/plugins-and-extensions.md#plugin-engine-rule-strict`): a
|
||||
typed contract with real domain operations,
|
||||
an owning `Registry` (register/get/names, no start/stop lifecycle — see
|
||||
below), and narrow host access via a `Registrar`.
|
||||
|
||||
|
||||
@@ -332,7 +332,8 @@ Each step is independently verifiable and lands green on its own.
|
||||
4. **Chat write path.** The tool adapter onto CRUD and the turn's subject on the
|
||||
context. *Depends on 3, because a write is only observable through the read.*
|
||||
5. **Delete `internal/memory` and the dead config/dashboard surface**, and
|
||||
rewrite `ARCHITECTURE.md`'s "Memory engine family" section to describe the
|
||||
rewrite the "Memory engine family" section of
|
||||
`docs/architecture/plugins-and-extensions.md` to describe the
|
||||
engine family rather than a manager it deleted. *Depends on 3 and 4.*
|
||||
|
||||
Steps 3 and 4 are separable from each other; step 1 is separable from everything.
|
||||
|
||||
@@ -116,7 +116,7 @@ re-baselined coupling inventory is below, and the ratified boundary is
|
||||
- Any concrete adoption of Pi (or another external agent harness) as an
|
||||
execution runner. Raised in conversation alongside this decomposition,
|
||||
but it is a separate decision (agent execution as a strict data
|
||||
boundary, `ARCHITECTURE.md`) and does not gate or get gated by this PRD.
|
||||
boundary, `docs/architecture/agent-system.md`) and does not gate or get gated by this PRD.
|
||||
|
||||
## Open questions
|
||||
|
||||
|
||||
@@ -66,10 +66,10 @@ the control.
|
||||
Mapped payload fields are treated as ordinary user-controlled text inside an
|
||||
agent prompt, exactly like an inbound chat message never as trusted
|
||||
instructions. "The agent should ignore instructions in the payload" is not a
|
||||
control and must not appear as one anywhere in this feature -- per
|
||||
`ARCHITECTURE.md`'s environmental-enforcement-over-prompt-rules principle,
|
||||
the boundary is the gate and the sandbox, not a sentence in the system
|
||||
prompt.
|
||||
control and must not appear as one anywhere in this feature -- per the
|
||||
environmental-enforcement principle (`docs/architecture/agent-system.md`,
|
||||
"Existing invariants to preserve"), the boundary is the gate and the sandbox,
|
||||
not a sentence in the system prompt.
|
||||
|
||||
## 5. Retention and redaction of captured payloads
|
||||
|
||||
|
||||
Reference in new issue
Block a user