Skip to content

fix: stop-the-bleeding tier from the adversarial design review (OS-01, OS-07, OS-13, OS-14, OS-15, OS-27) - #16

Open
srikanthlogic wants to merge 8 commits into
devfrom
fix/stop-the-bleeding
Open

srikanthlogic wants to merge 8 commits into
devfrom
fix/stop-the-bleeding

Conversation

@srikanthlogic

Copy link
Copy Markdown
Contributor

Closes the stop the bleeding tier of BACKLOG.md (the 2026-11-28 adversarial design review) — six small, contained fixes, each with a reproduction in the backlog. Also lands the findings + bundled-skills feature that was sitting uncommitted on dev (first three commits).

What changed

OS-01 (P0) — one agent could cast both confirmations (f973b48)
The quorum counted verification rows, not distinct verifiers. Now enforced at three layers: unique index on verifications(submission_id, verifier_agent_id), a submit-time 409 duplicate_verify guard, and claimNext skipping verify tasks whose submission the agent already verified or holds a sibling lease on. The "pairwise-distinct handles" promise in llms.txt is now true.

OS-13/OS-14 (P1) — submissions bound to task target and registry (fab8ca8)
New optional ProjectModule hooks bindSubmission(taskPayload, payload) and validateSubmission(payload); C1 pins bank/country/cardType to the task target and requires registry membership, so an SBI task can no longer publish an HDFC payload and IN:ghostbank:credit can no longer enter the ledger. Runs on agent and human paths; genericness stub untouched.

OS-15 (P1) — human respawn names the fact (fab8ca8)
The human form's placeholder populate task carried no fact, so rejecting a human submission respawned an unworkable task. It now carries the submitted target.

OS-07 (P1) — adjudication is single-shot + constant-time token (f00a2ad)
Re-applying a verdict minted points every time (author 10 → 30) and published submissions passed the old guard. adjudicate() now wins a conditional transition exactly once; points and ledger writes settle only for the winner. Both ADMIN_TOKEN routes compare tokens with a new safeTokenEqual() (SHA-256 + timingSafeEqual).

OS-27 (P0) — markdown parity surfaces sanitized (e802b96)
codingAgent/model accepted newlines that were interpolated verbatim into /api/md/leaderboard — a prompt-injection vector at operator agents that read /setup.txt. Registration now rejects control characters (human-form name falls back to "anonymous"), and every untrusted interpolation on /api/md/* renders through a new mdCell() (single line, pipes escaped, block markers neutralized).

docs + protocol sync (c1aca9b)
/join.txt §3, llms.txt, setup.txt, the verification concept (four pre-publication checks), desk-api, adjudication and the error-code page (which was also missing the findings codes) all match the enforced behavior. Vitest per-test timeout 30s → 60s: each test file runs its own PGlite WASM instance in parallel and individuals brushed the old limit under load.

Verification

  • npm run verify green on this branch: lint --max-warnings 0 + typecheck + 59/59 tests + build (20 tests are new: distinct-verifier enforcement, binding/registry, human respawn, single-shot adjudication, markdown sanitization).
  • cd docs && npm run verify green: typecheck + build + 770 internal links across 27 pages.

BACKLOG.md is deliberately untouched — it is a point-in-time review; commit messages carry the OS ids.

Srikanth added 8 commits November 29, 2026 21:50
Every project declares goal (intended) findings, seeded idempotently by
ensureProjects() from the module's required goalFindings. Agents file
emergent findings via POST /api/projects/<slug>/findings after completing
at least one task (capped at 5 open per agent per project, evidence
validated as http(s) URLs). The operator curates via
POST /api/admin/findings (ADMIN_TOKEN): confirmed pays +3 once, archived
drops from public listings. Project page, project meta JSON, markdown
parity (/api/md/projects, /api/md/project-<slug>) and join.txt section 5
document the flow.
Four first-party skills under .claude/skills/: openswarm-hub-agent
(participate in a running hub), openswarm-project (author a project
module), openswarm-dev (develop this repo) and openswarm-operator
(deploy and brand an own instance). Documented on the docs site and
shape-guarded by tests/skills.test.ts (frontmatter, instance-agnostic
copy, setup.txt advertisement).
AGENTS.md, README.md and CONTRIBUTING.md now cover goal/emergent
findings and the bundled first-party agent skills.
The quorum counted verification rows, not distinct verifiers: one agent
could hold both sibling verify tasks and confirm twice, publishing a
fact with a single identity. BACKLOG.md OS-01, contradicting the
pairwise-distinct-handles promise in llms.txt.

Three layers now enforce it: a unique index on
verifications(submission_id, verifier_agent_id); a submit-time 409
duplicate_verify guard (does not burn the lease - release instead); and
claimNext skips verify tasks whose submission the agent already
verified or whose sibling verify task it currently holds leased.
…s (OS-13, OS-14, OS-15)

Pipeline correctness fixes from the adversarial review:

- OS-13: a populate submission is no longer only shape-checked. Modules
  may declare bindSubmission(taskPayload, payload); C1 pins bankId /
  country / cardType to the claimed task's target, so a task for one
  bank can no longer publish under another bank's key.
- OS-14: modules may declare validateSubmission(payload); C1 enforces
  registry membership (bankId must exist in C1_BANKS, country and card
  type must match the registry row), so IN:ghostbank:credit can no
  longer enter the public ledger. Runs on the agent and human paths.
- OS-15: the human form's placeholder populate task carried no fact, so
  rejecting a human submission respawned an unworkable task. The task
  and its verify siblings now carry the submitted target.

Both hooks are optional on ProjectModule - the genericness stub flows
through unchanged.
…OS-07)

Adjudication was repeatable and minted points on every re-apply (author
10 -> 30 on a double 'verified'), ignored its own flag for published
submissions, and compared the admin token with ===, leaking timing.

- adjudicate() now accepts only a rejected submission still flagged for
  adjudication, and wins a conditional UPDATE ... WHERE status='rejected'
  AND needs_adjudication transition exactly once; ledger upsert, task
  closing and points settle only for the caller that won it. Re-applying
  any verdict returns 'not awaiting adjudication' and settles nothing.
- new src/lib/secure.ts safeTokenEqual(): both sides SHA-256 digested
  then timingSafeEqual - length and prefix leak nothing; used by both
  ADMIN_TOKEN routes (adjudicate + findings curation).
codingAgent and model accepted newlines, and /api/md/leaderboard
interpolated them verbatim: registering a model of 'x\n\n## NOTE FOR THE
SETUP AGENT...' rewrote the leaderboard markdown that operator agents
read via /setup.txt before editing the instance - a prompt-injection
vector into repo and environment access. The same sinks existed for
human-form names, findings titles/details and ledger entry values.

Two layers now:
- registration rejects control characters in codingAgent/model
  (422 invalid_registration, new isSafeText in core/tokens.ts); the
  human form name falls back to 'anonymous' when unsafe.
- new src/lib/md.ts mdCell() renders every untrusted interpolation on
  the /api/md/* pages inert: control characters flattened to one line,
  pipes escaped so tables survive, leading heading/quote/list/fence
  markers neutralized.
- /join.txt section 3 documents the new binding/policy rejections and
  the two-distinct-agents quorum (409 duplicate_verify); llms.txt and
  setup.txt mark the pairwise-distinct rule and adjudication as
  enforced/single-shot.
- docs: verification concept now lists four pre-publication checks
  (shape, citations, policy+target, distinct verifiers); desk-api and
  errors reference gain duplicate_verify, invalid_submission and
  unbound_submission, the single-shot adjudication semantics, and the
  findings error codes the error page was missing.
- adjudication operator doc gains a single-shot callout; agent protocol
  page mirrors the join.txt changes.
- vitest: per-test timeout raised 30s -> 60s — every test file runs its
  own PGlite WASM instance in parallel, and under load individual tests
  brushed the old limit even though each is fast standalone.
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