refactor: strip doc and issue narration from code comments
Remove PRD/doc paths, bead IDs, phase notes and deleted-test references from comments; drop test-only hooks left by the test deletion. Includes in-progress archied bootstrap, gateway and query changes.
This commit is contained in:
1 parent
a8a118c1b8
commit
030b4ed176
269 files changed
+1201
-2609
No files matched your search
@@ -1,48 +0,0 @@
|
||||
// Command archie-prbench scores the PR reviewer on the Martian
|
||||
// Code-Review-Bench problems. See docs/prds/pr-review-agent.md, Verification.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/app/prbench"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
)
|
||||
|
||||
func main() { os.Exit(run()) }
|
||||
|
||||
func run() int {
|
||||
var opts prbench.Options
|
||||
var problems string
|
||||
flag.StringVar(&opts.Config, "config", configuration.DefaultConfigPath(), "configuration file whose providers serve the reviewer and judge")
|
||||
flag.StringVar(&opts.Fixtures, "findings", "", "directory of <problem id>.json findings to rescore; omit to review live")
|
||||
flag.StringVar(&opts.ReviewModel, "review-model", "", "provider/model for the review role in live runs")
|
||||
flag.StringVar(&opts.ClassifyModel, "classification-model", "", "provider/model for the classification role in live runs")
|
||||
flag.StringVar(&opts.JudgeModel, "judge-model", "anthropic/claude-sonnet-4.6", "provider/model of the independent judge")
|
||||
flag.StringVar(&opts.Out, "out", "bin/prbench-results", "directory for per-problem results and summary.json")
|
||||
flag.StringVar(&opts.Resume, "resume", "", "reuse complete results from a previous run with the same models")
|
||||
flag.StringVar(&problems, "problems", "", "comma-separated problem ids (default: all)")
|
||||
flag.IntVar(&opts.Concurrency, "concurrency", 4, "problems judged at once")
|
||||
flag.Parse()
|
||||
opts.GitHubToken = os.Getenv("GH_TOKEN")
|
||||
if opts.GitHubToken == "" {
|
||||
opts.GitHubToken = os.Getenv("GITHUB_TOKEN")
|
||||
}
|
||||
if problems != "" {
|
||||
opts.Problems = strings.Split(problems, ",")
|
||||
}
|
||||
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
defer stop()
|
||||
if _, err := prbench.Run(ctx, opts, os.Stdout); err != nil {
|
||||
fmt.Fprintln(os.Stderr, "archie-prbench:", err)
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
// Command archie-state-store hosts the State Store's gRPC contract and is the
|
||||
// only process that owns the PostgreSQL stores behind it. See
|
||||
// docs/prds/state-store-contract.md §5, §9 and §11.
|
||||
// only process that owns the PostgreSQL stores behind it.
|
||||
package main
|
||||
|
||||
import (
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
// recoveryUsage is the whole flag surface of the offline recovery commands.
|
||||
// They are subcommands of this binary rather than a recovery binary of their
|
||||
// own: offline database maintenance belongs to the process that owns the file
|
||||
// and its path layout (docs/architecture/organisation.md#process-boundaries).
|
||||
// and its path layout.
|
||||
const recoveryUsage = `usage: archie-state-store <command> [flags]
|
||||
|
||||
With no command, archie-state-store serves the State Store gRPC contract.
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
// contracts. It is the .5.2 companion to archie-gateway and
|
||||
// archie-state-store: a thin main that parses process inputs and hands them
|
||||
// to archieui.Run.
|
||||
//
|
||||
// See docs/prds/ui-service-boundary.md for the ratified boundary.
|
||||
package main
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//go:build ignore
|
||||
|
||||
// log module implementation for archied's EDA playbook engine (Module
|
||||
// position, t2db.13). The first action kind: side-effect-free -- it only
|
||||
// writes a line to the daemon's log, so it proves the schema -> go:generate
|
||||
// log module implementation for archied's EDA playbook engine. The first action
|
||||
// kind: side-effect-free -- it only writes a line to the daemon's log, so it
|
||||
// proves the schema -> go:generate
|
||||
// -> Yaegi load -> ModuleRegistry -> dispatch mechanism end to end without
|
||||
// needing an idempotency answer.
|
||||
//
|
||||
|
||||
@@ -358,7 +358,7 @@ func isNonEmptyString(object map[string]json.RawMessage, field string) bool {
|
||||
}
|
||||
|
||||
// scriptToolSet exposes run_go_script: interpreting a Yaegi Go script
|
||||
// bundled with a skill (.agents/skills/<skill>/scripts/*.go) or living
|
||||
// bundled with a skill or living
|
||||
// anywhere else in the workspace, and returning what it printed. This is
|
||||
// how an agent following a skill's instructions ("run scripts/gitleaks.go
|
||||
// to scan for secrets") actually executes a .go helper without a Go
|
||||
|
||||
@@ -84,9 +84,9 @@ type Request struct {
|
||||
Protection Protection `json:"protection"`
|
||||
Notes string `json:"notes,omitempty"`
|
||||
CaptureTools []CaptureTool `json:"capture_tools,omitempty"`
|
||||
// Plugins are bundled Yaegi plugins from the skill's plugins/
|
||||
// directory. Each entry carries the name and source so the agent
|
||||
// can register them as tools. PRD section 5 Layer 1.
|
||||
// Plugins are bundled Yaegi plugins from the skill's plugins/ directory.
|
||||
// Each entry carries the name and source so the agent can register them as
|
||||
// tools.
|
||||
Plugins []PluginSpec `json:"plugins,omitempty"`
|
||||
// Harness, when set, runs the stage on an external coding-agent CLI
|
||||
// instead of the built-in loop. The worker in a Kit container is the
|
||||
|
||||
@@ -9,9 +9,7 @@ import (
|
||||
//
|
||||
// These belong to this package because it defines what an agent request and
|
||||
// response mean. They previously sat in the NATS package, which made the
|
||||
// transport the owner of Archie's agent protocol; see
|
||||
// docs/architecture/dependencies-and-contracts.md -- message schemas and the
|
||||
// subjects addressing them stay with the domain that defines them.
|
||||
// transport the owner of Archie's agent protocol.
|
||||
const (
|
||||
// SubjectSystemWildcard matches every task's system subject, for a
|
||||
// daemon subscribing to all of them at once with a single core NATS
|
||||
|
||||
@@ -33,7 +33,7 @@ type LogPublisher interface {
|
||||
// decode() moves it into Fields itself. Handing decode() this payload
|
||||
// instead of json.Unmarshal would nest everything one level too deep, under
|
||||
// a literal "fields" key, and silently lose every real field name. A future
|
||||
// consumer of this subject (see GitHub issue #454) must unmarshal directly
|
||||
// consumer of this subject must unmarshal directly
|
||||
// into logging.Entry, not call decode() on these bytes.
|
||||
//
|
||||
// Publishing is fire-and-forget. A core NATS Publish call is already
|
||||
|
||||
@@ -78,9 +78,8 @@ type ToolSetOptions struct {
|
||||
Approval tools.ApprovalRequester
|
||||
|
||||
// OnToolCall, when non-nil, is notified once per completed tool call.
|
||||
// LoopRunner populates it so a workflow stage can surface tool
|
||||
// activity on the task timeline (archie-core-467's task-transcript
|
||||
// counterpart). Nil means no one is listening.
|
||||
// LoopRunner populates it so a workflow stage can surface tool activity on
|
||||
// the task timeline. Nil means no one is listening.
|
||||
OnToolCall ToolCallReporter
|
||||
}
|
||||
|
||||
|
||||
@@ -42,12 +42,12 @@ type hybridTrees struct {
|
||||
localDir string
|
||||
branch string
|
||||
// worktreeUID and worktreeGID are the daemon's own host UID/GID
|
||||
// (WORKTREE_UID/WORKTREE_GID, set by containerEnv), or -1 when unset.
|
||||
// The agent runs as root inside the container, so a commit it writes
|
||||
// to the bind-mounted worktree lands owned by UID 0 on the host; Push
|
||||
// reconciles ownership back to the daemon's UID before handing off,
|
||||
// since the daemon -- running as its own non-root host user -- is the
|
||||
// one that reads those objects to actually push (archie-core#520).
|
||||
// (WORKTREE_UID/WORKTREE_GID, set by containerEnv), or -1 when unset. The
|
||||
// agent runs as root inside the container, so a commit it writes to the
|
||||
// bind-mounted worktree lands owned by UID 0 on the host; Push reconciles
|
||||
// ownership back to the daemon's UID before handing off, since the daemon
|
||||
// -- running as its own non-root host user -- is the one that reads those
|
||||
// objects to actually push.
|
||||
worktreeUID, worktreeGID int
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ type taskDependencies struct {
|
||||
// steps is the workflow step vocabulary pinned definitions are compiled
|
||||
// against, registered at the composition root and injected: this is the
|
||||
// executing half of the contract whose validating half is the control
|
||||
// plane's (archie-core-fwmp).
|
||||
// plane's.
|
||||
steps *workflow.Manager
|
||||
// guardrails is the guardrail engine agent stages record tool outcomes
|
||||
// against. It is built by this process's composition root (the workflow
|
||||
@@ -270,13 +270,12 @@ func runTask(ctx context.Context, req taskrun.Request, dependencies taskDependen
|
||||
}
|
||||
// The agent process runs as root inside the container, so everything this
|
||||
// run writes into the bind-mounted worktree is owned by UID 0 on the host;
|
||||
// CommitAll and Push hand it back on the success path (archie-core#520).
|
||||
// Doing the same here covers every OTHER way a run can end -- a gate
|
||||
// failure that parks the task, a stage error, an early return -- because
|
||||
// the daemon is the one that later cleans and resets this directory, as its
|
||||
// own non-root host user, and it cannot even unlink a root-owned directory.
|
||||
// Without this, a parked attempt left a worktree the next attempt could not
|
||||
// start from.
|
||||
// CommitAll and Push hand it back on the success path. Doing the same here
|
||||
// covers every OTHER way a run can end -- a gate failure that parks the
|
||||
// task, a stage error, an early return -- because the daemon is the one
|
||||
// that later cleans and resets this directory, as its own non-root host
|
||||
// user, and it cannot even unlink a root-owned directory. Without this, a
|
||||
// parked attempt left a worktree the next attempt could not start from.
|
||||
defer restoreWorktreeOwnership(trees, workDir, log)()
|
||||
|
||||
// The MCP providers a task hosts share the same model runtime its agent
|
||||
@@ -305,7 +304,7 @@ func runTask(ctx context.Context, req taskrun.Request, dependencies taskDependen
|
||||
// processes connected only by NATS. Without this bridge, tc.Emit is a
|
||||
// silent no-op for every stage/outcome/park event this run produces,
|
||||
// which is why the dashboard timeline showed nothing for any task
|
||||
// executed through the container/NATS path (archie-core-518). Nil
|
||||
// executed through the container/NATS path. Nil
|
||||
// dependencies.events (a caller with no NATS connection, e.g. tests
|
||||
// that construct taskDependencies directly) leaves bus nil, and
|
||||
// TaskContext.Emit is already nil-safe.
|
||||
@@ -335,7 +334,6 @@ func runTask(ctx context.Context, req taskrun.Request, dependencies taskDependen
|
||||
// prefetchPRReview, writing under workDir/.archie-pr-review -- the same
|
||||
// host directory Docker bind-mounts at storage.WorktreeMountDir) -- never
|
||||
// over the network, and never with a forge credential in this process.
|
||||
// See docs/development/agent.md, "Giving the agent something new".
|
||||
if req.Task.Workflow == "pr-review" {
|
||||
tc.PRSource = prsource.NewFromMount(filepath.Join(workDir, prsource.PrefetchDirName))
|
||||
}
|
||||
@@ -362,9 +360,7 @@ func runTask(ctx context.Context, req taskrun.Request, dependencies taskDependen
|
||||
|
||||
// CompilePinnedWorkflow resolves and compiles the immutable definition the task
|
||||
// request carries, against this process's step vocabulary. Production execution
|
||||
// and the workflow step-vocabulary contract test
|
||||
// (internal/app/controlplane/step_vocabulary_agreement_test.go) both enter
|
||||
// through it.
|
||||
// and the workflow step-vocabulary contract test both enter through it.
|
||||
//
|
||||
// A request that carries no definition is routed and pinned from the shipped
|
||||
// definitions, which writes the resolved workflow name, YAML, and digest back
|
||||
|
||||
@@ -36,11 +36,9 @@ type Settings struct {
|
||||
NATSToken string
|
||||
WorkDir string
|
||||
|
||||
// StateStoreTarget and StateStoreToken are the daemon-injected State
|
||||
// Store gRPC endpoint and bearer token (docs/prds/state-store-contract.md
|
||||
// §6: STATE_STORE_URL/STATE_STORE_TOKEN, mirroring the NATS_URL/NATS_TOKEN
|
||||
// handoff). StateStoreTarget is required: the legacy NATS storerpc path
|
||||
// is deleted (docs/prds/state-store-contract.md §12 step 4).
|
||||
// StateStoreTarget and StateStoreToken are the daemon-injected State Store
|
||||
// gRPC endpoint and bearer token. StateStoreTarget is required: the legacy
|
||||
// NATS storerpc path is deleted.
|
||||
StateStoreTarget string
|
||||
StateStoreToken string
|
||||
}
|
||||
@@ -72,12 +70,7 @@ type workerDependencies struct {
|
||||
guardrails *tools.GuardrailEngine
|
||||
}
|
||||
|
||||
// productionWorkerDependencies builds the worker's process dependencies. The
|
||||
// workflow step vocabulary is registered here, at the executing side's
|
||||
// composition root, before the first task is served:
|
||||
// internal/app/agentworker's step_vocabulary_test.go calls this function and
|
||||
// fails if it stops using the shared provider set
|
||||
// (internal/infrastructure/workflowsteps).
|
||||
// productionWorkerDependencies builds the worker's process dependencies.
|
||||
func productionWorkerDependencies() (workerDependencies, error) {
|
||||
steps, err := workflowsteps.NewManager()
|
||||
if err != nil {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// The `archied access reset` command: the locked-out-org and broken-instance
|
||||
// recovery surface (docs/prds/orgs-and-access.md, "Recovering from a
|
||||
// locked-out org"). It restores the shipped role policies for one org and
|
||||
// recovery surface. It restores the shipped role policies for one org and
|
||||
// removes its other org-level policies, or removes the stored instance
|
||||
// policies; the cross-org forbid is engine-enforced and survives any reset.
|
||||
//
|
||||
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
)
|
||||
|
||||
// bindingCipherFromConfig resolves the binding at-rest encryption key from
|
||||
// config through the secret registry and returns the EDA store's cipher. An unset
|
||||
// encryption_key returns a nil cipher, keeping the legacy plaintext path (the
|
||||
// store's default). See docs/prds/binding-secret-encryption.md.
|
||||
// config through the secret registry and returns the EDA store's cipher. An
|
||||
// unset encryption_key returns a nil cipher, keeping the legacy plaintext path
|
||||
// (the store's default).
|
||||
func bindingCipherFromConfig(cfg config.Config, secrets *secret.Registry) (bindingcipher.BindingCipher, error) {
|
||||
if cfg.Bindings.EncryptionKey == (secret.SecretRef{}) {
|
||||
return nil, nil
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -5,10 +5,7 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/domain/messaging"
|
||||
)
|
||||
|
||||
// carriesPersonIdentity reports whether a platform's SenderID names a person,
|
||||
// per docs/prds/memory-engine-unification.md §3: resolution is supplied per
|
||||
// channel by the composition, never inferred by the engine or guessed from a
|
||||
// channel-neutral "channel:SenderID" concatenation.
|
||||
// carriesPersonIdentity reports whether a platform's SenderID names a person.
|
||||
//
|
||||
// Telegram and email carry a native per-person sender id (a Telegram numeric
|
||||
// user id, an SMTP from address). The dashboard ("web") has one bearer token,
|
||||
@@ -37,7 +34,7 @@ func carriesPersonIdentity(platform string) bool {
|
||||
// It was closed over a single channel name, and one Gateway Router serves every
|
||||
// channel, so that name was "web" even for a Telegram turn: the allowlist above
|
||||
// was real code no production call site reached with a real channel name, and
|
||||
// Subject.UserID was always empty (archie-core-c1qx). Reading the platform off
|
||||
// Subject.UserID was always empty. Reading the platform off
|
||||
// the inbound is what makes the policy reachable.
|
||||
func userIdentityResolver() func(messaging.Inbound) (memory.IdentityID, bool) {
|
||||
return func(in messaging.Inbound) (memory.IdentityID, bool) {
|
||||
|
||||
@@ -48,7 +48,7 @@ type chatSetup struct {
|
||||
ChatTaskLogs gateway.ChatTaskLogReader
|
||||
ChatTaskActor gateway.ChatTaskActor
|
||||
DefaultChatIdentity string
|
||||
// Bus carries primary-input events (archie-core-035): a completed
|
||||
// Bus carries primary-input events: a completed
|
||||
// chat turn is published here so input-driven curators can wake. Nil
|
||||
// disables turn events (tests, minimal setups).
|
||||
Bus *events.Bus
|
||||
@@ -61,9 +61,8 @@ type chatSetup struct {
|
||||
// engine, resolved by cfg.Memory.Engine). Nil disables the chat <memory>
|
||||
// block for every turn runner built from this setup.
|
||||
MemoryEngine gateway.MemoryStore
|
||||
// MemoryWriter is the same active engine's write surface, used to build
|
||||
// the per-turn memory_create/update/delete/list tools (docs/prds/
|
||||
// memory-engine-unification.md §5). Nil omits those tools.
|
||||
// MemoryWriter is the same active engine's write surface, used to build the
|
||||
// per-turn memory_create/update/delete/list tools. Nil omits those tools.
|
||||
MemoryWriter gateway.MemoryWriteStore
|
||||
// ProviderOutcomes records the outcome of every chat-model call this
|
||||
// process makes, which the /status health source reads back. Nil disables
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
// validates the result. Boot and the SIGHUP reload both go through it: the
|
||||
// reload re-resolves the file document alone, so republishing that document
|
||||
// as it stands reverts each of these layers to its file value until the
|
||||
// process restarts (archie-core-ju85).
|
||||
// process restarts.
|
||||
func (b *boot) runtimeConfig(ctx context.Context, base config.Config) (config.Config, map[string]int64, error) {
|
||||
cfg, versions, err := b.controlPlane.RuntimeConfig(ctx, base)
|
||||
if err != nil {
|
||||
@@ -178,9 +178,7 @@ type executionSettingsCandidate struct {
|
||||
// be published as and runs this process's own runnability check on it -- the
|
||||
// same configuration.Validate that runtimeConfig applies before publishing a
|
||||
// layered config, and that the readiness probe applies to the published one. A
|
||||
// snapshot this process cannot run is refused before it becomes the live one
|
||||
// (docs/prds/runtime-control-plane.md, "API": Archie starts and checks the new
|
||||
// one before switching).
|
||||
// snapshot this process cannot run is refused before it becomes the live one.
|
||||
//
|
||||
// The kind's schema is deliberately not re-checked here. The store validates
|
||||
// every document before it is written (Definition.Decode) and
|
||||
@@ -332,7 +330,6 @@ func (b *boot) startRuntimeResourceWatches(ctx context.Context, versions map[str
|
||||
// reported through apply status, which keeps the version still live on the
|
||||
// record. A refused update therefore reaches the settings page the way a
|
||||
// refused workflow-execution-settings update does
|
||||
// (docs/prds/control-plane-apply-status.md).
|
||||
func (b *boot) applyRuntimeResourceUpdate(ctx context.Context, kind string, update controlplane.AppliedResource) {
|
||||
if update.Err != nil {
|
||||
// A stream failure carries no version at all (versions start at 1,
|
||||
@@ -443,9 +440,7 @@ func (b *boot) reconcileRuntimePlugins(ctx context.Context) {
|
||||
// refuseSkillsDirChange refuses a stored plugin-settings document whose
|
||||
// skills_dir differs from the value in force. skills_dir is the one directory
|
||||
// with no live consumer, so a change to it stays a restart-scoped edit rather
|
||||
// than a value the daemon reports as applied. The check reads the running
|
||||
// config, so it cannot live in validatePluginSettings, which is value-agnostic
|
||||
// by the archie-core-1143 decision.
|
||||
// than a value the daemon reports as applied.
|
||||
func (b *boot) refuseSkillsDirChange(ctx context.Context) error {
|
||||
var stored struct {
|
||||
SkillsDir string `json:"skills_dir"`
|
||||
|
||||
@@ -16,11 +16,7 @@ import (
|
||||
// ENDS can take: a store that errors at once is charged, and so is one that
|
||||
// stalls for less than the window the attempt is judged against, because that
|
||||
// window is derived from the delay the attempt would otherwise be charged and
|
||||
// widens with the ladder instead of sitting at its floor (attemptHealthy). The
|
||||
// reach stops at the window: a stall still going when the window closes is read
|
||||
// as a store that answered, so an outage whose every attempt takes at least
|
||||
// that long leaves the ladder at the minimum -- deliberately, and pinned by
|
||||
// TestKeepWatchTreatsAStallPastTheWindowAsAStoreThatAnswered.
|
||||
// widens with the ladder instead of sitting at its floor (attemptHealthy).
|
||||
//
|
||||
// This loop charges only attempts that end, and imposes no timeout of its own:
|
||||
// nextUpdate waits on the stream and on the loop's own context, never on a
|
||||
@@ -55,7 +51,7 @@ const controlPlaneWatchHealthyMultiple = 2
|
||||
// connection drops, or the server closes the stream. keepWatch reopens it in
|
||||
// place; workflow-execution-settings also reports the gap so apply status does
|
||||
// not keep re-stamping the previous successful version as current while no
|
||||
// live updates can arrive (archie-core-1050).
|
||||
// live updates can arrive.
|
||||
//
|
||||
// One goroutine per kind, reconnecting in place: a long outage does not stack
|
||||
// watchers. Reopening resumes after the last version an update carried, so a
|
||||
@@ -95,13 +91,12 @@ const controlPlaneWatchHealthyMultiple = 2
|
||||
// controlPlaneWatchRetry for what ends an attempt against a peer that never
|
||||
// answers), so the reach of the rule stops at the window itself: a stall still
|
||||
// going when the window closes is read as a store that answered, and the delay
|
||||
// stays at the minimum for as long as every attempt takes that long. That
|
||||
// is deliberate rather than a gap to close with another rule. The stalled
|
||||
// attempt lasts the window, so the reopens it leaves behind are bounded by the
|
||||
// attempt and not by the delay -- about 0.8 a second at the minimum rung,
|
||||
// against the four a second this rule exists to charge -- and a shape that slow
|
||||
// is not the request loop it exists for. It is pinned by
|
||||
// TestKeepWatchTreatsAStallPastTheWindowAsAStoreThatAnswered.
|
||||
// stays at the minimum for as long as every attempt takes that long. That is
|
||||
// deliberate rather than a gap to close with another rule. The stalled attempt
|
||||
// lasts the window, so the reopens it leaves behind are bounded by the attempt
|
||||
// and not by the delay -- about 0.8 a second at the minimum rung, against the
|
||||
// four a second this rule exists to charge -- and a shape that slow is not the
|
||||
// request loop it exists for.
|
||||
//
|
||||
// open, versionOf and deliver are the kind's halves. open re-establishes the
|
||||
// stream -- the caller opens the first one itself, so that a control plane
|
||||
@@ -113,10 +108,10 @@ const controlPlaneWatchHealthyMultiple = 2
|
||||
// wait is the delay between a stream ending and the reopen that follows it, and
|
||||
// production passes waitFor. It is injected so that the delay the loop hands it
|
||||
// is observable as a value: the retry_in log line states the delay the loop
|
||||
// charged, and a loop that charged one delay and waited another would leave that
|
||||
// attribute agreeing with itself. What the injected wait cannot show is a
|
||||
// multiple taken inside waitFor itself, which is a timer for exactly the d it is
|
||||
// given (TestKeepWatchWaitsTheDelayItCharged reads the argument, not the wait).
|
||||
// charged, and a loop that charged one delay and waited another would leave
|
||||
// that attribute agreeing with itself. What the injected wait cannot show is a
|
||||
// multiple taken inside waitFor itself, which is a timer for exactly the d it
|
||||
// is given.
|
||||
func keepWatch[T any](
|
||||
ctx context.Context,
|
||||
log *slog.Logger,
|
||||
@@ -187,12 +182,7 @@ func attemptHealthy(progressed bool, openFor, backoff time.Duration) bool {
|
||||
// delay the attempt would otherwise be charged, multiplied by
|
||||
// controlPlaneWatchHealthyMultiple. The window moves with the ladder, so the
|
||||
// charge reaches a store that fails slowly at every rung of it, which a window
|
||||
// fixed at the minimum does not. The multiple is strictly more than one, so the
|
||||
// window is always wider than that charge -- a store that fails as slowly as
|
||||
// the charge it would be paid is still charged, which is the shape of
|
||||
// TestWatchRetryGrowsWhileTheStateStoreIsDown that says so -- and an attempt is
|
||||
// healthy at the window as well as past it (TestAttemptHealthyAtTheWindowBoundary
|
||||
// pins that edge).
|
||||
// fixed at the minimum does not.
|
||||
func controlPlaneWatchHealthyWindow(backoff time.Duration) time.Duration {
|
||||
return controlPlaneWatchHealthyMultiple * retryDelay(backoff, false)
|
||||
}
|
||||
@@ -216,8 +206,7 @@ func retryDelay(current time.Duration, healthy bool) time.Duration {
|
||||
// cancellation that asked it to stop. The coupling that is load-bearing runs
|
||||
// the other way: this watch returns on cancellation without draining what the
|
||||
// producer has left for it, so controlplane.Client's producer must stop on the
|
||||
// same context instead of parking on a send no reader will ever take (its send
|
||||
// guard is pinned by TestKeepWatchLeavesNoProducerParkedOnAnUndeliveredUpdate).
|
||||
// same context instead of parking on a send no reader will ever take.
|
||||
func nextUpdate[T any](ctx context.Context, stream <-chan T) (T, bool) {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
|
||||
@@ -67,7 +67,7 @@ func RunGateway(ctx context.Context, options GatewayOptions) error {
|
||||
}
|
||||
// The Gateway also no longer opens archie.db directly: it consumes the
|
||||
// same remote State Store contract the daemon does via
|
||||
// [services.state].target (docs/prds/state-store-contract.md §12 step 7).
|
||||
// [services.state].target.
|
||||
if err := b.openGatewayState(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -132,7 +132,7 @@ func (b *boot) serveGatewayListener(ctx context.Context, listener net.Listener,
|
||||
b.log.Info("archie-gateway running", "addr", listener.Addr().String(), "token_required", !loopback)
|
||||
// Boot is over and this listener is about to accept: the same fact
|
||||
// systemd's READY=1 asserts, so the announcement goes out here rather than
|
||||
// from a second notion of "started" (archie-core-1174). Not later: Serve
|
||||
// from a second notion of "started". Not later: Serve
|
||||
// begins accepting the moment it is called, and a unit whose
|
||||
// TimeoutStartSec expires first would restart a healthy process.
|
||||
b.announceReady()
|
||||
@@ -159,13 +159,10 @@ func (b *boot) startGatewayRuntime(ctx context.Context, actor gateway.ChatTaskAc
|
||||
b.capabilityHost = plugin.NewHost()
|
||||
b.startRateLimiter(ctx, b.cfg.Chat.RateLimit)
|
||||
// The Gateway composes the process-wide worktree manager before
|
||||
// setupGatewayChat; nothing in this process reads it today (the old
|
||||
// synchronous operator-review path that did was removed with the
|
||||
// adversarial self-review system, archie-core-afbk.7 -- see that bead's
|
||||
// continuation for the operator trigger's replacement). Kept for the
|
||||
// setupGatewayChat; nothing in this process reads it today. Kept for the
|
||||
// manager's other consumers; it is the only part of the daemon's tree
|
||||
// composition the Gateway takes -- it must not own identity runners, so
|
||||
// it does not call buildTreesAndIdentities.
|
||||
// composition the Gateway takes -- it must not own identity runners, so it
|
||||
// does not call buildTreesAndIdentities.
|
||||
b.buildWorktreeManager()
|
||||
// setupMemoryEngine must run before setupGatewayChat: setupGatewayChat
|
||||
// constructs the turn runner, which captures b.memEngines at
|
||||
@@ -177,7 +174,7 @@ func (b *boot) startGatewayRuntime(ctx context.Context, actor gateway.ChatTaskAc
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := b.registerTools(ctx); err != nil {
|
||||
if err := b.registerTools(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b.registerStandaloneTools()
|
||||
|
||||
@@ -75,7 +75,6 @@ func (b *boot) setupChatRuntime(ctx context.Context, cfg config.Config) error {
|
||||
// Chat's /approve reaches the daemon's one task-action service rather
|
||||
// than its own requeue, so a chat approval and a dashboard approval
|
||||
// cannot record different decisions for one operator intent
|
||||
// (docs/prds/pr-review-operator-response.md, Decision 1).
|
||||
approve: func(ctx context.Context, scope *string, actor taskactions.Actor, taskID int64, res taskactions.ActionPayload) error {
|
||||
return b.taskActions().Apply(ctx, scope, actor, taskID, taskstate.ActionApprove, res)
|
||||
},
|
||||
@@ -90,9 +89,6 @@ func (b *boot) setupChatRuntime(ctx context.Context, cfg config.Config) error {
|
||||
// cannot be watched at all fails the boot that asked for it rather than
|
||||
// leaving the process running personas it can no longer update; after that the
|
||||
// watch reconnects instead of ending (see keepWatch).
|
||||
//
|
||||
// Persona updates are not reported through apply status -- the personas kind
|
||||
// has no apply-status wiring, which is archie-core-aj35, not this watch.
|
||||
func (b *boot) watchPersonas(ctx context.Context, version int64) error {
|
||||
updates, err := b.controlPlane.WatchPersonas(ctx, version)
|
||||
if err != nil {
|
||||
|
||||
@@ -15,12 +15,9 @@ import (
|
||||
// healthSurface is archied's own liveness endpoint, served on
|
||||
// [health].listen for the lifetime of the process.
|
||||
//
|
||||
// The dashboard also answers /healthz, but on the dashboard's listener: that
|
||||
// can be switched off, and in Phase 3 it belongs to a separate process
|
||||
// entirely. Either way it is the wrong thing to ask "did archied come back
|
||||
// up?" -- which is exactly what the update watchdog asks after restarting
|
||||
// the daemon, and answers with a rollback when nothing replies
|
||||
// (archie-core-1r4g, archie-core-exbz).
|
||||
// Either way it is the wrong thing to ask "did archied come back up?" -- which
|
||||
// is exactly what the update watchdog asks after restarting the daemon, and
|
||||
// answers with a rollback when nothing replies
|
||||
//
|
||||
// serving gates the liveness answer: the listener binds early in boot, so
|
||||
// the port is answering before the daemon is, and a 200 before the daemon
|
||||
|
||||
@@ -61,7 +61,6 @@ func (b *boot) setupKitLauncher(ctx context.Context) {
|
||||
}
|
||||
// grants is the production Resolver: Launch/Release Grant/RevokeGrant it
|
||||
// per run with exactly the declared-and-granted intersection
|
||||
// (docs/prds/external-agent-harness.md, Credentials; archie-core-egkf.11).
|
||||
grants := egress.NewGrantResolver()
|
||||
// Without a harness secret store, Register refuses a Kit with a
|
||||
// required OAuth credential.
|
||||
|
||||
@@ -359,10 +359,6 @@ func Run() int { //nolint:cyclop,funlen // the composition root's setup sequence
|
||||
return 1
|
||||
}
|
||||
|
||||
// The state-store adapter, its daemon-side surfaces and the policy chain
|
||||
// dispatch evaluates: one ordered stage of the composition sequence
|
||||
// (openStateStage; docs/prds/state-store-contract.md §12 step 7 and
|
||||
// docs/prds/orgs-and-access.md).
|
||||
if err := b.openStateStage(ctx); err != nil {
|
||||
return 1
|
||||
}
|
||||
@@ -406,7 +402,7 @@ func Run() int { //nolint:cyclop,funlen // the composition root's setup sequence
|
||||
return 1
|
||||
}
|
||||
|
||||
if err := b.loadWorkflows(ctx); err != nil {
|
||||
if err := b.loadWorkflows(); err != nil {
|
||||
return 1
|
||||
}
|
||||
if err := b.loadPlugins(); err != nil {
|
||||
@@ -425,7 +421,7 @@ func Run() int { //nolint:cyclop,funlen // the composition root's setup sequence
|
||||
return 1
|
||||
}
|
||||
|
||||
if err := b.registerTools(ctx); err != nil {
|
||||
if err := b.registerTools(); err != nil {
|
||||
return 1
|
||||
}
|
||||
b.registerStandaloneTools()
|
||||
@@ -441,7 +437,7 @@ func Run() int { //nolint:cyclop,funlen // the composition root's setup sequence
|
||||
// wireConfigSurfaces attaches the dashboard's configuration read path and
|
||||
// the reload plumbing behind it. The write handlers (PATCH /api/config, the
|
||||
// per-repository field update, per-row reset) are descoped for the UI
|
||||
// process (archie-core-ymut): the daemon still owns the validate-persist-
|
||||
// process: the daemon still owns the validate-persist-
|
||||
// publish policy, but no HTTP route reaches it -- editing is config.toml
|
||||
// plus reload -- so only the snapshot publication and the override list the
|
||||
// renderer needs stay wired.
|
||||
@@ -453,11 +449,10 @@ func (b *boot) wireConfigSurfaces(ctx context.Context, cfgPath, overlayPath stri
|
||||
b.publishConfigSnapshot(ctx)
|
||||
}
|
||||
|
||||
// persistEvents drains the bus until it closes, giving each event an ID
|
||||
// from the store. The store is the only fan-out point (docs/architecture/
|
||||
// migration-decisions.md, "Dashboard live event delivery"): the UI process
|
||||
// reads the same table through its event pump, so the daemon's job is
|
||||
// persistence, not delivery.
|
||||
// persistEvents drains the bus until it closes, giving each event an ID from
|
||||
// the store. The store is the only fan-out point: the UI process reads the same
|
||||
// table through its event pump, so the daemon's job is persistence, not
|
||||
// delivery.
|
||||
//
|
||||
// The insert deliberately outlives ctx: this loop ends when the bus closes,
|
||||
// which is part of shutdown, and the last events of a run are exactly the
|
||||
@@ -614,7 +609,7 @@ func (a chatTaskControllerAdapter) CancelChatTask(ctx context.Context, taskID in
|
||||
// An operator declining work lands in the same state whichever surface
|
||||
// they used, through the one cancel path: the store records the
|
||||
// cancellation -- every non-terminal step of the current attempt plus the
|
||||
// execution's own move (docs/prds/execution-tree-state-machine.md) -- and
|
||||
// execution's own move -- and
|
||||
// this write is what a late worker's next step write fails against. This
|
||||
// used to record StatusRejected while the dashboard recorded
|
||||
// StatusClosedWontDo, so the same decision showed up as two different
|
||||
@@ -653,7 +648,7 @@ func (a chatTaskLogReaderAdapter) ReadChatTaskLogs(
|
||||
// tasks, and tasks with no identity (forge-sourced) are not
|
||||
// readable through a chat tool at all — they belong to the daemon,
|
||||
// not a particular identity. "The empty string MUST NOT retain
|
||||
// special meaning" (docs/architecture/identity.md).
|
||||
// special meaning".
|
||||
if task.Identity != identity {
|
||||
return gateway.ChatTaskLogResult{}, fmt.Errorf("task %d belongs to %q, not %q", taskID, task.Identity, identity)
|
||||
}
|
||||
@@ -856,12 +851,11 @@ func subscribeAgentEvents(nc *natsio.Conn, bus *events.Bus, log *slog.Logger) (u
|
||||
}, nil
|
||||
}
|
||||
|
||||
// registerTaskRPCServers subscribes the forgerpc/worktreerpc handlers on nc
|
||||
// so an archie-agent container (which holds no forge token, or push
|
||||
// credential) can proxy those operations back to archied. The returned func
|
||||
// unsubscribes all of them. The agent's store calls are NOT proxied here: they
|
||||
// go over gRPC to the State Store (docs/prds/state-store-contract.md §12 step
|
||||
// 4), so the legacy NATS storerpc registration is deleted.
|
||||
// registerTaskRPCServers subscribes the forgerpc/worktreerpc handlers on nc so
|
||||
// an archie-agent container (which holds no forge token, or push credential)
|
||||
// can proxy those operations back to archied. The returned func unsubscribes
|
||||
// all of them. The agent's store calls are NOT proxied here: they go over gRPC
|
||||
// to the State Store, so the legacy NATS storerpc registration is deleted.
|
||||
//
|
||||
// Forge and worktree are identity-scoped: the root servers answer the root
|
||||
// (identity-less) subjects for single-identity deployments and root-owned
|
||||
@@ -941,10 +935,9 @@ func configuredNATSToken(cfg config.NATSConfig, getenv func(string) string) (str
|
||||
return token, nil
|
||||
}
|
||||
|
||||
// updateReportPath is where the update watchdog leaves the phase-2 outcome
|
||||
// of an update for this identity to relay on its next launch. The identity is
|
||||
// hashed so multiple identities sharing one daemon (see
|
||||
// docs/architecture/identity.md) never collide.
|
||||
// updateReportPath is where the update watchdog leaves the phase-2 outcome of
|
||||
// an update for this identity to relay on its next launch. The identity is
|
||||
// hashed so multiple identities sharing one daemon never collide.
|
||||
func updateReportPath(workDir, identity string) string {
|
||||
identityHash := sha256.Sum256([]byte(identity))
|
||||
return filepath.Join(
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
// from: the configuration it was built with and the manifest id it registered
|
||||
// under. A live tool-settings change diffs the stored server set against this
|
||||
// record, so a server that did not change is left running and untouched
|
||||
// (archie-core-zfb0.3).
|
||||
type appliedMCPServer struct {
|
||||
server config.MCPServer
|
||||
id string
|
||||
|
||||
@@ -35,7 +35,7 @@ const (
|
||||
// drop a file beside a running daemon and have it take effect without a
|
||||
// restart. Yaegi cannot unload an interpreter, so a removed file's code keeps
|
||||
// running and the reconciler reports it through apply status until the process
|
||||
// restarts (docs/prds/plugin-settings-live.md).
|
||||
// restarts.
|
||||
//
|
||||
// Files are content-hashed, so a tick loads only what appeared or changed: the
|
||||
// boot load's files are seeded as already loaded. A file whose load fails is
|
||||
@@ -170,7 +170,6 @@ func (r *pluginReconciler) reconcile(ctx context.Context) error {
|
||||
// it re-resolves provider credentials, so a provider disabled at boot for
|
||||
// an unresolvable engine is re-resolved on the first tick that finds it,
|
||||
// and a changed directory retargets the next tick without a restart
|
||||
// (docs/prds/plugin-settings-live.md, "Triggers").
|
||||
if r.relayer != nil {
|
||||
if err := r.relayer(ctx); err != nil {
|
||||
problems = append(problems, fmt.Errorf("re-resolve provider credentials: %w", err))
|
||||
|
||||
@@ -27,7 +27,7 @@ import (
|
||||
//
|
||||
// The probes read the daemon's state directly rather than through a
|
||||
// webui.Server: the daemon serves /health/detailed on its own listener and
|
||||
// has served no dashboard since the UI process cutover (archie-core-ml30).
|
||||
// has served no dashboard since the UI process cutover.
|
||||
func (b *boot) setupReadinessProbes() {
|
||||
cfg := b.cfg
|
||||
probes := []health.Probe{
|
||||
@@ -38,8 +38,7 @@ func (b *boot) setupReadinessProbes() {
|
||||
// The daemon no longer runs a chat channel, so it cannot observe one's
|
||||
// lifecycle; channel health is the Messaging Service's own probe. What
|
||||
// this process depends on is the Gateway answering, so that is what it
|
||||
// reports (docs/prds/ui-service-boundary.md, "Listen, authentication,
|
||||
// and readiness").
|
||||
// reports.
|
||||
readiness.NewContractProbe("gateway", time.Duration(cfg.Health.DependencyTimeout), func(ctx context.Context) error {
|
||||
return pingChat(ctx, b.chat)
|
||||
}),
|
||||
|
||||
@@ -109,8 +109,7 @@ var reloadableFields = map[string]bool{
|
||||
"Repos": true,
|
||||
// Per-task snapshot: ForTask carries these into every dispatched
|
||||
// TaskContext (config.go ForTask), built fresh from d.Cfg.Get() at
|
||||
// dispatch. Pinned by TestReloadableFieldsCoverForTaskSnapshot so a
|
||||
// field added to ForTask cannot silently drift out of this list.
|
||||
// dispatch.
|
||||
"DiffCapLines": true,
|
||||
"Budgets": true,
|
||||
"Dispatch": true,
|
||||
@@ -131,17 +130,12 @@ var reloadableFields = map[string]bool{
|
||||
"BotEmail": true,
|
||||
// cfg.Label additionally feeds IssuesWithLabel per poll cycle
|
||||
// (daemon.go:359,390) and cfg.BotUser feeds AssignedIssues (:364,377).
|
||||
// Label is not carried by ForTask, so it is pinned by hand in
|
||||
// TestReloadableFieldsCoverForTaskSnapshot.
|
||||
"Label": true,
|
||||
"BotUser": true,
|
||||
// MaxRetries has two consumers, both re-reading it: the webui
|
||||
// maxRetriesFor handler (api_tasks.go:380,383) reads it per request, and
|
||||
// ForTask carries it into every dispatched TaskConfig, where the
|
||||
// container's remediation round cap reads it (StageRemediationRoundCap).
|
||||
// The per-task half of this list is pinned mechanically by
|
||||
// TestReloadableFieldsCoverForTaskSnapshot; the webui-only entry is pinned
|
||||
// by TestChangedNonReloadableFields.
|
||||
// MaxRetries has two consumers, both re-reading it: the webui maxRetriesFor
|
||||
// handler (api_tasks.go:380,383) reads it per request, and ForTask carries
|
||||
// it into every dispatched TaskConfig, where the container's remediation
|
||||
// round cap reads it (StageRemediationRoundCap).
|
||||
"MaxRetries": true,
|
||||
// Tools.Policy (MaxResultChars/SpillDir) is carried into TaskConfig by
|
||||
// ForTask (config.go) and applied fresh per dispatch via
|
||||
@@ -149,24 +143,6 @@ var reloadableFields = map[string]bool{
|
||||
"ToolPolicy": true,
|
||||
}
|
||||
|
||||
// reloadableSubFields are sub-fields of structs that are otherwise
|
||||
// startup-built. VolumeTTL is re-read per cycle in cleanupExpiredStorage;
|
||||
// Profiles is resolved fresh per dispatch (daemon.configFor ->
|
||||
// Containers.Profile, called from pinTaskProfile) and is also its own
|
||||
// live-applying control-plane resource (AgentProfileKind), never captured at
|
||||
// container-pool construction -- docs/prds/external-agent-harness.md
|
||||
// "Selection": a Kit profile applies without a restart. Credentials is the
|
||||
// same shape one layer down: kitrun.Launcher reads Config.Get().Containers.
|
||||
// Credentials fresh on every Launch (CredentialBindingsKind), never a slice
|
||||
// captured once when the launcher was built. Image, MaxConcurrency, MaxUptime,
|
||||
// PullPolicy and Network are re-read per acquire by the container pool and
|
||||
// MaxConcurrency also resizes the running dispatcher on publish
|
||||
// (archie-core-zfb0.2), so a reload applies them without a restart.
|
||||
// RegistryAuth stays frozen in the startup-built pool: it is file-owned and
|
||||
// never part of the container-runtime-policies document, so a changed value
|
||||
// must warn requires-restart. Forge.Host is carried into TaskContext by ForTask
|
||||
// (display/link building only); the forge client itself is startup-built, so
|
||||
// Type/Token/TokenEnv stay requires-restart.
|
||||
var reloadableSubFields = map[string]map[string]bool{
|
||||
"Containers": {
|
||||
"VolumeTTL": true, "Profiles": true, "Credentials": true,
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
//
|
||||
// The protocol client and the heartbeat sampler live in internal/sdnotify
|
||||
// because archie-messaging, a separate process that cannot import this
|
||||
// package, is the next process that must be able to announce itself
|
||||
// (archie-core-g5g8). What stays here is what is the daemon's own: which
|
||||
// package, is the next process that must be able to announce itself.
|
||||
// What stays here is what is the daemon's own: which
|
||||
// marker counts as progress (daemon.LastPollAt) and how long the loop may go
|
||||
// without beginning a poll pass.
|
||||
//
|
||||
@@ -30,7 +30,7 @@ import (
|
||||
// announceReady tells systemd the daemon has finished starting. It is called at
|
||||
// the moment a process declares itself serving: the daemon's run loop (next to
|
||||
// healthSurface.markServing), and the serve steps of archie-gateway and
|
||||
// archie-state-store (archie-core-1174), which have health surfaces of their
|
||||
// archie-state-store, which have health surfaces of their
|
||||
// own and would otherwise hang a Type=notify unit until TimeoutStartSec while
|
||||
// perfectly healthy.
|
||||
func (b *boot) announceReady() {
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
// process inputs into RunStateStore, which serves the task and event-capture
|
||||
// stores from Postgres, registers every StateStore gRPC handler (the same service .4.2 serves
|
||||
// in-process on the daemon), and shuts down cleanly on ctx cancellation.
|
||||
//
|
||||
// See docs/prds/state-store-contract.md (rev. 2c) -- the single authoritative
|
||||
// design surface -- and in particular §5 (binary layout), §9 (transport
|
||||
// security boundary) and §11 (the store service owns its own DB lifecycle).
|
||||
package archied
|
||||
|
||||
import (
|
||||
@@ -57,7 +53,6 @@ type StateStoreOptions struct {
|
||||
// Listen is the gRPC listen address. Loopback binds (127.0.0.1, ::1,
|
||||
// localhost) serve insecure with no token; any non-loopback address
|
||||
// requires a non-empty token (or TLS), else the process fails closed
|
||||
// (state-store-contract.md §9).
|
||||
Listen string
|
||||
// Token is the bearer token the State Store server validates for a
|
||||
// non-loopback listener. Empty falls back to [services.state].target_token.
|
||||
@@ -99,8 +94,8 @@ func RunStateStore(ctx context.Context, options StateStoreOptions) error { //nol
|
||||
}
|
||||
// The resumable default org/workspace upgrade runs before this process
|
||||
// serves anything: the State Store refuses scoped calls until its upgrade
|
||||
// has finished, rather than serving records with no org
|
||||
// (docs/prds/orgs-and-access.md, "Upgrading existing installs"). A store
|
||||
// has finished, rather than serving records with no org.
|
||||
// A store
|
||||
// without the upgrader is one that owns no tenant boundary yet, so the
|
||||
// absence degrades to "no upgrade" rather than aborting boot.
|
||||
if upgrader, ok := b.st.(org.Upgrader); ok {
|
||||
@@ -150,8 +145,8 @@ func RunStateStore(ctx context.Context, options StateStoreOptions) error { //nol
|
||||
// Boot is over and every listener this process serves is bound: the gRPC
|
||||
// contract below and, when -ready-addr asked for one, the readiness HTTP
|
||||
// surface. systemd's READY=1 asserts the same fact, so the announcement
|
||||
// goes out here rather than from a second notion of "started"
|
||||
// (archie-core-1174). Not earlier: a readiness surface that fails to bind
|
||||
// goes out here rather than from a second notion of "started".
|
||||
// Not earlier: a readiness surface that fails to bind
|
||||
// fails the boot, and READY must not precede it. Not later: Serve begins
|
||||
// accepting the moment it is called.
|
||||
b.announceReady()
|
||||
@@ -161,14 +156,13 @@ func RunStateStore(ctx context.Context, options StateStoreOptions) error { //nol
|
||||
return serveStateStore(ctx, listener, deps, opts)
|
||||
}
|
||||
|
||||
// seedAndValidatePolicies seeds the shipped role policies for every org
|
||||
// that lacks them, grants the agent identities their org's shipped developer
|
||||
// role, and re-validates every stored policy this process serves
|
||||
// (docs/prds/orgs-and-access.md, "Storing and changing policies" and
|
||||
// "Roles"). An invalid org, workspace or object policy is logged here and
|
||||
// named as a problem by the engines the consumers build; an invalid instance
|
||||
// policy fails this boot -- the store stops serving until it is fixed. A
|
||||
// store without the access surfaces degrades: there is no chain to seed.
|
||||
// seedAndValidatePolicies seeds the shipped role policies for every org that
|
||||
// lacks them, grants the agent identities their org's shipped developer role,
|
||||
// and re-validates every stored policy this process serves. An invalid org,
|
||||
// workspace or object policy is logged here and named as a problem by the
|
||||
// engines the consumers build; an invalid instance policy fails this boot --
|
||||
// the store stops serving until it is fixed. A store without the access
|
||||
// surfaces degrades: there is no chain to seed.
|
||||
func (b *boot) seedAndValidatePolicies(ctx context.Context) error {
|
||||
policies, ok := b.st.(access.PolicyStore)
|
||||
if !ok {
|
||||
@@ -210,8 +204,7 @@ func (b *boot) seedAndValidatePolicies(ctx context.Context) error {
|
||||
// reportUnseededResources logs every kind ImportConfig could not seed.
|
||||
//
|
||||
// Reported, not fatal: a stale TOML value in a setting the database owns must
|
||||
// not stop this process from starting (docs/prds/runtime-control-plane.md,
|
||||
// "Bootstrap, migration, and recovery"). The kind stays ABSENT rather than
|
||||
// not stop this process from starting. The kind stays ABSENT rather than
|
||||
// half-written, so the file document's value is the one in effect for every
|
||||
// reader -- the layering leaves a kind with no stored value alone
|
||||
// (controlplane.resourceReader) -- and the operator's fix is still the file.
|
||||
@@ -237,10 +230,6 @@ func (b *boot) reportUnseededResources(skipped []controlplane.SeedSkip) {
|
||||
// registers before it compiles one, so within one build a definition this
|
||||
// server admits is compilable there; a skewed deploy is only fixed by a
|
||||
// matching deploy.
|
||||
//
|
||||
// It is separate from RunStateStore so that function stays within its
|
||||
// complexity budget, and step_vocabulary_test.go pins both the call to
|
||||
// stepVocabulary below and RunStateStore's call to this function.
|
||||
func openStateStoreControlPlane(resources controlplane.ResourceStore) (*controlplane.Server, error) {
|
||||
steps, err := stepVocabulary()
|
||||
if err != nil {
|
||||
@@ -317,7 +306,7 @@ func (b *boot) stateStoreDeps(grants *staterpc.TaskGrants) staterpc.Deps {
|
||||
}
|
||||
// Task logs live in the state directory, which this process owns, and the
|
||||
// dashboard process owns no such directory -- so this is where a task-log
|
||||
// read is served from (docs/prds/ui-service-boundary.md). The reader is
|
||||
// read is served from. The reader is
|
||||
// the daemon's own registry over the configured state_dir.
|
||||
//
|
||||
// The nil check is on the registry, not on the interface it is assigned
|
||||
@@ -342,7 +331,7 @@ func (b *boot) stateStoreDeps(grants *staterpc.TaskGrants) staterpc.Deps {
|
||||
deps.Sources = b.eda
|
||||
deps.MappingMatches = b.eda
|
||||
// HarnessSecrets rides the same encrypted-at-rest store as source
|
||||
// webhook secrets (docs/prds/binding-secret-encryption.md), under its
|
||||
// webhook secrets, under its
|
||||
// own domain separator (bindingcipher.HarnessSecretDomain).
|
||||
deps.HarnessSecrets = b.eda
|
||||
}
|
||||
@@ -391,7 +380,7 @@ func (b *boot) executionDeps(deps *staterpc.Deps) {
|
||||
}
|
||||
|
||||
// accessDeps wires the policy chain and its denial records from the same
|
||||
// store (docs/prds/orgs-and-access.md). A store without them -- one that owns
|
||||
// store. A store without them -- one that owns
|
||||
// no tenant boundary yet -- degrades the access RPCs rather than failing the
|
||||
// boot, the same pattern the other optional surfaces use.
|
||||
func (b *boot) accessDeps(deps *staterpc.Deps) {
|
||||
@@ -468,7 +457,7 @@ func (b *boot) startOptionalSurfaces(ctx context.Context, options StateStoreOpti
|
||||
return nil
|
||||
}
|
||||
|
||||
// stateStoreServerOpts applies the transport security boundary (§9): a
|
||||
// stateStoreServerOpts applies the transport security boundary: a
|
||||
// loopback listener is served insecure with no token; any non-loopback
|
||||
// address requires a bearer token, else the process fails closed. It cannot
|
||||
// enforce TLS/mTLS (an operator decision), so it narrows the non-loopback
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
// composeStateStoreClient dials the State Store gRPC service the daemon's own
|
||||
// capture/mapping/binding consumers call. Token resolution is the daemon's
|
||||
// (it owns the config keys and the secret registry); the dial itself and the
|
||||
// fail-closed non-loopback rule (§9) belong to the transport, so they come
|
||||
// fail-closed non-loopback rule belong to the transport, so they come
|
||||
// from staterpc.Dial.
|
||||
func composeStateStoreClient(services config.Services, secrets *secret.Registry) (*staterpc.Client, func(), error) {
|
||||
target, err := services.RequireTarget(config.ServiceNameState)
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// fails closed: a stored setting that will not validate stops archied
|
||||
// starting, and the in-band remedy -- replaying an earlier revision while the
|
||||
// State Store is up -- is unavailable in exactly the case that needs it
|
||||
// (docs/architecture/safe-change-and-recovery.md).
|
||||
//
|
||||
// Every operation but import works on the PostgreSQL database database_url
|
||||
// names (state_store_recovery_postgres.go). The ones that write refuse while a
|
||||
|
||||
@@ -40,14 +40,6 @@ func newToolCallProjectingTaskStore(inner storecontract.TaskStore, toolCalls too
|
||||
return &toolCallProjectingTaskStore{TaskStore: inner, toolCalls: toolCalls, log: log}
|
||||
}
|
||||
|
||||
// toolCallProjectionFailures reports how many tool_call projections have been
|
||||
// dropped since this process started. Named and exported to the test surface
|
||||
// rather than buried in a log field alone: a silent swallow is the bug this
|
||||
// decorator exists not to have.
|
||||
func (s *toolCallProjectingTaskStore) toolCallProjectionFailures() int64 {
|
||||
return s.projectionFailures.Load()
|
||||
}
|
||||
|
||||
func (s *toolCallProjectingTaskStore) InsertEvent(ctx context.Context, e events.Event) (int64, error) {
|
||||
id, err := s.TaskStore.InsertEvent(ctx, e)
|
||||
if err != nil || e.Kind != events.KindToolCall {
|
||||
|
||||
@@ -19,11 +19,6 @@ import (
|
||||
// definition registers no vocabulary and cannot be failed by one, which is why
|
||||
// the gateway root and internal/app/archiemessaging are not here.
|
||||
//
|
||||
// It is a named function so that step_vocabulary_test.go can fail if a root
|
||||
// stops resolving the shipped stages, or hands a constructor a manager other
|
||||
// than the one this returns; the roots themselves open a database and dial
|
||||
// gRPC, so the test asserts their wiring by parsing their bodies.
|
||||
//
|
||||
// Agreement is within one build: the State Store and archie-agent are
|
||||
// separately deployed binaries, so a State Store built from newer source than
|
||||
// the agent it dispatches to can still disagree, and only a matching deploy
|
||||
@@ -66,7 +61,7 @@ func (b *boot) openDaemonWorkflowDefinitions() error {
|
||||
// two calls owe each other is a property of the pair, not of that sequence: the
|
||||
// definitions client wraps the control-plane transport the adapter dials, so it
|
||||
// cannot be built first, and buildDaemon captures the client, so it cannot be
|
||||
// built later. step_vocabulary_test.go pins exactly that order here.
|
||||
// built later.
|
||||
//
|
||||
// The gateway root calls openStateStoreAdapter directly and stops there; the
|
||||
// daemon-only half stays out of that function for the reason above it.
|
||||
|
||||
@@ -19,7 +19,7 @@ const updateReportPollInterval = 2 * time.Second
|
||||
// restarts archied and leaves its verdict in a file on archied's host, so
|
||||
// only archied can read it. It previously ran inside the dashboard's own
|
||||
// Run, which put a host-local file read in the process that is moving off
|
||||
// the host (archie-core-8cda.5.4). The report reaches an operator the same
|
||||
// the host. The report reaches an operator the same
|
||||
// way it always did, as an event -- persisted with every other event and
|
||||
// delivered to whichever dashboard is watching.
|
||||
//
|
||||
|
||||
@@ -33,7 +33,7 @@ func channelDescriptors(instances []*channelInstance) []status.Descriptor {
|
||||
// reloadable reports whether this channel can re-read its configuration. It is
|
||||
// the single source for both the capability a descriptor declares and the action
|
||||
// a reload performs; deriving them separately is how a dashboard ends up offering
|
||||
// a button that reports success and changes nothing (archie-core-np7l).
|
||||
// a button that reports success and changes nothing.
|
||||
func reloadable(instance *channelInstance) bool {
|
||||
gateway, ok := instance.current().(*telegram.Gateway)
|
||||
return ok && gateway.Reload != nil
|
||||
@@ -72,8 +72,8 @@ func (s *Service) ReloadChannel(_ context.Context, id string) error {
|
||||
//
|
||||
// Before this, Start handed every channel an empty channels.Lifecycle{}, so
|
||||
// nothing recorded starting, running or failed anywhere and
|
||||
// internal/channels/status.Manager had no production writer at all
|
||||
// (archie-core-8cda.6.8). The channels have always reported: all three call
|
||||
// internal/channels/status.Manager had no production writer at all.
|
||||
// The channels have always reported: all three call
|
||||
// ReportStarting and ReportRunning on whichever lifecycle they are handed.
|
||||
func (s *Service) lifecycleFor(id string) channels.Lifecycle {
|
||||
return channels.Lifecycle{
|
||||
|
||||
@@ -310,11 +310,7 @@ func (s *Service) Start(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// Every configured channel has been handed its lifetime and the service
|
||||
// blocks here serving them. systemd's READY=1 asserts the same fact this
|
||||
// line has just established, so the announcement goes out here rather than
|
||||
// from a second notion of "started" (the convention archie-core-1174 set
|
||||
// for the daemon, the Gateway and the State Store; archie-core-g5g8 is this
|
||||
// process joining them). Not earlier: a channel whose configuration is
|
||||
// blocks here serving them. Not earlier: a channel whose configuration is
|
||||
// invalid fails composition, above, and READY must not precede it. Not
|
||||
// later: a unit whose TimeoutStartSec expires first would restart a healthy
|
||||
// process. Nothing is consumed until the unit says Type=notify, so this is
|
||||
|
||||
@@ -24,8 +24,7 @@ type ResolvedConfig struct {
|
||||
// WorkDir, BotUser and HealthURL are not channel transport settings. They
|
||||
// locate this identity's release-announcement and update-report state
|
||||
// files, and give the update installer the daemon health endpoint to poll
|
||||
// after it applies one (docs/architecture/migration-decisions.md, "Telegram
|
||||
// operator surface after extraction").
|
||||
// after it applies one.
|
||||
WorkDir string
|
||||
BotUser string
|
||||
HealthURL string
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
// channel connections (Telegram, email, webhook) served against a Gateway running
|
||||
// over its gRPC contract.
|
||||
//
|
||||
// docs/prds/messaging-service-boundary.md is the authority. The Messaging Service
|
||||
// owns channel persistent connections and dispatches turns directly to Gateway's
|
||||
// ChatContract over gRPC.
|
||||
// The Messaging Service owns channel persistent connections and dispatches
|
||||
// turns directly to Gateway's ChatContract over gRPC.
|
||||
package archiemessaging
|
||||
|
||||
import (
|
||||
|
||||
@@ -25,7 +25,7 @@ type chatSettingsSource interface {
|
||||
// interval is the cadence every process already reports at, the messaging
|
||||
// process has no other control-plane watch to share a reconnect ladder with,
|
||||
// and a stored document that cannot be read must leave the running channels
|
||||
// alone (docs/prds/plugin-settings-live.md).
|
||||
// alone.
|
||||
func (s *Service) reconcileLoop(ctx context.Context) {
|
||||
ticker := time.NewTicker(s.reconcileInterval)
|
||||
defer ticker.Stop()
|
||||
@@ -117,8 +117,7 @@ func resolveChatSecrets(base ResolvedConfig, layered config.ChatConfig) (Resolve
|
||||
// The composed set and the listen addresses are fixed for the life of the
|
||||
// process. Enabling or disabling a channel and rebinding a listen address are
|
||||
// process bindings; the change is refused and reported for a restart instead of
|
||||
// applied (docs/prds/runtime-control-plane.md, "Some changes require a
|
||||
// restart").
|
||||
// applied.
|
||||
func (s *Service) applyChannelSettings(next ResolvedConfig) (bool, error) {
|
||||
current := s.currentConfig()
|
||||
effective, outstanding := pinProcessBindings(current, next)
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
// The supervisor is per channel rather than one loop over every channel
|
||||
// because a channel-settings change must restart exactly the channel whose
|
||||
// settings changed: cancelling one run context stops one channel and leaves the
|
||||
// rest serving (archie-core-zfb0.4).
|
||||
// rest serving.
|
||||
func (s *Service) runChannel(ctx context.Context, c *channelInstance) {
|
||||
defer s.wg.Done()
|
||||
for {
|
||||
@@ -77,7 +77,6 @@ func (s *Service) runChannel(ctx context.Context, c *channelInstance) {
|
||||
// restartChannel stops the running channel id and starts a replacement built
|
||||
// from next. The replacement is built before the running channel is touched, so
|
||||
// a configuration this build cannot run leaves the running channel serving
|
||||
// (the validate-before-switch rule in docs/prds/runtime-control-plane.md).
|
||||
//
|
||||
// A channel that is not currently supervised is not restarted: it already
|
||||
// stopped on its own, and resurrecting it here would race that exit. The caller
|
||||
|
||||
@@ -16,12 +16,8 @@ import (
|
||||
)
|
||||
|
||||
// configureTelegram wires the operator seams telegram.Gateway leaves to its
|
||||
// composition root. Which process may satisfy each one is settled in
|
||||
// docs/architecture/migration-decisions.md ("Telegram operator surface after
|
||||
// extraction"); notably ReleaseAnnouncements and Dangerous stay nil, because
|
||||
// nothing this process can observe would make them true. RunningVersions is
|
||||
// supplied here from this process's own build stamp; see
|
||||
// messagingRunningVersions.
|
||||
// composition root. RunningVersions is supplied here from this process's own
|
||||
// build stamp; see messagingRunningVersions.
|
||||
func configureTelegram(ctx context.Context, g *telegram.Gateway, cfg ResolvedConfig, chat messaging.ChatContract, log *slog.Logger) {
|
||||
g.Version = gatewayVersionReporter(ctx, chat, cfg.Options.DependencyTimeout)
|
||||
g.SetShowToolCalls(cfg.ShowToolCalls)
|
||||
@@ -49,7 +45,6 @@ func configureTelegram(ctx context.Context, g *telegram.Gateway, cfg ResolvedCon
|
||||
// from, which Verify reads as drift rather than false success. Reading the
|
||||
// version from the Gateway instead would report a different process's stamp,
|
||||
// which is the failure mode the check exists to catch (see
|
||||
// docs/architecture/migration-decisions.md).
|
||||
//
|
||||
// The agent is deliberately absent: every archie-agent process is task-scoped
|
||||
// and observed only through daemon.AgentStatus, which this process does not
|
||||
@@ -131,10 +126,9 @@ func telegramReloader(o Options, log *slog.Logger) func(*telegram.Gateway) error
|
||||
}
|
||||
|
||||
// identityStatePath names a per-identity state file under workDir. The identity
|
||||
// is hashed so several identities sharing one work directory (see
|
||||
// docs/architecture/identity.md) never collide. The scheme is the daemon's,
|
||||
// unchanged: a different path would replay every release announcement the
|
||||
// operator has already been shown.
|
||||
// is hashed so several identities sharing one work directory never collide. The
|
||||
// scheme is the daemon's, unchanged: a different path would replay every
|
||||
// release announcement the operator has already been shown.
|
||||
func identityStatePath(workDir, kind, identity string) string {
|
||||
identityHash := sha256.Sum256([]byte(identity))
|
||||
return filepath.Join(workDir, fmt.Sprintf("%s-%x.json", kind, identityHash[:8]))
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// internal/domain/workflow (routing binding files) and
|
||||
// internal/domain/eda/playbook (EDA playbooks) -- this package only calls the
|
||||
// loaders the daemon runs and formats results; there is deliberately no
|
||||
// second validation path here (per docs/prds/eda-playbook-engine.md).
|
||||
// second validation path here.
|
||||
package archieplaybooks
|
||||
|
||||
import (
|
||||
|
||||
@@ -35,46 +35,18 @@ type deps struct {
|
||||
// configured for it.
|
||||
Login identity.LoginFlow
|
||||
// Access evaluates the policy chain; Principals assembles the request
|
||||
// principal; Denials records refusals
|
||||
// (docs/prds/orgs-and-access.md). Wired together or not at all.
|
||||
// principal; Denials records refusals.
|
||||
// Wired together or not at all.
|
||||
Access access.Authorizer
|
||||
Principals access.PrincipalSource
|
||||
Denials access.DenialStore
|
||||
}
|
||||
|
||||
// compose builds the dashboard server for the UI process. It sets exactly the
|
||||
// fields a contract already carries plus this process's own settings, and
|
||||
// leaves every remaining field at its zero value on purpose: each one is a
|
||||
// daemon-local runtime handle with no contract behind it, and the handlers
|
||||
// already degrade to a documented 501/503/empty response rather than panicking
|
||||
// (docs/prds/ui-service-boundary.md:130-131).
|
||||
//
|
||||
// What is deliberately absent, and which bead fills it:
|
||||
//
|
||||
// - Cfg, LastReload, UpdateConfig, ConfigOverrides, ResetConfig,
|
||||
// UpdateRepoField: the configuration owner stays the daemon. The read
|
||||
// crosses as the snapshot ConfigSource renders; the write routes answer
|
||||
// 503 and the page hides their controls (archie-core-ymut).
|
||||
// - LogFeed, Events, Channels, ReloadChannel, Curators, Memory,
|
||||
// Workflows, WorkRequests, RunningVersions, Chat.Updates,
|
||||
// UpdateReportPath: no contract exists for these yet.
|
||||
// Defining one amends the owning service's contract first
|
||||
// (docs/prds/ui-service-boundary.md:205-207); the route migration is
|
||||
// archie-core-8cda.5.3.
|
||||
// - TaskLogs: wired below from the store client's TaskLogStore contract.
|
||||
// Task log files live in the state directory the State Store owns, so this
|
||||
// process reads one attempt's log over that contract rather than opening
|
||||
// the file itself -- which would only work on a single host and is exactly
|
||||
// what the boundary forbids (archie-core-iaqx).
|
||||
// - Captures, CaptureIntake, CaptureMaxEvents: wired below. From the
|
||||
// cutover change (archie-core-8cda.5.4) this process is the only
|
||||
// listener serving POST /webhooks/capture/{source}: the receiver is a
|
||||
// persistence shim over the State Store contract, and the daemon's
|
||||
// binding-dispatch loop keeps consuming captures from the same store,
|
||||
// so the HTTP front door moved here without moving the owner of work
|
||||
// intake. Mounting it before the daemon's listener was gone would have
|
||||
// given two listeners the same intake authority, which the PRD forbids
|
||||
// (docs/prds/ui-service-boundary.md:30-33).
|
||||
// compose builds the dashboard server for the UI process from contract-backed
|
||||
// dependencies only. Fields left at zero are daemon-local handles; their
|
||||
// handlers answer 501/503 or empty. Config writes stay with the daemon. Task
|
||||
// logs are read through the State Store, and this process is the only listener
|
||||
// for POST /webhooks/capture/{source}.
|
||||
func compose(d deps) *webui.Server {
|
||||
srv := &webui.Server{
|
||||
Store: d.Store,
|
||||
@@ -96,7 +68,6 @@ func compose(d deps) *webui.Server {
|
||||
// Channel lifecycle follows the same split as the config view: the process
|
||||
// hosting the channels publishes, this one reads. Withholding it left
|
||||
// /api/channels answering with nothing while channels were running
|
||||
// (archie-core-8cda.6.8).
|
||||
if channels, ok := d.Store.(storecontract.ChannelStatusStore); ok {
|
||||
srv.Channels = webui.RemoteChannelStatus(channels)
|
||||
}
|
||||
@@ -115,8 +86,8 @@ func compose(d deps) *webui.Server {
|
||||
}
|
||||
// Harness OAuth token sets are a ratified State Store contract, and the
|
||||
// same client already carries them. Withholding it would leave the
|
||||
// harness page answering 503 on a deployment that has the store
|
||||
// (archie-core-egkf.7). The setup terminal itself is not wired here: its
|
||||
// harness page answering 503 on a deployment that has the store.
|
||||
// The setup terminal itself is not wired here: its
|
||||
// implementation owns a container, which this process must not link, so
|
||||
// the route stays a documented 503 until a daemon-side contract exists.
|
||||
if secrets, ok := d.Store.(storecontract.HarnessSecretStore); ok {
|
||||
@@ -130,11 +101,10 @@ func compose(d deps) *webui.Server {
|
||||
}
|
||||
// The task-log read crosses the State Store contract: the files live in
|
||||
// the state directory that process owns, so this one asks for the log
|
||||
// rather than opening a path (docs/prds/ui-service-boundary.md). Withholding
|
||||
// rather than opening a path. Withholding
|
||||
// it would degrade a page that has an owner, and would leave the dashboard
|
||||
// claiming task logging was not enabled -- see wireTaskLogs.
|
||||
// The policy chain: wired together or not at all
|
||||
// (docs/prds/orgs-and-access.md, "Where it lives").
|
||||
srv.Access = d.Access
|
||||
srv.Principals = d.Principals
|
||||
srv.Denials = d.Denials
|
||||
|
||||
@@ -19,13 +19,11 @@ import (
|
||||
//
|
||||
// The projection is an allowlist of the values this process needs --
|
||||
// [services.gateway].{target,target_token}, [services.state].{target,
|
||||
// target_token}, [web].{listen,trust_forwarded_headers} and [capture] (the
|
||||
// receiver this process mounts; archie-core-8cda.5.4). The UI reads the
|
||||
// same file the daemon does because operators already keep the service
|
||||
// endpoints there, but Options has no field for anything else in it: the
|
||||
// daemon's forge credentials, model catalog, workflow routing, NATS settings,
|
||||
// filesystem jail and agent/container settings have nowhere to land
|
||||
// (docs/prds/ui-service-boundary.md:87-89).
|
||||
// target_token}, [web].{listen,trust_forwarded_headers} and [capture]. The UI
|
||||
// reads the same file the daemon does because operators already keep the
|
||||
// service endpoints there, but Options has no field for anything else in it:
|
||||
// the daemon's forge credentials, model catalog, workflow routing, NATS
|
||||
// settings, filesystem jail and agent/container settings have nowhere to land
|
||||
func Resolve(o Options, log *slog.Logger) (Options, error) {
|
||||
if o.Config != "" {
|
||||
cfg, found, err := readProjection(o.Config, o.Overlay, log)
|
||||
@@ -194,11 +192,9 @@ func resolveToken(o Options) (string, error) {
|
||||
return webui.LoadOrCreateToken(o.TokenFile)
|
||||
}
|
||||
|
||||
// validate holds the PRD's security posture (lines 116-118): a loopback
|
||||
// listener may omit the dashboard token, a non-loopback listener requires one
|
||||
// and fails closed without it. Unlike the daemon, which mints a token
|
||||
// silently, this process refuses to start -- an operator who exposed the
|
||||
// dashboard by accident learns about it here rather than from the log.
|
||||
// Unlike the daemon, which mints a token silently, this process refuses to
|
||||
// start -- an operator who exposed the dashboard by accident learns about it
|
||||
// here rather than from the log.
|
||||
func (o Options) validate() error {
|
||||
if o.Gateway.Target == "" {
|
||||
return fmt.Errorf("gateway target is required (-gateway-target or [services.gateway].target)")
|
||||
|
||||
@@ -2,17 +2,13 @@
|
||||
// HTTP surface and the compiled SPA, served against a Gateway and a State
|
||||
// Store running in other processes.
|
||||
//
|
||||
// docs/prds/ui-service-boundary.md is the authority. The two rules that shape
|
||||
// this package are that the UI owns only process-local settings ("HTTP listen
|
||||
// address and read/header/shutdown timeouts; UI asset source or build mode;
|
||||
// UI authentication mode and token reference; Gateway endpoint and credential
|
||||
// reference; State Store endpoint and credential reference; readiness
|
||||
// endpoint and dependency timeout policy"), and that it "must never implement
|
||||
// [configuration] policy by holding or mutating a shared config.Holder".
|
||||
//
|
||||
// It deliberately lives outside internal/app/archied: that package's
|
||||
// dependency graph carries the daemon, forge, container and workflow runtimes
|
||||
// that the PRD's deletion gate forbids the UI process from linking.
|
||||
// The two rules that shape this package are that the UI owns only process-local
|
||||
// settings ("HTTP listen address and read/header/shutdown timeouts; UI asset
|
||||
// source or build mode; UI authentication mode and token reference; Gateway
|
||||
// endpoint and credential reference; State Store endpoint and credential
|
||||
// reference; readiness endpoint and dependency timeout policy"), and that it
|
||||
// "must never implement [configuration] policy by holding or mutating a shared
|
||||
// config.Holder".
|
||||
package archieui
|
||||
|
||||
import (
|
||||
@@ -82,8 +78,8 @@ type Options struct {
|
||||
TrustForwardedHeaders *bool
|
||||
|
||||
// Capture configures the unbound webhook capture receiver this process
|
||||
// mounts on its bypass mux (docs/prds/event-capture-storage.md). At the
|
||||
// cutover (archie-core-8cda.5.4) this process is the only listener
|
||||
// mounts on its bypass mux. At the
|
||||
// cutover this process is the only listener
|
||||
// serving POST /webhooks/capture/{source}: the receiver persists what
|
||||
// arrives through the State Store contract, and the daemon's
|
||||
// binding-dispatch loop consumes captures from the same store, so the
|
||||
@@ -98,11 +94,8 @@ type Options struct {
|
||||
|
||||
// DependencyTimeout bounds each readiness probe's call to a dependency.
|
||||
DependencyTimeout time.Duration
|
||||
// EventPollInterval bounds how stale the dashboard's activity feed can
|
||||
// be. This process owns no event bus, so live activity is a poll of the
|
||||
// State Store's event cursor; see webui.DefaultEventPollInterval and
|
||||
// docs/architecture/migration-decisions.md, "Dashboard live event
|
||||
// delivery".
|
||||
// EventPollInterval bounds how stale the dashboard's activity feed can be.
|
||||
// Live activity is a poll of the State Store's event cursor.
|
||||
EventPollInterval time.Duration
|
||||
// ReadHeaderTimeout and ShutdownTimeout bound the HTTP lifecycle.
|
||||
ReadHeaderTimeout time.Duration
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
// UI is ready when both of its mandatory remote contracts answer within the
|
||||
// dependency timeout; each probe consumes the dependency's own result over
|
||||
// the wire and never inspects its manager, registry or database
|
||||
// (docs/prds/ui-service-boundary.md:126-132).
|
||||
//
|
||||
// The component names match the daemon dashboard's, so the readiness view
|
||||
// reads the same whichever process serves it.
|
||||
|
||||
@@ -111,9 +111,8 @@ func Run(ctx context.Context, options Options) error {
|
||||
|
||||
// Live activity has no in-process bus in this process: the pump reads
|
||||
// events back out of the State Store over the same cursor SSE catch-up
|
||||
// uses. Backgrounded so priming past a large events table cannot delay
|
||||
// the listener (docs/architecture/migration-decisions.md, "Dashboard
|
||||
// live event delivery").
|
||||
// uses. Backgrounded so priming past a large events table cannot delay the
|
||||
// listener.
|
||||
go func() {
|
||||
if err := srv.PumpEvents(ctx, opts.EventPollInterval); err != nil {
|
||||
log.Error("event pump stopped; the activity feed will only show history", "err", err)
|
||||
@@ -156,7 +155,7 @@ func serve(ctx context.Context, listener net.Listener, handler http.Handler, opt
|
||||
// Shutdown returned once the drain deadline elapsed with a request
|
||||
// still in flight. Force-close what is left so shutdown finishes
|
||||
// and the process exits cleanly rather than carrying a deadline
|
||||
// error to the operator as a fatal exit (archie-core-u4xu).
|
||||
// error to the operator as a fatal exit.
|
||||
_ = server.Close()
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -2,18 +2,9 @@ package controlplane
|
||||
|
||||
import "github.com/samcharles93/archie-core/internal/config"
|
||||
|
||||
// AgentProfileKind is the control-plane resource for Kit and image agent
|
||||
// profiles. It exists so a Kit profile applies without a restart
|
||||
// (docs/prds/external-agent-harness.md, "Selection"): [containers].profiles
|
||||
// in config.toml is only its seed, ContainerRuntimePoliciesKind carries every
|
||||
// other container setting and none of this one (config.ContainerConfig.
|
||||
// Profiles is json:"-"), and this resource's own ApplyMode is "live".
|
||||
//
|
||||
// Its document is agentProfile (container_settings.go's snake_case wire
|
||||
// type), not config.AgentProfile directly: that internal type carries no
|
||||
// json tags, so encoding/json would fall back to its Go field names --
|
||||
// "Tools", "Image" -- exactly the defect archie-core-1171 fixed for the rest
|
||||
// of this document family.
|
||||
// AgentProfileKind is the control-plane resource holding agent profiles. Its
|
||||
// document is the snake_case agentProfile wire type, not config.AgentProfile,
|
||||
// which has no json tags.
|
||||
const AgentProfileKind = "agent-profiles"
|
||||
|
||||
func agentProfileDefinition() Definition {
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
|
||||
// The channel-settings DOCUMENT lives in internal/infrastructure/controlplanerpc,
|
||||
// beside the client that projects it, so a process that only reads stored
|
||||
// settings does not link this package's store-backed server and workflow engine
|
||||
// (archie-core-1ng1). These aliases keep the store-backed side reading the same
|
||||
// settings does not link this package's store-backed server and workflow engine.
|
||||
// These aliases keep the store-backed side reading the same
|
||||
// types by the same names it always used, so there is one definition of the
|
||||
// document rather than a copy on each side of the boundary.
|
||||
type (
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
// embeds the Messaging Service's client -- the generic resource read path and
|
||||
// the channel-settings projection -- and adds the resource-specific reads and
|
||||
// watches, which need the workflow and scheduling engines that such a process
|
||||
// already links (archie-core-1ng1).
|
||||
// already links.
|
||||
type Client struct {
|
||||
*controlplanerpc.Client
|
||||
rpc pb.ControlPlaneServiceClient
|
||||
@@ -146,8 +146,8 @@ type AppliedResource struct {
|
||||
}
|
||||
|
||||
// WatchResource streams version updates for any resource kind without
|
||||
// decoding the document. It is the shape the runtime-resource watches read
|
||||
// (archie-core-zfb0.1): keepWatch reconnects on it exactly as it does on a
|
||||
// decoding the document. It is the shape the runtime-resource watches read:
|
||||
// keepWatch reconnects on it exactly as it does on a
|
||||
// typed stream, and the resume point still moves past a document the client
|
||||
// refused to decode -- the store answered with that version, and resuming
|
||||
// before it would re-offer it on every reconnect.
|
||||
|
||||
@@ -15,13 +15,11 @@ import (
|
||||
// directly: that struct's tags belong to the TOML file format, and when it was
|
||||
// the document, encoding/json fell back to its Go field names -- "Image",
|
||||
// "MaxConcurrency", "LegacyEnabled" -- the only Go-cased resource left in the
|
||||
// registry (archie-core-1171). The two durations are config.Duration, which
|
||||
// registry. The two durations are config.Duration, which
|
||||
// already writes the string the file accepts; the leak was the keys only.
|
||||
//
|
||||
// Profiles is deliberately not a field here: config.ContainerConfig.Profiles
|
||||
// is json:"-" (its own resource, AgentProfileKind, applies live where the
|
||||
// rest of this one is restart-required -- docs/prds/external-agent-harness.md
|
||||
// "Selection"), so this document never carries it either.
|
||||
// Profiles is deliberately not a field here: config.ContainerConfig.Profiles is
|
||||
// json:"-", so this document never carries it either.
|
||||
type containerRuntimePolicies struct {
|
||||
Image string `json:"image"`
|
||||
MaxConcurrency int `json:"max_concurrency"`
|
||||
|
||||
@@ -4,7 +4,6 @@ import "github.com/samcharles93/archie-core/internal/config"
|
||||
|
||||
// CredentialBindingsKind is the control-plane resource mapping a Kit
|
||||
// credential@1 service name to an org secret
|
||||
// (docs/prds/external-agent-harness.md, Credentials; docs/prds/orgs-and-access.md).
|
||||
// It exists so a binding applies without a restart, the same reason
|
||||
// AgentProfileKind is its own resource: [containers].credentials in
|
||||
// config.toml is only its seed, and kitrun.Launcher reads the live
|
||||
|
||||
@@ -48,8 +48,8 @@ func operationalDefinitions() []Definition {
|
||||
// ApplyMode is live: the daemon diffs the stored MCP server set against
|
||||
// the running providers -- connecting added servers, disconnecting
|
||||
// removed ones and reconnecting changed ones while leaving unchanged
|
||||
// servers untouched -- and rebuilds the web_fetch and minimax entries
|
||||
// (archie-core-zfb0.3). A changed server whose new engine fails to start
|
||||
// servers untouched -- and rebuilds the web_fetch and minimax entries.
|
||||
// A changed server whose new engine fails to start
|
||||
// is rolled back to the old one, so the refusal is reported rather than
|
||||
// leaving the server down.
|
||||
{Kind: ToolSettingsKind, Title: "Tool and MCP settings", ApplyMode: "live", Document: toolSettings{}, Seed: seedTools, Validate: validateTools},
|
||||
@@ -57,23 +57,20 @@ func operationalDefinitions() []Definition {
|
||||
// and the daemon's reconciliation loads new and changed files without a
|
||||
// restart. A removal cannot unload Yaegi's interpreter, so it stays an
|
||||
// outstanding apply-status problem rather than a restart of the whole kind
|
||||
// (docs/prds/plugin-settings-live.md).
|
||||
{Kind: PluginSettingsKind, Title: "Plugin settings", ApplyMode: "live", Document: pluginSettings{}, Seed: func(cfg config.Config) any {
|
||||
return pluginSettings{cfg.PluginDir, cfg.ModuleDir, cfg.SecretEngineDir, cfg.SkillsDir}
|
||||
}, Validate: validatePluginSettings},
|
||||
// ApplyMode is live: the container pool reads the published config on
|
||||
// every acquire (image, pull policy, network, max uptime, concurrency
|
||||
// cap) and the daemon resizes its running dispatcher after the publish,
|
||||
// so neither a deferred container nor a queued task needs a restart
|
||||
// (archie-core-zfb0.2). RegistryAuth is file-owned and never part of
|
||||
// so neither a deferred container nor a queued task needs a restart.
|
||||
// RegistryAuth is file-owned and never part of
|
||||
// this document, so it stays a boot-resolved value.
|
||||
{Kind: ContainerRuntimePoliciesKind, Title: "Container runtime policies", ApplyMode: "live", Document: containerRuntimePolicies{}, Seed: seedContainerPolicies, Validate: validateContainers, Normalize: normalizeContainerPolicies},
|
||||
}
|
||||
}
|
||||
|
||||
// validatePluginSettings accepts every value, deliberately. The four directories
|
||||
// are free-form operator paths, and that is the decision recorded for
|
||||
// archie-core #1143 rather than a validator nobody has written yet.
|
||||
// validatePluginSettings accepts every value, deliberately.
|
||||
//
|
||||
// Two candidate rules were considered and are refused:
|
||||
//
|
||||
@@ -134,7 +131,7 @@ func validateScheduling(input []byte) error {
|
||||
// leaves the file's label in force, which is what legacy policies
|
||||
// decode with), so a stored label-requiring trigger with no label was
|
||||
// a value the store blessed and boot refused -- the two-layer
|
||||
// disagreement the parity test refuses to allow (archie-core-7pyj).
|
||||
// disagreement the parity test refuses to allow.
|
||||
if workintake.RequiresLabel(policy.Dispatch.Trigger) && (policy.Label == nil || *policy.Label == "") {
|
||||
return fmt.Errorf("label is required when dispatch.trigger is %q (an empty label matches every open issue)", policy.Dispatch.Trigger)
|
||||
}
|
||||
|
||||
@@ -115,13 +115,10 @@ const (
|
||||
// the file document's value stays the one in effect (Client.RuntimeConfig
|
||||
// leaves an absent kind alone), with the fix still in the file. The seed is
|
||||
// retried on the next start of this process, so correcting config.toml re-seeds
|
||||
// it.
|
||||
// docs/prds/runtime-control-plane.md, "Bootstrap, migration, and recovery":
|
||||
// after migration, settings in TOML are ignored and cannot block State Store
|
||||
// startup -- and this import runs on the State Store's startup path. Fail closed
|
||||
// belongs to the process that uses the value: boot.runtimeConfig validates the
|
||||
// effective document and refuses to start archied with a value it cannot run
|
||||
// with, which is what keeps an invalid value from taking effect silently.
|
||||
// it. Fail closed belongs to the process that uses the value:
|
||||
// boot.runtimeConfig validates the effective document and refuses to start
|
||||
// archied with a value it cannot run with, which is what keeps an invalid value
|
||||
// from taking effect silently.
|
||||
func (s *Server) ImportConfig(ctx context.Context, cfg config.Config) (map[string]int64, []SeedSkip, error) {
|
||||
versions := make(map[string]int64, len(s.ordered))
|
||||
var skipped []SeedSkip
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
// workflow's two dials: whether a post-worthiness pass runs before findings are
|
||||
// posted, and whether a human approves the draft before it posts. The file's
|
||||
// [review] section seeds it; the stored document outranks the file from then on
|
||||
// (docs/prds/review-settings-resource.md).
|
||||
const ReviewSettingsKind = "review-settings"
|
||||
|
||||
type reviewSettings struct {
|
||||
|
||||
@@ -34,7 +34,6 @@ import (
|
||||
//
|
||||
// It also returns the version of each kind it read, so the process that
|
||||
// layers them in can report which version it is running
|
||||
// (docs/prds/control-plane-apply-status.md).
|
||||
func (c *Client) RuntimeConfig(ctx context.Context, base config.Config) (config.Config, map[string]int64, error) {
|
||||
return runtimeConfigFrom(ctx, c, base)
|
||||
}
|
||||
@@ -116,8 +115,8 @@ func runtimeConfigFrom(ctx context.Context, reader controlplanerpc.ResourceReade
|
||||
// The stored role assignments own cfg.Models once the store carries a
|
||||
// value, the way the provider layer above owns cfg.Providers: a role
|
||||
// removed from the store is gone from the layered document too. The
|
||||
// runtime-resource watches re-layer over an already-layered base
|
||||
// (archie-core-zfb0.1), so json.Unmarshal's map merge here would
|
||||
// runtime-resource watches re-layer over an already-layered base,
|
||||
// so json.Unmarshal's map merge here would
|
||||
// resurrect a role the store deleted every time any watched kind changed.
|
||||
if err := layerResource(ctx, reader, versions, ModelRoleAssignmentsKind, func(value []byte) error {
|
||||
var roles map[string]string
|
||||
@@ -163,7 +162,7 @@ func runtimeConfigFrom(ctx context.Context, reader controlplanerpc.ResourceReade
|
||||
// review-settings owns the pr-review dials once the store carries a value.
|
||||
// The two fields are assigned individually, not `out.Review = ...`: a field
|
||||
// added to config.Review later keeps the file's value until the stored
|
||||
// document carries it (docs/prds/review-settings-resource.md).
|
||||
// document carries it.
|
||||
if err := layerResource(ctx, reader, versions, ReviewSettingsKind, func(value []byte) error {
|
||||
var settings reviewSettings
|
||||
if err := json.Unmarshal(value, &settings); err != nil {
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
// bareObjectSchema is what a descriptor advertises when its definition names no
|
||||
// document. It is the fallback, not the norm: a descriptor with no properties is
|
||||
// what left the Web UI with nothing to label, describe or format a field with
|
||||
// (archie-core-2xs6).
|
||||
const bareObjectSchema = `{"type":"object"}`
|
||||
|
||||
var timeType = reflect.TypeFor[time.Time]()
|
||||
|
||||
@@ -24,7 +24,7 @@ const projectWriteAttempts = 3
|
||||
|
||||
// WorkflowProjector carries an installed package's workflow contributions
|
||||
// into the org's workflow-definitions resource, the same document an operator
|
||||
// edits on the dashboard (docs/prds/store.md, "Packages"). The readers the
|
||||
// edits on the dashboard. The readers the
|
||||
// daemon holds read that resource per dispatch, so a projected workflow is
|
||||
// usable at the next dispatch and a withdrawn one stops dispatching, without
|
||||
// restarting processes.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package buildinfo carries the release version stamped into every host
|
||||
// binary. The updater asks each installed binary what it is, rather than
|
||||
// trusting one component's word for a whole install whose binaries may have
|
||||
// been replaced by hand (archie-core-k94o).
|
||||
// been replaced by hand.
|
||||
package buildinfo
|
||||
|
||||
import (
|
||||
|
||||
@@ -142,7 +142,6 @@ func (g *Gateway) handleSMTP(ctx context.Context, conn net.Conn) {
|
||||
write(250, "OK: message accepted")
|
||||
return
|
||||
}
|
||||
// Un-dot-stuff: RFC 5321 §4.5.2
|
||||
if strings.HasPrefix(line, "..") {
|
||||
line = line[1:]
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// facts for the dashboard and readiness surfaces. It lives beside the
|
||||
// channels package rather than inside it so UI-process code can hold the
|
||||
// types without linking the plugin contract there -- which references the
|
||||
// gateway runtime (archie-core-8cda.5.6).
|
||||
// gateway runtime.
|
||||
package status
|
||||
|
||||
import "sync"
|
||||
|
||||
@@ -29,11 +29,10 @@ var gatewayCommandSpecs = []commandSpec{
|
||||
{Command: "settings", Description: "Inspect or change runtime settings", Usage: "/settings [list|get <kind>|set <kind> <field>=<value> ...]"},
|
||||
{Command: "cancel", Description: "Cancel a queued or waiting task", Usage: "/cancel [identity=name] <task-id>"},
|
||||
// /approve and /deny are Telegram's own dangerous-command approval surface:
|
||||
// dangerous.go lists the pending commands and the inline buttons decide. The
|
||||
// shared command specs use /approve for task approval instead, and Telegram's
|
||||
// exact-match handler shadows that path, so /help must describe the Telegram
|
||||
// meaning. Reconciling the split is archie-core-ho86; do not copy the shared
|
||||
// task-approval copy here.
|
||||
// dangerous.go lists the pending commands and the inline buttons decide.
|
||||
// The shared command specs use /approve for task approval instead, and
|
||||
// Telegram's exact-match handler shadows that path, so /help must describe
|
||||
// the Telegram meaning.
|
||||
{Command: "approve", Description: "Show pending dangerous commands to approve", Usage: "/approve"},
|
||||
{Command: "deny", Description: "Show pending dangerous commands to deny", Usage: "/deny"},
|
||||
{Command: "start", Description: "Confirm that Archie is running", Usage: "/start"},
|
||||
|
||||
@@ -84,12 +84,6 @@ type liveReply struct {
|
||||
// interval throttles updates; zero renders every change.
|
||||
interval time.Duration
|
||||
|
||||
// mediaWg lets tests (and a future bounded drain, mirroring
|
||||
// abandonAllLive) wait for in-flight Media deliveries. Callers other
|
||||
// than tests must not block on it: Media is fire-and-forget by
|
||||
// contract, same as Delta and ToolCall.
|
||||
mediaWg sync.WaitGroup
|
||||
|
||||
// newMediaSender builds the MediaSender Media delivers through.
|
||||
// Defaults to g.NewMediaSender; tests override it to inject a sender
|
||||
// with fixed Capabilities(), which the real Telegram one can't
|
||||
@@ -414,7 +408,7 @@ func (l *liveReply) Media(ctx context.Context, event messaging.MediaEvent) {
|
||||
return
|
||||
}
|
||||
|
||||
l.mediaWg.Go(func() {
|
||||
go func() {
|
||||
sender := l.newMediaSender(l.b, l.chatID, l.messageThreadID)
|
||||
|
||||
// Checked before attempting delivery, not just on failure: that is
|
||||
@@ -441,7 +435,7 @@ func (l *liveReply) Media(ctx context.Context, event messaging.MediaEvent) {
|
||||
l.g.log.Warn("media delivery failed, falling back to a link",
|
||||
"tool", event.ToolName, "type", event.Attachment.Type, "error", err)
|
||||
l.appendFallbackLine(ctx, event.Attachment)
|
||||
})
|
||||
}()
|
||||
}
|
||||
|
||||
// appendFallbackLine renders att as a visible link in the reply, for a
|
||||
@@ -478,13 +472,6 @@ func (l *liveReply) appendFallbackLine(ctx context.Context, att messaging.MediaA
|
||||
l.requestRender()
|
||||
}
|
||||
|
||||
// waitMedia blocks until every Media delivery started so far has finished.
|
||||
// Tests only: production callers never wait on Media's fire-and-forget
|
||||
// goroutines.
|
||||
func (l *liveReply) waitMedia() {
|
||||
l.mediaWg.Wait()
|
||||
}
|
||||
|
||||
// render writes the current buffer, cursor and all, to the live message.
|
||||
func (l *liveReply) render(ctx context.Context) {
|
||||
l.mu.Lock()
|
||||
|
||||
@@ -115,12 +115,10 @@ func stripInlineMarkdown(s string) string {
|
||||
}
|
||||
|
||||
// stripEmphasis removes paired emphasis delimiters and keeps their content.
|
||||
// Pairing follows CommonMark's flanking rules, so a delimiter that cannot
|
||||
// open or close is ordinary text and stays put. That is what keeps this
|
||||
// project's own vocabulary intact over the wire: snake_case config keys,
|
||||
// dotted paths like config_schema_test.go, and Go pointer types such as
|
||||
// Pairing follows CommonMark's flanking rules, so a delimiter that cannot open
|
||||
// or close is ordinary text and stays put.
|
||||
// *sql.Tx all used to lose characters to a non-greedy `_(.+?)_` that paired
|
||||
// any two markers on a line (archie-core-8x1r).
|
||||
// any two markers on a line.
|
||||
func stripEmphasis(s, marker string) string {
|
||||
var b strings.Builder
|
||||
for i := 0; i < len(s); {
|
||||
@@ -277,7 +275,7 @@ func (p *markdownBlockParser) handleLine(line string) {
|
||||
case p.startsIndentedCode(line):
|
||||
// CommonMark's other code form. Models emit it constantly, and
|
||||
// without this it fell to the paragraph case below, which
|
||||
// space-joins its lines into one run-on line (archie-core-cvu6).
|
||||
// space-joins its lines into one run-on line.
|
||||
p.flush()
|
||||
p.inCode, p.indented, p.codeLang = true, true, ""
|
||||
p.codeLines = []string{stripCodeIndent(line)}
|
||||
@@ -300,7 +298,7 @@ func (p *markdownBlockParser) handleLine(line string) {
|
||||
// said it is a line, so it closes its own block and the next one
|
||||
// hugs it. Line-oriented reports (/status, /tasks) depend on this;
|
||||
// without it every one of their lines soft-joined into one run-on
|
||||
// paragraph (archie-core-8cda.6.10).
|
||||
// paragraph.
|
||||
p.flushList()
|
||||
p.flushQuote()
|
||||
switch {
|
||||
@@ -488,7 +486,7 @@ func (p *markdownBlockParser) flushQuote() {
|
||||
|
||||
// closeCode emits the open code block. The text is passed through verbatim:
|
||||
// code is not prose, and running the emphasis stripper over it turned
|
||||
// *sql.Tx into sql.Tx and ate same-line snake_case pairs (archie-core-8x1r).
|
||||
// *sql.Tx into sql.Tx and ate same-line snake_case pairs.
|
||||
func (p *markdownBlockParser) closeCode() {
|
||||
lines := p.codeLines
|
||||
if p.indented {
|
||||
|
||||
@@ -281,11 +281,7 @@ type telegramTextHandler struct {
|
||||
}
|
||||
|
||||
// telegramTextHandlers is the single source for the commands Telegram answers
|
||||
// locally. Registration reads it, and so does
|
||||
// TestPublishedCommandsMatchExecutableSurface, which proves the published menu
|
||||
// covers the executable surface: a handler added here without a spec in
|
||||
// gatewayCommandSpecs fails that test, so a command cannot become typeable
|
||||
// without becoming discoverable.
|
||||
// locally.
|
||||
var telegramTextHandlers = []telegramTextHandler{
|
||||
{"/status", bot.MatchTypeExact, func(g *Gateway, c messaging.ChatContract) bot.HandlerFunc { return g.statusHandler(c) }},
|
||||
{"/whoami", bot.MatchTypeExact, func(g *Gateway, c messaging.ChatContract) bot.HandlerFunc { return g.whoamiHandler(c) }},
|
||||
|
||||
@@ -178,7 +178,6 @@ func (g *Gateway) handleWebhook(route *RouteConfig) http.HandlerFunc {
|
||||
// empty: consumers read it as a person
|
||||
// (internal/app/archied/chat_identity.go, sessioncurator),
|
||||
// and a route path must never become a user identity
|
||||
// (docs/prds/memory-engine-unification.md criterion 7).
|
||||
Role: messaging.RoleUser,
|
||||
Text: text,
|
||||
},
|
||||
@@ -200,7 +199,7 @@ func (g *Gateway) handleWebhook(route *RouteConfig) http.HandlerFunc {
|
||||
// (chat prose, meant for a human) or 202'd as accepted (indistinguishable
|
||||
// from a delivered event, so the source would never retry it). 429 lets
|
||||
// the source back off and retry, the way internal/webhookguard.RateLimiter's
|
||||
// other callers already respond (archie-core-1173).
|
||||
// other callers already respond.
|
||||
if reply.RateLimited {
|
||||
http.Error(w, "rate limited", http.StatusTooManyRequests)
|
||||
return
|
||||
|
||||
@@ -23,8 +23,8 @@ type ChatFrontEnd struct {
|
||||
// two answers drifted: the daemon's channel status manager counted the inbound
|
||||
// mail gateway, and the dashboard projection published for the extracted UI
|
||||
// process did not, so an email-only deployment read as configured on
|
||||
// /api/channels and unconfigured on the setup checklist at the same time
|
||||
// (GitHub #821). Front-ends are enumerated once here so a front-end added to
|
||||
// /api/channels and unconfigured on the setup checklist at the same time.
|
||||
// Front-ends are enumerated once here so a front-end added to
|
||||
// [chat] cannot be counted by one surface and missed by the other.
|
||||
//
|
||||
// A whitespace-only value is not configured on any front-end: an env var name
|
||||
|
||||
+49
-80
@@ -8,10 +8,7 @@
|
||||
// The forge API token is deliberately not part of the file: it comes from a
|
||||
// configurable env var.
|
||||
//
|
||||
// Per docs/architecture/configuration.md this package is scheduled for
|
||||
// dissolution: its types and methods are to be reassigned to the domains
|
||||
// whose behaviour they describe. Do not add new fields here that a single
|
||||
// domain could own.
|
||||
// Do not add new fields here that a single domain could own.
|
||||
package config
|
||||
|
||||
import (
|
||||
@@ -130,8 +127,6 @@ func (r Repo) ResolvedPreflight() [][]string {
|
||||
}
|
||||
|
||||
// ResolvedTestGlob returns the test-file glob pattern for this repo.
|
||||
// Explicit TestGlob wins; otherwise the ecosystem default; empty
|
||||
// for unknown ecosystems and "custom" (protection no-ops).
|
||||
func (r Repo) ResolvedTestGlob() string {
|
||||
if r.TestGlob != "" {
|
||||
return r.TestGlob
|
||||
@@ -203,15 +198,12 @@ type Forge struct {
|
||||
WebhookAddr string `toml:"webhook_addr" yaml:"webhook_addr"`
|
||||
}
|
||||
|
||||
// Review configures the pr-review workflow (docs/prds/pr-review-agent.md).
|
||||
// Review configures the pr-review workflow.
|
||||
// Both fields are off by default: the pipeline is recall-first, and posts
|
||||
// automatically, unless an operator opts into either dial.
|
||||
type Review struct {
|
||||
// PrecisionGate runs a post-worthiness pass after phase 4 (review) and
|
||||
// before phase 5 (verification): it keeps every concrete, evidenced
|
||||
// defect, drops nitpicks, style and unverifiable claims, and keeps a
|
||||
// finding when unsure. It trades recall for precision and cuts
|
||||
// verification cost by filtering early.
|
||||
// It trades recall for precision and cuts verification cost by filtering
|
||||
// early.
|
||||
PrecisionGate bool `toml:"precision_gate" yaml:"precision_gate"`
|
||||
// ApproveBeforePost ends the pipeline in waiting_human right after
|
||||
// synthesis, before the merge gate runs, so an operator can choose which
|
||||
@@ -395,36 +387,29 @@ type Config struct {
|
||||
Services Services `toml:"services" yaml:"services"`
|
||||
WorkDir string `toml:"work_dir" yaml:"work_dir"`
|
||||
// SkillsDir is an optional path to a shared skills directory
|
||||
// containing .agents/skills/*/SKILL.md files. When set, the
|
||||
// containing */SKILL.md files. When set, the
|
||||
// daemon builds its workflow registry from the skill catalog
|
||||
// (plugin-defined workflows override built-ins). When empty,
|
||||
// only built-in workflows are available. Its skills are also the
|
||||
// store a Kit's agent-skills@1 mounts, read-only, into the harness.
|
||||
SkillsDir string `toml:"skills_dir" yaml:"skills_dir"`
|
||||
// WorkflowRoutingFile is an optional path to a YAML file rebinding
|
||||
// which registered workflow an intake Kind (bug/feature/bootstrap)
|
||||
// prefers -- see docs/prds/eda-playbook-engine.md. When empty, the
|
||||
// built-in bindings (bug->tdd, feature->feasibility,
|
||||
// bootstrap->bootstrap) are used unchanged.
|
||||
// WorkflowRoutingFile is an optional path to a YAML file rebinding which
|
||||
// registered workflow an intake Kind (bug/feature/bootstrap) prefers.
|
||||
WorkflowRoutingFile string `toml:"workflow_routing_file" yaml:"workflow_routing_file"`
|
||||
// WorkflowLabelsFile is an optional path to a YAML file binding forge
|
||||
// issue labels outside the closed bug/feature/bootstrap kind set to
|
||||
// registered workflows (e.g. "security" -> "security-review") -- the
|
||||
// second slice of docs/prds/eda-playbook-engine.md. When empty, only
|
||||
// the kind layer routes by label. A label already owned by the kind
|
||||
// set, or a duplicate binding, is a load failure per the design doc's
|
||||
// collision rule.
|
||||
// WorkflowLabelsFile is an optional path to a YAML file binding forge issue
|
||||
// labels outside the closed bug/feature/bootstrap kind set to registered
|
||||
// workflows (e.g. A label already owned by the kind set, or a duplicate
|
||||
// binding, is a load failure per the design doc's collision rule.
|
||||
WorkflowLabelsFile string `toml:"workflow_labels_file" yaml:"workflow_labels_file"`
|
||||
// PlaybookDirs is an optional list of directories of *.yaml/*.yml
|
||||
// binding files loaded at startup (the third slice of
|
||||
// docs/prds/eda-playbook-engine.md). Each file binds kinds and/or
|
||||
// arbitrary labels to workflow names; the directories are an
|
||||
// additional input to WorkflowRoutingFile and WorkflowLabelsFile,
|
||||
// which remain supported unchanged. A binding key declared by more
|
||||
// than one source -- two files, or two directories -- is a reported
|
||||
// load failure (a collision), not a silent pick-one. When empty, no
|
||||
// playbook directories are loaded. Repo-scoping of playbook dirs is a
|
||||
// separate, later decision and is not attempted here.
|
||||
// PlaybookDirs is an optional list of directories of *.yaml/*.yml binding
|
||||
// files loaded at startup. Each file binds kinds and/or arbitrary labels to
|
||||
// workflow names; the directories are an additional input to
|
||||
// WorkflowRoutingFile and WorkflowLabelsFile, which remain supported
|
||||
// unchanged. A binding key declared by more than one source -- two files,
|
||||
// or two directories -- is a reported load failure (a collision), not a
|
||||
// silent pick-one. When empty, no playbook directories are loaded.
|
||||
// Repo-scoping of playbook dirs is a separate, later decision and is not
|
||||
// attempted here.
|
||||
PlaybookDirs []string `toml:"playbook_dirs" yaml:"playbook_dirs"`
|
||||
// EDAPlaybookDir is an optional path to a directory of rich EDA playbook
|
||||
// documents (*.yaml/*.yml: trigger + ordered actions with CEL `when`
|
||||
@@ -469,19 +454,17 @@ type Config struct {
|
||||
// Label marks issues archie should pick up.
|
||||
Label string `toml:"label" yaml:"label"`
|
||||
BotUser string `toml:"bot_user" yaml:"bot_user"`
|
||||
// Org is this identity's org (docs/prds/orgs-and-access.md). Empty means
|
||||
// Org is this identity's org. Empty means
|
||||
// "default": the org a single-operator install's one identity belongs to.
|
||||
// A credential binding whose Org does not match a run's identity never
|
||||
// resolves for it, regardless of what the identity is granted.
|
||||
Org string `toml:"org" yaml:"org"`
|
||||
// GrantedCredentials names the credential@1 services this identity may
|
||||
// use, by CredentialBinding.Service (docs/prds/external-agent-harness.md,
|
||||
// Organisations: "a harness run ... acts as the workflow's identity").
|
||||
// Empty grants none -- a binding existing is not a grant, the same
|
||||
// fail-closed default the proxy itself already applies to an unbound
|
||||
// required credential. Declared (what a Kit's descriptor asks for) and
|
||||
// granted (this list) are two separate facts; only their intersection
|
||||
// resolves, and neither widens the other.
|
||||
// GrantedCredentials names the credential@1 services this identity may use,
|
||||
// by CredentialBinding.Service. Empty grants none -- a binding existing is
|
||||
// not a grant, the same fail-closed default the proxy itself already
|
||||
// applies to an unbound required credential. Declared (what a Kit's
|
||||
// descriptor asks for) and granted (this list) are two separate facts; only
|
||||
// their intersection resolves, and neither widens the other.
|
||||
GrantedCredentials []string `toml:"granted_credentials" yaml:"granted_credentials"`
|
||||
// BotEmail is the git author email; defaults to the GitHub noreply
|
||||
// address for BotUser.
|
||||
@@ -816,7 +799,7 @@ const (
|
||||
//
|
||||
// An empty Mode resolves from URL: URL set means "external", URL empty means
|
||||
// "embedded". Autonomous workflow handoff always uses NATS; there is no
|
||||
// broker-off execution mode (docs/prds/embedded-nats.md).
|
||||
// broker-off execution mode.
|
||||
type NATSConfig struct {
|
||||
// Mode selects embedded or external. Empty resolves from URL.
|
||||
Mode string `toml:"mode" yaml:"mode"`
|
||||
@@ -828,8 +811,8 @@ type NATSConfig struct {
|
||||
TokenEnv string `toml:"token_env" yaml:"token_env"`
|
||||
}
|
||||
|
||||
// CaptureConfig configures the unbound webhook capture endpoint
|
||||
// (docs/prds/event-capture-storage.md). All fields have defaults; an empty
|
||||
// CaptureConfig configures the unbound webhook capture endpoint.
|
||||
// All fields have defaults; an empty
|
||||
// [capture] section is valid and produces them -- capture is on by default.
|
||||
type CaptureConfig struct {
|
||||
// Retention is how long a captured event is kept before prune-on-write
|
||||
@@ -844,12 +827,11 @@ type CaptureConfig struct {
|
||||
// MaxBodyBytes rejects (413) any single POST body larger than this
|
||||
// before it is read into memory. Zero means the 256 KiB default.
|
||||
MaxBodyBytes int `toml:"max_body_bytes" yaml:"max_body_bytes"`
|
||||
// RatePerSecond and RateBurst configure the per-remote-address token
|
||||
// bucket (webhookguard.RateLimiter) applied before a request's body is
|
||||
// read. Keyed by remote address, not the source path segment, since
|
||||
// that segment is unregistered and attacker-chosen by design -- see
|
||||
// docs/prds/event-capture-storage.md's disk-bound mechanics. Zero means
|
||||
// the defaults (1 req/s, burst 5).
|
||||
// RatePerSecond and RateBurst configure the per-remote-address token bucket
|
||||
// (webhookguard.RateLimiter) applied before a request's body is read. Keyed
|
||||
// by remote address, not the source path segment, since that segment is
|
||||
// unregistered and attacker-chosen by design. Zero means the defaults (1
|
||||
// req/s, burst 5).
|
||||
RatePerSecond float64 `toml:"rate_per_second" yaml:"rate_per_second"`
|
||||
RateBurst int `toml:"rate_burst" yaml:"rate_burst"`
|
||||
}
|
||||
@@ -857,7 +839,6 @@ type CaptureConfig struct {
|
||||
// BindingsConfig configures the playbook-binding store (t2db). When
|
||||
// EncryptionKey is unset, binding secrets are persisted as plaintext
|
||||
// (legacy behaviour); when set, they are AES-256-GCM encrypted at rest
|
||||
// (see docs/prds/binding-secret-encryption.md).
|
||||
type BindingsConfig struct {
|
||||
// EncryptionKey is the active key that seals new binding secrets.
|
||||
// Resolved through the secret registry (engine + key) at startup; the
|
||||
@@ -899,8 +880,8 @@ type ContainerConfig struct {
|
||||
// AgentProfileKind, seeded from this field but validated and stored
|
||||
// (and reloaded live) separately -- see internal/app/controlplane.
|
||||
Profiles map[string]AgentProfile `toml:"profiles" yaml:"profiles" json:"-"`
|
||||
// Credentials binds a Kit's credential@1 service names to org secrets
|
||||
// (docs/prds/external-agent-harness.md, Credentials). A binding names
|
||||
// Credentials binds a Kit's credential@1 service names to org secrets.
|
||||
// A binding names
|
||||
// where the value comes from; it is not itself a grant -- an identity
|
||||
// resolves a bound service only when its own Org matches and the service
|
||||
// is in its GrantedCredentials.
|
||||
@@ -926,18 +907,13 @@ type ContainerConfig struct {
|
||||
}
|
||||
|
||||
// CredentialBinding maps one Kit credential@1 service name to an org secret.
|
||||
// It carries no secret value itself, only where to resolve one from: the
|
||||
// existing secret registry (env/file), not yet the encrypted org-secret
|
||||
// store docs/prds/binding-secret-encryption.md describes -- that store is
|
||||
// separate, still-open work this does not attempt.
|
||||
type CredentialBinding struct {
|
||||
// Service names the credential@1 service a Kit's descriptor declares
|
||||
// (docker/sandbox-kit-spec spec.CredentialCapability.Service).
|
||||
Service string `toml:"service" yaml:"service"`
|
||||
// Org is the org this binding belongs to. Empty means the default org.
|
||||
// A run whose identity's Org does not match never resolves this binding,
|
||||
// however it is granted (docs/prds/orgs-and-access.md: "No record is
|
||||
// shared between orgs").
|
||||
// Org is the org this binding belongs to. Empty means the default org. A
|
||||
// run whose identity's Org does not match never resolves this binding,
|
||||
// however it is granted.
|
||||
Org string `toml:"org" yaml:"org"`
|
||||
// Secret is where an API key's real value is resolved from. A service
|
||||
// the Kit declares OAuth-managed leaves it empty: its tokens are the
|
||||
@@ -991,8 +967,8 @@ func (c ContainerConfig) ValidateCredentialBindings() error {
|
||||
}
|
||||
|
||||
// AgentProfile is a named execution environment for an agent. Secrets and
|
||||
// forge or network access are granted to identities, not profiles
|
||||
// (docs/prds/orgs-and-access.md). A workflow's profile name is not checked
|
||||
// forge or network access are granted to identities, not profiles.
|
||||
// A workflow's profile name is not checked
|
||||
// when the workflow is saved: a name with no profile here parks the task for
|
||||
// an operator when it is dispatched (daemon pinTaskProfile).
|
||||
type AgentProfile struct {
|
||||
@@ -1089,9 +1065,8 @@ type Log struct {
|
||||
Quiet bool `toml:"quiet" yaml:"quiet"`
|
||||
}
|
||||
|
||||
// ChatConfig configures conversational front-ends (multi-agent
|
||||
// collaboration PRD, phase C -- docs/prds/multi-agent-collaboration.md).
|
||||
// Empty (Telegram.Token.Key == "") disables chat entirely.
|
||||
// ChatConfig configures conversational front-ends. Empty (Telegram.Token.Key ==
|
||||
// "") disables chat entirely.
|
||||
type ChatConfig struct {
|
||||
// Operator is the display name of the person this deployment assists,
|
||||
// shown to the chat agent as runtime metadata. Empty tells it nothing.
|
||||
@@ -1184,9 +1159,8 @@ type ChatConfig struct {
|
||||
// A sender is identified per channel: Telegram by numeric user ID, email by the
|
||||
// SMTP from address, webhook by the configured route path -- which is a source,
|
||||
// not a person, so it reaches the limiter through the transport-only
|
||||
// Inbound.BudgetKey rather than through SenderID (see
|
||||
// docs/prds/memory-engine-unification.md §3). Disabled unless both fields are
|
||||
// set to a positive value.
|
||||
// Inbound.BudgetKey rather than through SenderID. Disabled unless both fields
|
||||
// are set to a positive value.
|
||||
type RateLimitConfig struct {
|
||||
// Window is the rolling interval MaxRequests is budgeted over.
|
||||
Window time.Duration `toml:"window" yaml:"window"`
|
||||
@@ -1254,17 +1228,12 @@ type WebhookRoute struct {
|
||||
|
||||
// Notify configures outbound notifications (n8n webhook → email etc.).
|
||||
type Notify struct {
|
||||
// Webhook receives JSON POSTs for events that need a human (e.g.
|
||||
// feasibility PRDs awaiting go/no-go). Empty disables.
|
||||
// Webhook receives JSON POSTs for events that need a human. Empty disables.
|
||||
Webhook string `toml:"webhook" json:"webhook" yaml:"webhook"`
|
||||
}
|
||||
|
||||
// Web configures the observability dashboard.
|
||||
// Health is archied's own liveness surface, always on. It is separate from
|
||||
// the dashboard's /healthz because the process whose restart is being
|
||||
// verified has to be the one answering: the dashboard can be switched off,
|
||||
// and it becomes its own process in Phase 3, at which point probing it would
|
||||
// report health for something the update watchdog never restarted.
|
||||
// Web configures the observability dashboard. Health is archied's own liveness
|
||||
// surface, always on.
|
||||
type Health struct {
|
||||
// Listen is the address the daemon serves /healthz, /health and
|
||||
// /health/detailed on. Defaulted, never empty in a loaded config.
|
||||
|
||||
@@ -17,7 +17,6 @@ package config
|
||||
//
|
||||
// It lives here rather than in internal/secret so the archie-ui process can
|
||||
// render config projections without linking the secret runtime
|
||||
// (archie-core-8cda.5.6).
|
||||
type SecretRef struct {
|
||||
Engine string `toml:"engine" yaml:"engine" json:"engine"`
|
||||
Key string `toml:"key" yaml:"key" json:"key"`
|
||||
|
||||
@@ -74,6 +74,6 @@ type ServiceConnection struct {
|
||||
// when dialing a non-loopback service target, and the standalone
|
||||
// archie-state-store server validates. Empty means no token, which is
|
||||
// the loopback-only, daemon-only listener topology permitted without
|
||||
// auth (docs/prds/state-store-contract.md §9).
|
||||
// auth.
|
||||
TargetToken string `toml:"target_token" yaml:"target_token"`
|
||||
}
|
||||
@@ -37,7 +37,7 @@ type Container struct {
|
||||
func (c *Container) Exited() <-chan struct{} { return c.exited }
|
||||
|
||||
// TaskPayload is the boot-time brief written to /data/worktree/.git/task.json
|
||||
// before the container starts, per PRD section 3.
|
||||
// before the container starts.
|
||||
type TaskPayload struct {
|
||||
ID int64 `json:"id"`
|
||||
Owner string `json:"owner"`
|
||||
@@ -138,11 +138,11 @@ type Config struct {
|
||||
Image string
|
||||
MaxConcurrency int
|
||||
// MaxUptime is the total container lifetime cap from creation. When
|
||||
// exceeded, the container is killed regardless of task state. PRD §4.
|
||||
// exceeded, the container is killed regardless of task state.
|
||||
MaxUptime time.Duration
|
||||
// GracePeriod is the idle time after task completion before the
|
||||
// container is killed. The agent stays alive to handle follow-ups
|
||||
// (gate re-runs, human replies) during this window. PRD §1.
|
||||
// GracePeriod is the idle time after task completion before the container
|
||||
// is killed. The agent stays alive to handle follow-ups (gate re-runs,
|
||||
// human replies) during this window.
|
||||
GracePeriod time.Duration
|
||||
PullPolicy string
|
||||
// RegistryAuth is the resolved value of [containers].registry_auth: either
|
||||
@@ -516,10 +516,10 @@ func releaseDecision(ctx context.Context, grace time.Duration) (honorGrace bool,
|
||||
return grace > 0, nil
|
||||
}
|
||||
|
||||
// Release stops and removes a container after a task completes. If
|
||||
// GracePeriod is configured, the container stays alive for that duration
|
||||
// before being killed -- the agent can handle follow-ups (gate re-runs,
|
||||
// human replies) during this window. PRD section 1.
|
||||
// Release stops and removes a container after a task completes. If GracePeriod
|
||||
// is configured, the container stays alive for that duration before being
|
||||
// killed -- the agent can handle follow-ups (gate re-runs, human replies)
|
||||
// during this window.
|
||||
func (p *Pool) Release(ctx context.Context, c *Container) {
|
||||
if c == nil {
|
||||
return
|
||||
|
||||
@@ -2,12 +2,11 @@ package daemon
|
||||
|
||||
import "sync"
|
||||
|
||||
// AgentStatus tracks the most recent version and install type an
|
||||
// archie-agent worker reported about itself. It is observed passively, off
|
||||
// ordinary taskrun.Response traffic in runViaAgent -- there is no dedicated
|
||||
// poll, since every archie-agent process is task-scoped and ephemeral (see
|
||||
// docs/architecture and internal/app/agentworker), not a long-lived process
|
||||
// the daemon could query on demand the way it can Telegram's gateway.
|
||||
// AgentStatus tracks the most recent version and install type an archie-agent
|
||||
// worker reported about itself. It is observed passively, off ordinary
|
||||
// taskrun.Response traffic in runViaAgent -- there is no dedicated poll, since
|
||||
// every archie-agent process is task-scoped and ephemeral, not a long-lived
|
||||
// process the daemon could query on demand the way it can Telegram's gateway.
|
||||
//
|
||||
// Before the first task completes, nothing is known: Snapshot's ok return
|
||||
// reports that honestly rather than a caller guessing a value.
|
||||
|
||||
+28
-36
@@ -80,9 +80,9 @@ type NATSEndpoint struct {
|
||||
// StateStoreEndpoint is the State Store gRPC target (and the bearer token the
|
||||
// daemon presents, when one is configured) that containerEnv injects as
|
||||
// STATE_STORE_URL / STATE_STORE_TOKEN so archie-agent authenticates to the
|
||||
// same remote archie-state-store service the daemon dials
|
||||
// (docs/prds/state-store-contract.md §6, §9, §10). After the in-process
|
||||
// serving path is deleted (docs/prds/state-store-contract.md §12 step 7) this
|
||||
// same remote archie-state-store service the daemon dials.
|
||||
// After the in-process
|
||||
// serving path is deleted this
|
||||
// is always the configured [services.state].target, never a daemon-owned
|
||||
// listener.
|
||||
type StateStoreEndpoint struct {
|
||||
@@ -107,12 +107,12 @@ type Daemon struct {
|
||||
// [services.state].target after the in-process serving path is deleted.
|
||||
ConnectedStateStore StateStoreEndpoint
|
||||
Store storecontract.TaskStore
|
||||
// Mappings persists payload field mappings (docs/prds/payload-field-mapping.md).
|
||||
// Mappings persists payload field mappings.
|
||||
// Used by the binding dispatch loop to resolve capture bodies against
|
||||
// the mapping a binding names. Optional: nil disables the binding
|
||||
// dispatch loop (legacy behaviour).
|
||||
Mappings storecontract.MappingStore
|
||||
// Bindings persists playbook bindings (docs/prds/playbook-binding.md).
|
||||
// Bindings persists playbook bindings.
|
||||
// Optional: nil disables the binding dispatch loop (legacy behaviour).
|
||||
Bindings storecontract.BindingStore
|
||||
// BindingDispatcher is the dispatch-time helper surface for bindings:
|
||||
@@ -130,9 +130,8 @@ type Daemon struct {
|
||||
// Optional: nil disables the dispatch loop.
|
||||
BindingTaskCreator storecontract.BindingTaskCreator
|
||||
// Access evaluates the policy chain at dispatch, the second of the two
|
||||
// Authorizer call sites (docs/prds/orgs-and-access.md, "Where it
|
||||
// lives"): the workflow's identity may `run` the workflow in its
|
||||
// workspace. Optional: nil dispatches without the chain, which is the
|
||||
// Authorizer call sites: the workflow's identity may `run` the workflow in
|
||||
// its workspace. Optional: nil dispatches without the chain, which is the
|
||||
// behaviour of an install that has not built it.
|
||||
Access access.Authorizer
|
||||
// Principals assembles the dispatch principal for the workflow's
|
||||
@@ -156,8 +155,8 @@ type Daemon struct {
|
||||
// reactionPublisher is built lazily by scanPRReviews; an indirection
|
||||
// only so tests can swap the delivery without the bus.
|
||||
reactionPublisher ReactionPublisher
|
||||
// Reactions pulls the review-reaction fan-out stream
|
||||
// (docs/prds/pr-review-remediation.md). Each cycle it is drained into
|
||||
// Reactions pulls the review-reaction fan-out stream.
|
||||
// Each cycle it is drained into
|
||||
// queued remediate runs before the task drain, so a reaction can be
|
||||
// claimed in the same pass that carried it. Optional: nil disables the
|
||||
// reaction consumer (tests, or a deployment without the reaction
|
||||
@@ -743,9 +742,8 @@ func (d *Daemon) dispatchOneBinding(ctx context.Context, b binding.Binding, c st
|
||||
return
|
||||
}
|
||||
// The chain decides dispatch: the workflow's identity may `run` this
|
||||
// workflow in its workspace, and the event's signature result and
|
||||
// address travel with the request (docs/prds/orgs-and-access.md,
|
||||
// "Access decisions"). A denial is recorded and the dispatch is not
|
||||
// workflow in its workspace, and the event's signature result and address
|
||||
// travel with the request. A denial is recorded and the dispatch is not
|
||||
// claimed: the capture stays listed for the next cycle.
|
||||
if !d.authorizeDispatch(ctx, b, c, target) {
|
||||
return
|
||||
@@ -755,7 +753,7 @@ func (d *Daemon) dispatchOneBinding(ctx context.Context, b binding.Binding, c st
|
||||
|
||||
// claimAndEnqueue claims the dispatch in the at-most-once ledger and enqueues
|
||||
// the task. A failed enqueue after the claim loses that dispatch, which is
|
||||
// the at-most-once side of the trade (docs/prds/playbook-binding.md).
|
||||
// the at-most-once side of the trade.
|
||||
func (d *Daemon) claimAndEnqueue(ctx context.Context, b binding.Binding, c storecontract.CapturedEvent, target bindingTarget, values map[string]any) {
|
||||
if err := d.BindingDispatcher.RecordDispatch(ctx, b.ID, int64(b.Version), c.ID, 0); err != nil {
|
||||
if !errors.Is(err, storecontract.ErrAlreadyDispatched) {
|
||||
@@ -1171,8 +1169,7 @@ func (d *Daemon) pollNATS(ctx context.Context, fg forge.Forge, cfg config.Config
|
||||
// issue on a later poll does not enqueue the work twice. It is the single
|
||||
// enqueue path shared by the poller and the forge webhook intake, so neither
|
||||
// can drift in how a discovered issue becomes a task -- including the org the
|
||||
// key is built from (docs/prds/orgs-and-access.md, "Events and task
|
||||
// identity").
|
||||
// key is built from.
|
||||
func (d *Daemon) PublishTask(ctx context.Context, task workintake.TaskEnvelope) error {
|
||||
if d.Tasks == nil {
|
||||
return fmt.Errorf("publish task %s: no task bus configured", task.Ref())
|
||||
@@ -1675,11 +1672,10 @@ func (d *Daemon) acquireTaskContainer(
|
||||
}
|
||||
|
||||
// pr-review needs an external pull request's metadata, diff and head
|
||||
// snapshot inside the container, but the container must never hold a
|
||||
// forge credential (docs/development/agent.md, "Giving the agent
|
||||
// something new"). The daemon fetches it here, before the container
|
||||
// exists, using its own credentialed forge client, and writes the result
|
||||
// into workDir -- the same host directory Docker bind-mounts at
|
||||
// snapshot inside the container, but the container must never hold a forge
|
||||
// credential. The daemon fetches it here, before the container exists,
|
||||
// using its own credentialed forge client, and writes the result into
|
||||
// workDir -- the same host directory Docker bind-mounts at
|
||||
// storage.WorktreeMountDir -- so the sandboxed pipeline can read it back
|
||||
// with prsource.MountSource and no network call of its own.
|
||||
if task.Workflow == "pr-review" {
|
||||
@@ -1943,12 +1939,12 @@ func (d *Daemon) pinTaskProfile(ctx context.Context, task *workflow.Task) (confi
|
||||
}
|
||||
|
||||
// validateProfileMeetsNeeds rejects a Kit profile whose harness cannot meet
|
||||
// what the workflow declares it needs (docs/prds/external-agent-harness.md,
|
||||
// "Contract"): a workflow needing captures but naming a profile whose Kit CLI
|
||||
// serves none (no adapter, or one with no MCP config to register archie-agent
|
||||
// mcp against -- e.g. Codex, Pi, OMP per agentexec.harnessAdapters). An image
|
||||
// profile is never checked: the built-in agent loop always supports both
|
||||
// captures and gate retries, so Needs constrains only the harness path.
|
||||
// what the workflow declares it needs: a workflow needing captures but naming a
|
||||
// profile whose Kit CLI serves none (no adapter, or one with no MCP config to
|
||||
// register archie-agent mcp against -- e.g. Codex, Pi, OMP per
|
||||
// agentexec.harnessAdapters). An image profile is never checked: the built-in
|
||||
// agent loop always supports both captures and gate retries, so Needs
|
||||
// constrains only the harness path.
|
||||
func validateProfileMeetsNeeds(profile config.AgentProfile, needs workflowtask.WorkflowNeeds) error {
|
||||
if !profile.IsKit() || !needs.Captures {
|
||||
return nil
|
||||
@@ -2067,7 +2063,7 @@ func pinnedDefinitionID(task *workflow.Task) (string, bool, error) {
|
||||
}
|
||||
|
||||
// runActionPlaybooks runs the action playbooks matching a task that is about
|
||||
// to be pinned, which happens once per task (docs/prds/action-playbook-run.md).
|
||||
// to be pinned, which happens once per task.
|
||||
// A run never affects routing and its failure never fails the task. A task
|
||||
// that already names a workflow is the approval requeue and is skipped, as
|
||||
// it is for workflow playbooks.
|
||||
@@ -2223,7 +2219,7 @@ func (d *Daemon) containerEnv(task *workflow.Task, stateStoreToken string) []str
|
||||
env = append(env, "NATS_TOKEN="+token)
|
||||
}
|
||||
// The State Store gRPC target follows the same seam as NATS_URL/
|
||||
// NATS_TOKEN above (docs/prds/state-store-contract.md §6). It is always
|
||||
// NATS_TOKEN above. It is always
|
||||
// the configured [services.state].target after the in-process serving
|
||||
// path is deleted. stateStoreToken is this task's own scoped credential
|
||||
// (see stateStoreGrantToken) -- never d.ConnectedStateStore.Token, which
|
||||
@@ -2235,13 +2231,9 @@ func (d *Daemon) containerEnv(task *workflow.Task, stateStoreToken string) []str
|
||||
env = append(env, "STATE_STORE_TOKEN="+stateStoreToken)
|
||||
}
|
||||
}
|
||||
// The agent process runs as root inside the container (no USER in the
|
||||
// Dockerfile, no userns-remap), so a commit it writes to the bind-mounted
|
||||
// worktree lands owned by UID 0 on the host. The daemon then reads those
|
||||
// same loose objects to push, running as its own non-root host user --
|
||||
// archie-core#520's "permission denied" on .git/objects. Passing the
|
||||
// daemon's own UID/GID lets the agent chown the worktree back to it
|
||||
// before pushing.
|
||||
// The agent runs as root in the container, so its commits land owned by
|
||||
// UID 0 on the host. The daemon's UID/GID let the agent hand the worktree
|
||||
// back before the daemon reads it to push.
|
||||
env = append(env, fmt.Sprintf("WORKTREE_UID=%d", os.Getuid()))
|
||||
env = append(env, fmt.Sprintf("WORKTREE_GID=%d", os.Getgid()))
|
||||
for _, p := range d.configFor(task).Providers {
|
||||
|
||||
@@ -14,14 +14,12 @@ import (
|
||||
)
|
||||
|
||||
// prefetchPRReview fetches a pull request's metadata, diff and head snapshot
|
||||
// over f (the daemon's own forge client, which holds the real credential)
|
||||
// and writes them under workDir/prReviewPrefetchDir, before the task's
|
||||
// container is acquired. This is how pr-review gets its data into the
|
||||
// sandbox with no forge credential ever entering the container: the daemon
|
||||
// does the real HTTP fetch here, unsandboxed, and the container-side
|
||||
// prsource.MountSource only ever reads the result off the bind-mounted disk
|
||||
// (docs/development/agent.md, "Giving the agent something new": "the
|
||||
// daemon's own administrative token never enters a container").
|
||||
// over f (the daemon's own forge client, which holds the real credential) and
|
||||
// writes them under workDir/prReviewPrefetchDir, before the task's container is
|
||||
// acquired. This is how pr-review gets its data into the sandbox with no forge
|
||||
// credential ever entering the container: the daemon does the real HTTP fetch
|
||||
// here, unsandboxed, and the container-side prsource.MountSource only ever
|
||||
// reads the result off the bind-mounted disk.
|
||||
func prefetchPRReview(ctx context.Context, f any, owner, repo string, number int, workDir string) error {
|
||||
prReader, ok := f.(forge.PullRequestReader)
|
||||
if !ok {
|
||||
|
||||
@@ -34,12 +34,8 @@ var remediableReviewStates = map[string]bool{
|
||||
"commented": true,
|
||||
}
|
||||
|
||||
// reactionConsumer turns forge review reactions on Archie-owned PRs into
|
||||
// queued remediate runs. It implements the consumer half of
|
||||
// docs/prds/pr-review-remediation.md decisions 3 and 5: resolve the PR to
|
||||
// the task that owns it (the authorization boundary), never react to
|
||||
// Archie's own comments, collect a review's comments into one unit while it
|
||||
// is pending, and rely on the guarded store transition for dedup.
|
||||
// reactionConsumer turns forge review reactions on Archie-owned PRs into queued
|
||||
// remediate runs.
|
||||
type reactionConsumer struct {
|
||||
lookup workintake.ReviewTaskLookup
|
||||
remediations storecontract.RemediationStarter
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Package access owns the policy schema, the action vocabulary, how
|
||||
// principals and resources are turned into policy entities, and the
|
||||
// Authorizer contract (docs/prds/orgs-and-access.md).
|
||||
// Authorizer contract.
|
||||
//
|
||||
// The policy chain is
|
||||
//
|
||||
|
||||
@@ -6,7 +6,7 @@ package access
|
||||
import "context"
|
||||
|
||||
// Authorizer evaluates the policy chain for one request. Exactly two places
|
||||
// call it (docs/prds/orgs-and-access.md, "Where it lives"): the dashboard and
|
||||
// call it: the dashboard and
|
||||
// API request path, and dispatch. The implementation is the Cedar engine in
|
||||
// internal/infrastructure/access.
|
||||
//
|
||||
|
||||
@@ -141,7 +141,7 @@ type PrincipalSource interface {
|
||||
}
|
||||
|
||||
// Denial is one recorded refusal: who was refused, doing what, to what, by
|
||||
// which level and which policies (docs/prds/orgs-and-access.md, "Denials").
|
||||
// which level and which policies.
|
||||
type Denial struct {
|
||||
Principal identity.IdentityID `json:"principal"`
|
||||
Org org.OrgID `json:"org"`
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// The shipped policies: the four org roles every org carries, and the
|
||||
// cross-org forbid the engine always enforces
|
||||
// (docs/prds/orgs-and-access.md, "The policy chain" and "Roles").
|
||||
//
|
||||
// The role policies are Cedar policy text because that is what the engine
|
||||
// evaluates. They live in the domain so the store seeds them, the reset
|
||||
|
||||
@@ -28,8 +28,8 @@ type PolicyStore interface {
|
||||
EnsureShippedOrgPolicies(ctx context.Context, orgID org.OrgID) error
|
||||
}
|
||||
|
||||
// Resetter restores access for a locked-out org or a broken instance policy
|
||||
// (docs/prds/orgs-and-access.md, "Recovering from a locked-out org"). It
|
||||
// Resetter restores access for a locked-out org or a broken instance policy.
|
||||
// It
|
||||
// runs only on the State Store host, never over the network, and the reset
|
||||
// command records it as an audit event.
|
||||
type Resetter interface {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Package applystatus reports which version of a control-plane resource each
|
||||
// process is running. See docs/prds/control-plane-apply-status.md.
|
||||
// process is running.
|
||||
package applystatus
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Package binding owns the playbook binding vocabulary: the matcher +
|
||||
// mapping + workflow + state-machine entity that turns a captured webhook
|
||||
// into an archie task. See docs/prds/webhook-intake-security.md and
|
||||
// docs/prds/payload-field-mapping.md.
|
||||
// Package binding owns the playbook binding vocabulary: the matcher + mapping +
|
||||
// workflow + state-machine entity that turns a captured webhook into an archie
|
||||
// task.
|
||||
package binding
|
||||
|
||||
import (
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
// maxRecentActions bounds how much per-curator history activityTracker
|
||||
// keeps in memory. Curator activity is inspectable, not archival -- there is
|
||||
// deliberately no persistence layer here (archie-core-1786637489932-6),
|
||||
// deliberately no persistence layer here,
|
||||
// so this is a ring buffer, not a log.
|
||||
const maxRecentActions = 20
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Package curator is the curator engine family: long-running agent loops
|
||||
// that reason over memory and perform small maintenance tasks, rather than
|
||||
// one hardcoded background job. See epic archie-core-yp9.
|
||||
// one hardcoded background job..
|
||||
//
|
||||
// A curator is defined by a declared shape (check-in interval, tool set,
|
||||
// attached memory engine), runs persistently while there is input, and backs
|
||||
@@ -46,23 +46,22 @@ type Manifest struct {
|
||||
// OnInput marks the curator as input-driven: primary input (e.g. a
|
||||
// completed chat turn) wakes it before the next interval. Wake events
|
||||
// are best-effort nudges; the trigger decision is a deterministic
|
||||
// state read at pass time (archie-core-035).
|
||||
// state read at pass time.
|
||||
OnInput bool
|
||||
// Tools is the declared tool set: the only tools a pass may reach.
|
||||
// Enforcement is mechanical — the pass's tool set is built from this
|
||||
// list, never from a broader registry.
|
||||
Tools []string
|
||||
// Skills declares the skill-maintenance capability (skill curator,
|
||||
// archie-core-i7i). The registrar must carry a SkillStore for a
|
||||
// curator that declares it.
|
||||
// Skills declares the skill-maintenance capability. The registrar must
|
||||
// carry a SkillStore for a curator that declares it.
|
||||
Skills bool
|
||||
// MemoryEngine names the attached memory engine once the memory engine
|
||||
// family exists (archie-core-pek). Empty means the curator does not
|
||||
// family exists. Empty means the curator does not
|
||||
// use memory; a memory operation without a declared engine is
|
||||
// rejected.
|
||||
MemoryEngine string
|
||||
// Conversations declares the conversation-history capability
|
||||
// (session-memory curator, archie-core-1786637499114). The registrar
|
||||
// Conversations declares the conversation-history capability.
|
||||
// The registrar
|
||||
// must carry a ConversationSource for a curator that declares it.
|
||||
Conversations bool
|
||||
// Model is the model reference ("provider/model") passes use. Empty
|
||||
@@ -132,7 +131,6 @@ type PassInput struct {
|
||||
|
||||
// PassResult reports what a pass did. Every action is attributable: the
|
||||
// registry emits them as events and they are inspectable at runtime
|
||||
// (archie-core-114).
|
||||
type PassResult struct {
|
||||
// Actions records what this pass changed and why.
|
||||
Actions []Action
|
||||
|
||||
@@ -13,10 +13,7 @@ import (
|
||||
// registry's activity surface and events.
|
||||
const ActionToolCalled = "tool.called"
|
||||
|
||||
// defaultDefinitionMaxSteps bounds the model/tool loop of one definition
|
||||
// pass. It is not a definition value and is deliberately not configurable
|
||||
// yet: the PRD's no-live-path-constants rule covers interval, cooldown,
|
||||
// tools, model, and memory engine, not loop length.
|
||||
// defaultDefinitionMaxSteps bounds the model/tool loop of one definition pass.
|
||||
const defaultDefinitionMaxSteps = 10
|
||||
|
||||
// DefinitionEngine interprets a Definition: one generic engine serving
|
||||
|
||||
@@ -29,11 +29,11 @@ type Registrar struct {
|
||||
// declared set, never a broader registry. Bound when tools are
|
||||
// declared.
|
||||
Tools ToolBuilder
|
||||
// Skills is the skill-maintenance capability (skill curator,
|
||||
// archie-core-i7i). Bound when the curator declares Skills.
|
||||
// Skills is the skill-maintenance capability. Bound when the curator
|
||||
// declares Skills.
|
||||
Skills SkillStore
|
||||
// MemoryEngines resolves a named memory engine, for a curator that
|
||||
// declared Manifest.MemoryEngine (archie-core-1786637499636). Bound
|
||||
// declared Manifest.MemoryEngine. Bound
|
||||
// only when declared. Like Tools, resolution is by name at call time,
|
||||
// not a value pre-fetched at Bind: a curator calls
|
||||
// MemoryEngines.Get(its own Manifest().MemoryEngine), the same trust
|
||||
@@ -41,9 +41,8 @@ type Registrar struct {
|
||||
// trusted to pass its own declared identifier, not handed a
|
||||
// pre-scoped instance.
|
||||
MemoryEngines MemoryEngineSource
|
||||
// Conversations is read-only recent conversation history, for a
|
||||
// curator that declared Manifest.Conversations (session-memory
|
||||
// curator, archie-core-1786637499114). Bound only when declared.
|
||||
// Conversations is read-only recent conversation history, for a curator
|
||||
// that declared Manifest.Conversations. Bound only when declared.
|
||||
Conversations ConversationSource
|
||||
// Events publishes curator activity. Implementations must be
|
||||
// non-blocking and bounded (drop on overflow), so a curator can never
|
||||
@@ -99,7 +98,7 @@ type ToolBuilder interface {
|
||||
}
|
||||
|
||||
// SkillStore is the skill-maintenance capability. The implementation owns
|
||||
// the on-disk format and catalog reload rules (archie-core-i7i).
|
||||
// the on-disk format and catalog reload rules.
|
||||
type SkillStore interface {
|
||||
List(ctx context.Context) ([]SkillRef, error)
|
||||
Read(ctx context.Context, name string) (Skill, error)
|
||||
|
||||
@@ -45,8 +45,8 @@ type Registry struct {
|
||||
order []string
|
||||
state registryState
|
||||
|
||||
// activity tracks recent per-curator run history for observability
|
||||
// (archie-core-1786637489932-6). It has its own mutex and is safe to
|
||||
// activity tracks recent per-curator run history for observability.
|
||||
// It has its own mutex and is safe to
|
||||
// use independently of r.mu.
|
||||
activity *activityTracker
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ type RuntimeConfig struct {
|
||||
// Curators are peers, never dependencies: nothing a curator does — a
|
||||
// blocking pass, a panic, a burst of nudges — can block a chat turn, an
|
||||
// agent run, or the daemon. Wake events are accelerations; the trigger is a
|
||||
// deterministic state read at pass time (archie-core-035), so a dropped
|
||||
// deterministic state read at pass time, so a dropped
|
||||
// nudge only delays a run to the next check-in.
|
||||
type Runtime struct {
|
||||
registry *Registry
|
||||
@@ -312,7 +312,7 @@ func (rt *Runtime) fail(name, phase string, err error) {
|
||||
}
|
||||
|
||||
// emitRun publishes one run summary plus one event per action, so what ran,
|
||||
// when, what it changed, and why all stay attributable (archie-core-114).
|
||||
// when, what it changed, and why all stay attributable.
|
||||
func (rt *Runtime) emitRun(name string, at time.Time, result PassResult) {
|
||||
rt.registry.RecordActivity(name, at, result.Actions)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
// WakeOnPrimaryInput forwards primary-input events from the in-process bus
|
||||
// to the runtime as best-effort nudges (archie-core-035). Only the kinds in
|
||||
// to the runtime as best-effort nudges. Only the kinds in
|
||||
// inputKinds wake curators — the trigger-accounting invariant: curator-
|
||||
// produced activity (curator_run, curator_action, curator_error, and any
|
||||
// future derived-write kind) never appears on this path, so a curator's own
|
||||
|
||||
@@ -13,10 +13,9 @@
|
||||
// evaluation cannot disagree; the standalone lint command covers the flat
|
||||
// kind/label binding files, not rich EDA playbook documents.
|
||||
//
|
||||
// CEL is non-Turing-complete, side-effect-free, and panic-free by design (no
|
||||
// recover() wrapper is needed; verified in the t2db.14 acceptance tests
|
||||
// against hostile data). Anything the schema does not accept is a returned
|
||||
// error here -- the reject-at-load philosophy of the parent design doc.
|
||||
// CEL is non-Turing-complete, side-effect-free, and panic-free by design.
|
||||
// Anything the schema does not accept is a returned error here -- the
|
||||
// reject-at-load philosophy of the parent design doc.
|
||||
package expr
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Package log is the schema source for the "log" Module action kind -- the
|
||||
// side-effect-free proof-of-concept kind for the Module position (t2db.13,
|
||||
// docs/prds/module-position.md). A Yaegi module implementing this kind
|
||||
// exports a fixed function name against these generated types; the operator's
|
||||
// file is the implementation, this package is the contract.
|
||||
// side-effect-free proof-of-concept kind for the Module position. A Yaegi
|
||||
// module implementing this kind exports a fixed function name against these
|
||||
// generated types; the operator's file is the implementation, this package is
|
||||
// the contract.
|
||||
//
|
||||
// This is the hand-written schema. logextract (generated by `go generate`)
|
||||
// turns it into the Yaegi symbol table the interpreter uses.
|
||||
|
||||
@@ -7,10 +7,9 @@
|
||||
// installed source, resolve its typed entrypoint, then call it through the
|
||||
// panic-safe interpreter boundary.
|
||||
//
|
||||
// Per docs/prds/module-position.md, there is deliberately no generic Module
|
||||
// interface with an any payload. Each action kind is its own tiny package
|
||||
// with its own generated contract (internal/domain/eda/module/<kind>), and
|
||||
// the registry's internal storage is the only place type erasure appears.
|
||||
// Each action kind is its own tiny package with its own generated contract
|
||||
// (internal/domain/eda/module/<kind>), and the registry's internal storage is
|
||||
// the only place type erasure appears.
|
||||
package module
|
||||
|
||||
import (
|
||||
@@ -74,9 +73,9 @@ func New() *ModuleRegistry {
|
||||
return &ModuleRegistry{kinds: make(map[string]invoker)}
|
||||
}
|
||||
|
||||
// Kinds returns the known action-kind names, sorted for determinism. Only
|
||||
// kinds with a registered contract can be loaded; the log kind is the
|
||||
// shipped proof-of-concept (t2db.13).
|
||||
// Kinds returns the known action-kind names, sorted for determinism. Only kinds
|
||||
// with a registered contract can be loaded; the log kind is the shipped
|
||||
// proof-of-concept.
|
||||
func Kinds() []string {
|
||||
names := make([]string, 0, len(registry))
|
||||
for name := range registry {
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
// InvokeOnce runs one playbook action at most once per
|
||||
// (playbook, version, event, action) tuple, record-before-invoke: the ledger
|
||||
// row is committed before fn runs, so a redelivered action (the same
|
||||
// structural key) skips without repeating a non-revocable side effect
|
||||
// (docs/prds/eda-playbook-engine.md gap 2). The structural key is computed
|
||||
// structural key) skips without repeating a non-revocable side effect.
|
||||
// The structural key is computed
|
||||
// from Decision.PlaybookID, Decision.Version, input.TaskID (the event_id) and
|
||||
// Decision.ActionID; when the action declares no id the 1-based
|
||||
// Decision.ActionPosition is used instead -- it is never a CEL expression. A
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
// Package playbook is the EDA playbook document type and its event
|
||||
// coordinator: the rich trigger+actions YAML shape (docs/prds/
|
||||
// eda-playbook-engine.md) with CEL `when` conditions and `args` values
|
||||
// (open question 1, resolved to CEL). A playbook is one of two shapes
|
||||
// Package playbook is the EDA playbook document type and its event coordinator:
|
||||
// the rich trigger+actions YAML shape with CEL `when` conditions and `args`
|
||||
// values (open question 1, resolved to CEL). A playbook is one of two shapes
|
||||
// (multi-action-playbooks.md, D2):
|
||||
//
|
||||
// - a workflow playbook is exactly one `workflow` action, unchanged from
|
||||
// the original boundary, and is routed by the daemon's definition pin;
|
||||
// - an action playbook is one or more `module` actions in order, each with
|
||||
// a registered `kind`, `args`, and an optional `when`/`id`. Store.Run
|
||||
// executes it (docs/prds/action-playbook-run.md).
|
||||
// executes it.
|
||||
//
|
||||
// The two shapes never mix in one playbook. This is an ADDITIONAL routing
|
||||
// source alongside the flat kind/label binding files (t2db.9/.10/.11): the
|
||||
// daemon consults a matching workflow playbook before those bindings when it
|
||||
// pins a task's workflow definition (t2db.23). The binding loaders themselves
|
||||
// are untouched.
|
||||
// source alongside the flat kind/label binding files: the daemon consults a
|
||||
// matching workflow playbook before those bindings when it pins a task's
|
||||
// workflow definition. The binding loaders themselves are untouched.
|
||||
package playbook
|
||||
|
||||
import (
|
||||
@@ -661,7 +659,6 @@ func (pb *Playbook) Match(input DispatchInput) bool {
|
||||
// that chose it. Version pins the decision to the exact file content active
|
||||
// when it fired, and both fields are the first two components of the
|
||||
// per-action idempotency key the resolved gap-2 scheme derives
|
||||
// (docs/prds/eda-playbook-engine.md, "Idempotency at execution time").
|
||||
type Decision struct {
|
||||
PlaybookID string
|
||||
Version string
|
||||
@@ -671,9 +668,8 @@ type Decision struct {
|
||||
// dispatch ledger) read this action under.
|
||||
ActionID string
|
||||
// ActionPosition is the 1-based index of the dispatched action in the
|
||||
// playbook's actions list. It is the idempotency-key fallback when
|
||||
// ActionID is empty (docs/prds/eda-playbook-engine.md, "Idempotency at
|
||||
// execution time").
|
||||
// playbook's actions list. It is the idempotency-key fallback when ActionID
|
||||
// is empty.
|
||||
ActionPosition int
|
||||
}
|
||||
|
||||
@@ -736,7 +732,6 @@ func evalContext(input DispatchInput) expr.Context {
|
||||
// Asymmetry with `when`: `when` is a predicate, so an evaluation error is
|
||||
// false (J3: skip + log); `args` is data, so an evaluation error has no
|
||||
// meaningful substitute and is returned to the caller to abort the playbook run
|
||||
// (J6, docs/prds/playbook-expression-syntax.md).
|
||||
func (s *Store) EvalArgs(a Action, input DispatchInput) (map[string]any, error) {
|
||||
if s == nil {
|
||||
return map[string]any{}, nil
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
// Run executes every action playbook whose trigger matches input, in load
|
||||
// order (docs/prds/action-playbook-run.md). Each action goes through
|
||||
// order. Each action goes through
|
||||
// InvokeOnce, so it fires at most once per (playbook, version, event,
|
||||
// action). A failure stops only its own playbook; the rest still run, and
|
||||
// the failures are returned joined, each naming its playbook and action.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Package embedding is the embedding capability: a narrow typed boundary
|
||||
// for turning text into vectors, so consumers (curators first, per bead
|
||||
// archie-core-1786637500752-415-434e5bb9 / GitHub #436) never depend on a
|
||||
// specific provider SDK.
|
||||
// Package embedding is the embedding capability: a narrow typed boundary for
|
||||
// turning text into vectors, so consumers never depend on a specific provider
|
||||
// SDK.
|
||||
//
|
||||
// Unlike curator and memory (internal/domain/curator, internal/domain/
|
||||
// memory), a Client has no Lifecycle: it is call-scoped, not long-running,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Package eventtype owns event types: named kinds of event from one source,
|
||||
// each defined by a match rule over headers and payload. It infers a
|
||||
// structural signature per capture, groups a source's captures into proposed
|
||||
// types, evaluates rules, and refuses two types on one source whose rules can
|
||||
// match the same event. An event that matches no type is unidentified and is
|
||||
// never dispatched. See docs/prds/event-automation.md, "Event types".
|
||||
// each defined by a match rule over headers and payload. It infers a structural
|
||||
// signature per capture, groups a source's captures into proposed types,
|
||||
// evaluates rules, and refuses two types on one source whose rules can match
|
||||
// the same event. An event that matches no type is unidentified and is never
|
||||
// dispatched.
|
||||
package eventtype
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
// Package harnesssecret is the OAuth token set a credential binding's
|
||||
// service holds for one org (docs/prds/external-agent-harness.md,
|
||||
// Credentials). The setup terminal writes the first capture; the egress
|
||||
// proxy overwrites it on every token refresh. It is never a Kit-declared
|
||||
// value and never resolved through the config secret registry the way an
|
||||
// API-key binding's SecretRef is -- it is state archie itself captures and
|
||||
// mutates.
|
||||
// Package harnesssecret is the OAuth token set a credential binding's service
|
||||
// holds for one org. The setup terminal writes the first capture; the egress
|
||||
// proxy overwrites it on every token refresh. It is never a Kit-declared value
|
||||
// and never resolved through the config secret registry the way an API-key
|
||||
// binding's SecretRef is -- it is state archie itself captures and mutates.
|
||||
package harnesssecret
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Package image is the image generation capability family: a
|
||||
// provider-neutral boundary for hosted (gpt-image-2-class) and local GPU
|
||||
// backends, so /image routing can target either without depending on
|
||||
// provider-specific types. See docs/prds/image-capability-contract.md for
|
||||
// the design and epic archie-core-1786748942120-1-6636e629.
|
||||
// Package image is the image generation capability family: a provider-neutral
|
||||
// boundary for hosted (gpt-image-2-class) and local GPU backends, so /image
|
||||
// routing can target either without depending on provider-specific types.
|
||||
//
|
||||
// Unlike curator and memory (internal/domain/curator,
|
||||
// internal/domain/memory), a Provider has no Lifecycle: it is call-scoped,
|
||||
|
||||
Loaded 100 of 269 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user