Skip to content

fix(protocol): document the §9.2 federation headers and responses in openapi.json - #15

Merged
alpha912 merged 1 commit into
mainfrom
alpha/trusting-darwin-kdwngg
Oct 23, 2026
Merged

alpha912 merged 1 commit into
mainfrom
alpha/trusting-darwin-kdwngg

Conversation

@alpha912

Copy link
Copy Markdown
Contributor

Summary

SPECIFICATION.md §9.2 says node-to-node requests MUST send X-Node-ID, X-Node-Signature and X-Timestamp, and the reference backend enforces this (apps/backend/src/routes/federate.ts). But protocol/openapi.json declared none of these headers on POST /api/v1/federate/announce or /federate/offer, and listed only 202. A client generated from the reference contract therefore always got an undocumented 401.

  • openapi.json
    • Adds three shared, required header parameters under components.parameters (XNodeId, XNodeSignature, XTimestamp, the last typed date-time with the ±5 minute rule). Both federate operations reference them.
    • Both operations now list 400 (invalid body, or a missing or malformed X-Timestamp) and 401 (missing node headers or credentials, or a stale timestamp), matching what the route returns.
    • Security is unchanged: the operations still inherit BearerAuth, which the backend accepts alongside X-API-Key.
  • SPECIFICATION.md §8.2: the two federate request examples now show all three §9.2 headers; before, they showed only X-Node-Signature. No normative text changed.
    • Adding those lines shifted 10 pinned clauses, so profiles/core-dp/requirements/spec-v0.2.0-normative-manifest.json is re-pinned. Only source_line values change; ids and statement hashes are untouched.
  • New apps/backend/tests/openapi.federate.test.ts: checks that every header the contract declares is actually enforced by the route, and that every rejection status the route returns is documented. All 4 cases fail against the old contract.
  • The site mirror is re-synced, and the protocol CHANGELOG.md is updated.

Not in this PR: @apidevtools/swagger-parser rejects servers[0].variables.node on main as well ("unevaluated properties"). Without the servers block, both main and this branch validate. That pre-existing issue looks like a validator quirk with OpenAPI 3.1 server variables, and it isn't touched here.

Tree(s) touched

  • apps/backend (test only)
  • apps/site (mirror re-sync only)
  • protocol
  • ops/org-profile
  • ops/ledger, scripts/, .github/ or root files

How was this tested?

  • bash scripts/ci-local.sh (all targets): pass. This includes npm run test in protocol/, which checks the re-pinned manifest against the spec, and the conformance gate.
  • Backend bun test against a scratch localloop_test DB: 382 pass, 0 fail.
  • Site bun run build and bun run test: 53 pass, including the internal link and anchor check. The rendered spec shows the new headers.
  • @apidevtools/swagger-parser 10.1.1: with servers removed, both main and this branch validate as OpenAPI 3.1 with 14 paths.

Checklist

  • bash scripts/ci-local.sh passes locally.
  • Tests added or updated where behaviour changed.
  • protocol/ changed: the site mirror was re-synced, check:conformance passes, git status --short shows no deletions, and the normative manifest was re-pinned.
  • protocol/CHANGELOG.md ## [Unreleased] updated.
  • No secrets, .env files, dumps or apps/backend/data/ content included.
  • Outward-facing wording stays "lab demo only".
  • Commit messages follow Conventional Commits and contain no tool attribution or co-author trailers for tools.
  • Contributed under the licence of the area touched.

Generated by Claude Code

…openapi.json

POST /api/v1/federate/announce and /federate/offer declared neither the
X-Node-ID, X-Node-Signature and X-Timestamp headers SPECIFICATION.md §9.2
makes mandatory nor the 400/401 responses the reference backend returns,
so a client generated from the contract always got an undocumented 401.

- openapi.json: shared required header parameters under
  components.parameters, referenced by both operations, plus 400 and 401.
- SPECIFICATION.md §8.2: the federate examples show all three headers;
  the Core-DP normative manifest is re-pinned for the shifted lines.
- Backend test: every header the contract declares is enforced by the
  route, and every rejection status is documented.
- Site mirror re-synced.
@alpha912
alpha912 merged commit e2aab08 into main Oct 23, 2026
5 checks passed
@alpha912
alpha912 deleted the alpha/trusting-darwin-kdwngg branch October 23, 2026 21:21
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.

2 participants