Skip to content

factory: Trigger API — message and status doors, one event bus with sinks, signed webhooks per source - #2485

Merged
santoshkumarradha merged 8 commits into
factory/general-intakefrom
factory/gi-trigger-api
Nov 7, 2026
Merged

santoshkumarradha merged 8 commits into
factory/general-intakefrom
factory/gi-trigger-api

Conversation

@santoshkumarradha

@santoshkumarradha santoshkumarradha commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Summary

Wave 2's Trigger API, reshaped for AgentField: one event bus out with pluggable sinks, a message door and a status door, and signed per-source webhooks from a durable outbox. No per-source tokens and no SDKs (AgentField's SDKs and DID auth cover that). Every HTTP call takes the operator token.

lifecycle (lease report · inbox.Add · inbox.Message)
  inbox.Notify(job, Event)            filed started question pr_opened merged stuck done message
    ├─ source's inbox.Replier         Jira: comments pr_opened/merged/stuck/question, ignores the rest
    ├─ RegisterSink("webhook")        trigger.WebhookSink → trigger-outbox/ → POST URL, signed
    └─ RegisterSink("agentfield")     the AgentField node: reports each moment to the job's open executions
Call Door (callable without HTTP)
POST /api/intake/{source}/{id}/messages {author?, text} → {job, accepted, outcome, line} trigger.Message(ctx, st, trigger.Said, now) → inbox.Message → factory.ReadComments (the GitHub comment path)
GET /api/intake/{source}/{id} → {job, state, steps_done, steps_total, route?, pr_url?, question?, updated} trigger.Status(st, source, id), trigger.StatusOfJob(st, job) → api.IntakeStatusOf (read off api.FromItem)
GET/POST/DELETE /v1/webhooks · codeaf factory webhook add SOURCE URL / list / remove SOURCE trigger.Webhooks (secret printed once; kept 0600 in trigger-webhooks.json)
AgentField message / status reasoners the same trigger.Message / trigger.Status / trigger.StatusOfJob; the node is inbox.RegisterSink("agentfield", …)

This PR also moves #2487's AgentField node onto the bus:

 internal/factory/agentfield
-  replier registered per agentfield:* source (inbox.RegisterReplier)
-  20-second reportEvery tick → reportAll
+  sink{n} registered as "agentfield" on Start, removed on Stop/Forget
+  retellQuiet on each lease renewal: an execution untold for 3 min is told again
-  message stand-in → Node.Send → factory.job_send, answers {job, delivered}
+  message → trigger.Message, answers {job, accepted, outcome, line}
-  status stand-in → Facts(it)
+  status → trigger.Status / StatusOfJob, answers api.IntakeStatus

Signature: X-Codeaf-Signature: t=<unix>,sha256=HMAC(secret, "<t>.<body>"), plus X-Codeaf-Delivery (the same id on every retry) and X-Codeaf-Event. Retries start at 2s and double up to 1h, for 72h, until a 2xx. The outbox survives a restart.

Evidence

  • internal/factory/trigger: TestTheOutboxRetriesUntilA2xxAndSurvivesARestart, TestARemovedWebhooksDeliveriesAreDroppedAndOldOnesGivenUp, TestTheSignatureRefusesATamperedOrStaleBody (a golden vector), TestAWebhookKeepsItsSecretPrivateAndIsReplacedWhole, TestTheSinkQueuesOnlyForASourceWithAWebhookAndAMergeIsAlsoDone, TestTheMessageAndStatusDoorsAnswerWithoutHTTP
  • internal/factory/inbox: TestEverySinkHearsEachMomentBesideTheReplier, TestMomentsAreTheChangesOfAnInboxJob, TestAMessageIsReadAsACommentAtTheLowerTrust, TestAMessageKeepsTheLastFewAndRefusesWhatItCannotTake
  • internal/factory/run: TestAMessageFromOutsideIsInTheNextStepsBrief
  • internal/factory/api: TestIntakeStatusIsTheJobWiresFacts
  • internal/factory/serve: TestTheTriggerAPIFilesMessagesReadsAndHearsBack, an httptest end-to-end: set the webhook, file, message, read status, receive signed job.filed, job.message and job.pr_opened, and see the teammate refusals
  • internal/factory/jira: TestReplierCommentsEachMoment also covers question and ignores the new kinds
  • cmd/codeaf: TestFactoryWebhookAddsListsAndRemoves
  • internal/factory/agentfield: TestMessageAndStatusReasoners (now through the doors: a comment on the job, a stranger's job read as context, 404 and 422), TestAStoppedJobFailsItsExecutionWithTheJobsWords (now from a bus moment), TestTheIntakeAnswers202AndThePullRequestCompletesTheExecution (the unit-level copy of the e2e), and the new TestAQuietExecutionIsToldAgainWithTheLease
  • make test-laws and go test ./internal/manual/ pass. make pr-ready BASE=origin/factory/general-intake passes (see the PR thread).

Merge Danger

Door: two-way. The new files live in the floor folder (trigger-webhooks.json, trigger-outbox/) and are ignored by older builds.

Blast Radius: factory-intake

GitHub is untouched (no change to the poller or its comments). Behaviour changes for jobs filed from outside:

  • a needs-you stop that carries a question is now question, not stuck, and Jira still comments it;
  • inbox.Add now notifies filed;
  • AgentField's message reasoner no longer sends the text into the manager conversation as a person's message: it is a comment, handled once, like a GitHub comment (text limit 8000, not 32000), and its answer and the status answer change shape (registered schemas updated);
  • the manager's ask for a message on a job filed from outside reads "sent a message about this job".

docs/changes/unreleased/2487-factory-agentfield-node.md had pr: 0, which failed changelog-check; it now says 2487.

Deferred: no desktop wire methods for webhooks (only CLI and HTTP). job.message carries the manager's reading of the message, not a later free-form reply.

🤖 Generated with Claude Code

…om outside, signed webhooks, Go and TypeScript clients
# Conflicts:
#	docs/design/factory-general/DESIGN.md
…r source, message and status doors for AgentField; no source tokens, no SDKs
…tory/gi-trigger-api

# Conflicts:
#	internal/manual/chat_test.go
…age and status reasoners are the Trigger API's doors

The node registers as inbox sink "agentfield" and reports each moment to
the job's open executions; the 20-second tick is gone. An execution quiet
for keepAlive is told again with the lease, so a long job never looks
stale and a dropped job still completes. The message and status reasoners
call trigger.Message and trigger.Status; Node.Send and its job_send wiring
are removed. #2487's change entry now names its pull request.
@santoshkumarradha
santoshkumarradha merged commit d4faf50 into factory/general-intake Nov 7, 2026
1 check passed
@santoshkumarradha
santoshkumarradha deleted the factory/gi-trigger-api branch November 7, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant