3.9 KiB
Bounded editorial approved-run contract
Only the explicitly configured WORKFLOW_WORKER grant pmo may use these routes under /api/internal/prepare-worker (the application's prefix supplies /api). No new credential or reviewer grant is provisioned here.
GET editorial-proposals/:taskId: exact bridge-created proposal status and, after ingestion, canonical immutable brief bytes/digest. No lease token, raw events, reviewer identities or arbitrary task projection.POST editorial-claim:{ "taskId": "<uuid>" }. Requires exact bridge key/title/scope/metadata plus original PMO creation/submission events, READY/RUNNING, latest independent unexpired approved Gate1, no blocking kill switch. Core claim runs inside the same admission/task-lock transaction, preserving reservations, ownership and 30-second leases. Competing claim returns null lease. Expired attempts retain unknown reservation; a 20-cent task cannot reserve a second 20 cents.POST heartbeat: existing{taskId,runId,leaseToken}while working. Extends lease by 30 seconds. Result rechecks Gate1 independently; heartbeat is not approval extension.POST editorial-result:{taskId,runId,leaseToken,brief}. No cost, QA pass, role, URI or caller identity fields accepted.
brief has exactly:
{
"researchDate": "YYYY-MM-DD",
"inputAvailability": [{"input":"input name","status":"AVAILABLE|UNAVAILABLE|PARTIAL","details":"availability explanation"}],
"findings": [{"sourceUrl":"https://public-source.example.org/path","sourceDate":"YYYY-MM-DD","finding":"source-backed finding"}],
"candidates": [
{"title":"Distinct candidate A","score":80,"rationale":"Reason","sourceUrls":["https://public-source.example.org/path"]},
{"title":"Distinct candidate B","score":70,"rationale":"Reason","sourceUrls":["https://public-source.example.org/path"]},
{"title":"Distinct candidate C","score":60,"rationale":"Reason","sourceUrls":["https://public-source.example.org/path"]}
]
}
Limits: canonical brief UTF-8 <=24,576 bytes; 1..10 inputs (name 120/details 500 characters); 1..20 findings (HTTPS DNS URL 2000/finding 1000 characters); 3..10 unique candidates (title 180/rationale 1000, integer score 0..100, 1..10 source references all in findings). Dates must be valid calendar dates, not future; source dates cannot exceed research date. Unknown nested keys rejected. Example URLs above illustrate shape only, not real research evidence.
Canonical artifact kind EDITORIAL_RESEARCH_BRIEF is stored in append-only artifact metadata with SHA-256 and a URN; authenticated status retrieves actual bytes. No filesystem/external URL persistence dependency. Transaction atomically checks task/approval/lease/run/reservation, inserts evidence/event, closes outbox and moves task to VERIFYING. Run is AWAITING_QA, quality PENDING_INDEPENDENT_QA; no attestation, success, publication, Gate2 or release authorization is created. Unknown cost retains RESERVE 20 without RECONCILE. Replay after lease closure is rejected, not silently overwritten.
Validation checks structure/source references, not source truth, retrieval, novelty, scoring quality, SEO value or factuality. No research/article/LLM execution is performed by this contract. Independent QA ingestion is deliberately not implemented; generic tracer/tech and Stage evidence cannot certify this evidence.
Verification: disposable Node22 + PostgreSQL16, source/dependency donors read-only and privately copied, generated Prisma client. New suite observed RED (missing routes) then GREEN. Final combined bridge/execution/tech/transport suites: 22/22; npm run build: exit 0. Full historical migrations fail on fresh database because pre-existing blog migration expects missing blogs table; final tests instead applied only real orchestration core, immutable-ledger and outbox migrations directly to empty disposable DB, including append-only triggers. No live database, proposal approval, cron, deployment or publication used.