Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

docs(protocol): publish ANS and Nostr federation governance draft (#3299)

rUv39e0b0540c9b
diff --git a/docs/protocol/README.md b/docs/protocol/README.md
new file mode 100644
index 0000000000..16aa4f264e
--- /dev/null
+++ b/docs/protocol/README.md
@@ -0,0 +1,28 @@
+# Ruflo Federation Protocol
+
+Publication: 0.1.0 draft, 2026-09-12. Status: open implementation proposal, not a ratified industry standard or an accepted Nostr NIP.
+
+These specifications let independent implementers distinguish a name, a signing key, an authenticated request and permission to execute. No Cognitum account, proprietary gateway or model is required by the proposed protocol. A deployment can impose its own admission policy.
+
+| Document | Scope | Status |
+| --- | --- | --- |
+| [ANS](ans.md) | Existing local identity binding and proposed Nostr binding | Documented v2 alpha plus explicit extension |
+| [HTTP authentication](http-auth.md) | Strict application profile of upstream NIP-98 | Proposed receiver requirements |
+| [Signed messages](signed-messages.md) | Existing wire format and versioned machine payload | Legacy description plus proposed profile |
+| [Governance](governance.md) | Changes, registries, adoption and release gates | Proposed process |
+| [Evidence](evidence.md) | Source snapshots, checks, gaps and conformance matrix | Review evidence |
+
+Capitalized MUST, MUST NOT, SHOULD and MAY express requirements for the named profile. Requirements labelled proposed do not imply existing implementations enforce them. The draft does not amend upstream NIPs. Existing project licenses apply; this proposal grants no third party patent rights and makes no patent clearance claim.
+
+## Implementer entry point
+
+1. Pin the draft version and source commit. Select ANS local v2, HTTP strict v1, message v1, or a stated combination.
+2. Implement the normative documents and negative cases in the evidence matrix. Preserve exact signed bytes.
+3. Publish implementation version, source hash, test inputs, outputs and deviations. A green syntax check is not conformance.
+4. Propose changes through a public pull request. Do not silently change deployed protocol semantics.
+
+## Interoperability boundary
+
+ANS currently uses Ed25519. Nostr uses Schnorr signatures over secp256k1. Keys are not interchangeable. Names and discovery records do not grant authority. A valid message proves authorship of its signed bytes, not task execution, capability ownership or truth of its claims. OAuth gateway publication is attributable to the gateway key unless an independently verified user proof accompanies it.
+
+The current ANS source is [ruvnet/Agent-Name-Service](https://github.com/ruvnet/Agent-Name-Service). The current federation source is this repository's `plugins/ruflo-x-gateway`. The proposed profiles are transport independent where specified; they do not require x.ruv.io as a trust root.
diff --git a/docs/protocol/SHA256SUMS b/docs/protocol/SHA256SUMS
new file mode 100644
index 0000000000..5d2dc3c886
--- /dev/null
+++ b/docs/protocol/SHA256SUMS
@@ -0,0 +1,10 @@
+980266d27d5ab680b865cf7715f9354982d13f8b0ea41f60ee5426bdcdd87570 README.md
+4966e24a1f502351409096c43c18c36b77641bb3038d4a3fb27ebb398032a7dd ans.md
+cf83b366deb6d6817ca3ae1e943b60d3a52df260f10ee9bbc6388100b307f846 evidence.md
+4698f1d426a17363b8969b873eed488fabeb23c0797e9bcc2eddd2a39327dd05 fixture-package-lock.json
+033a6c3ed623a962bcfac7b50f11e2f5e8c53e0dd55d78e453e517a41fd34ebb fixture-package.json
+cdd7e0ff34a357ef4c9551a016818aa539062a277666d78e1ff119b330e5f01f governance.md
+e6f495a02f145ca7e2e4e9e42632043c1056509241b7131ad7c629df5130e567 http-auth.md
+0fc838d16ae1154d306bef261179ac732266bef11d56586f684a5a08b5fb0846 signed-messages.md
+2155f921ad04ed1d893419932a5e9b20d42295adb62ca0e93ff2f7af4ebdf188 vectors.json
+ab78c3e7652076b97a3fd7365ae2930d318a3fa1bff76e7678f0cf6ce990e369 verify-vectors.mjs
diff --git a/docs/protocol/ans.md b/docs/protocol/ans.md
new file mode 100644
index 0000000000..ae54ad1f9d
--- /dev/null
+++ b/docs/protocol/ans.md
@@ -0,0 +1,55 @@
+# RFP ANS: identity and name binding
+
+Version 0.1.0 draft. Profile `ans-local-v2` describes the supported local API. Profile `ans-nostr-binding-v1` is proposed and unimplemented in the inspected source.
+
+## 1. Authority and scope
+
+A name is unique only inside one registry controlled by one pinned issuer. Implementers MUST identify names externally as the pair (trusted issuer, name); a bare name MUST NOT be interpreted as globally unique. Bootstrap issuer trust through operator configuration, not through an untrusted binding. This document does not claim compatibility with OWASP ANS, DNS, NIP-05 or X.509. Historical TypeScript code is outside the supported v2 profile.
+
+## 2. Local binding wire object
+
+The object has exactly seven members. Unknown members are rejected.
+
+| Member | Type and requirement |
+| --- | --- |
+| `id` | String matching `[a-f0-9-]{36}`; issuer emits a random UUID. The legacy validator does not enforce UUID layout. |
+| `name` | String matching `^[a-z0-9][a-z0-9._-]{0,63}$`; no automatic case conversion |
+| `subject` | Ed25519 public key in SPKI PEM, at most 1024 characters |
+| `issuer` | Ed25519 SPKI PEM; exact string equality with pinned issuer |
+| `issuedAt` | Safe integer, Unix milliseconds |
+| `expiresAt` | Safe integer, Unix milliseconds; greater than issuedAt; lifetime at most 86400000 ms |
+| `signature` | Standard base64 encoding of 64 Ed25519 signature bytes, 88 characters with `==` padding |
+
+Signing input is UTF-8 encoding of compact ECMAScript JSON serialization of this ordered array:
+
+```json
+["ans-v2", "id", "name", "subject PEM", "issuer PEM", 0, 3600000]
+```
+
+The displayed whitespace is illustrative. Implementations MUST produce the same bytes as `JSON.stringify(['ans-v2', b.id, b.name, b.subject, b.issuer, b.issuedAt, b.expiresAt])`. Object member order is irrelevant. PEM strings, embedded newlines and spelling are signed verbatim; do not normalize them after issuance. Sign with Ed25519 directly, with no additional prehash. A verifier checks the field constraints, pinned issuer, signature, and `issuedAt <= now < expiresAt`. Default issuance lifetime is 3600000 ms. The local implementation permits no future clock skew.
+
+## 3. Registry and possession
+
+Registration MUST validate the binding and atomically enforce name and ID uniqueness, revocation tombstones and configured capacity. Default capacity is 10000; supported configured range is 1 through 1000000. Resolution MUST recheck expiration and revocation. Revocation durably tombstones the ID and removes the active name. Reissuing a name requires a fresh binding ID; it is not continuity of the former subject. Expired rows currently remain until revoked; automatic expiry cleanup is not part of the inspected implementation.
+
+The server generates a random 32 byte nonce encoded as 64 lowercase hex characters and records it with the exact audience string and a 60000 ms expiry. Audience is 1 through 256 ECMAScript string code units. The subject signs UTF-8 compact JSON:
+
+```json
+["ans-proof-v2", "binding ID", "nonce", "audience"]
+```
+
+Authentication MUST verify the active binding, subject signature, expected audience, stored nonce and unexpired challenge, and atomically consume the nonce with success. Concurrent reuse MUST yield at most one success. Proof verification alone does not implement this transaction. Existing `verifyBinding` and MCP verification do not consult revocation; they MUST NOT be represented as registry authentication. Database operators own filesystem protection, backup and issuer recovery.
+
+## 4. Proposed Nostr identity binding
+
+Keep the ANS binding unchanged. Publish a separate Nostr event using the message v1 profile with message type `IdentityBinding`. Its payload has exactly `binding`, `nostrPubkey`, `audience`, `notBefore`, `expiresAt`, and `subjectProof`. `binding` is the complete ANS object above. `nostrPubkey` is the lowercase 64 hex event author. `audience` is the exact configured federation identifier. Times here are Unix seconds and must be safe integers.
+
+`subjectProof` is an Ed25519 signature in standard padded base64 over UTF-8 compact JSON of:
+
+```json
+["ans-nostr-binding-v1", "binding ID", "nostrPubkey", "audience", 0, 3600]
+```
+
+The last two values are notBefore and expiresAt. The receiver MUST verify both the ANS issuer binding and this subject proof, and the outer Nostr event signature. Require `notBefore <= now < expiresAt`, `notBefore < expiresAt`, `notBefore * 1000 >= binding.issuedAt`, and `expiresAt * 1000 <= binding.expiresAt`. Multiplication must remain in the safe integer range. Payload audience and outer message audience MUST agree. Outer expiry MUST equal payload expiry. Revocation status MUST be obtained from the authoritative registry for execution; if unavailable, fail closed. Offline display may show the binding only as revocation unchecked.
+
+This is a proposed dual possession binding, not a conversion between curves. It grants no execution rights. Rotation revokes the old ANS binding, issues a fresh ID and publishes a fresh dual proof. Receivers invalidate cached old bindings. There is no automatic recovery from issuer compromise: operators must distribute a new trust anchor out of band. No HTTP discovery endpoint or global name consensus is assigned by this draft.
diff --git a/docs/protocol/evidence.md b/docs/protocol/evidence.md
new file mode 100644
index 0000000000..10c2a42551
--- /dev/null
+++ b/docs/protocol/evidence.md
@@ -0,0 +1,75 @@
+# Evidence and conformance plan
+
+Review date: 2026-09-12. Publication status: Draft. No production deployment, live attack, membership change or full protocol conformance claim is made.
+
+## Source provenance
+
+| Input | Inspected revision and paths |
+| --- | --- |
+| Ruflo | `005a0ed25e644778f767cd78754fe91d660466af`: `plugins/ruflo-x-gateway/src/nostr-federation.mjs`, `relay-admin.mjs`, and `v3/@claude-flow/cli/src/mcp-tools/x-federation-join.ts` |
+| ANS | `0565783df31da2d98729c27f02551f49478b8393`: `v2/identity.mjs`, `v2/identity.test.mjs`, README |
+| Nostr | Upstream NIP-01 and NIP-98 master documents consulted on review date; a Stable release must pin their commit revisions |
+| Cognitum | `docs_search` consulted for ANS, authentication and federation. It returned device Ed25519 documentation but no authoritative ANS/Nostr protocol specification |
+| Cognitum assisted review | Federation `seraphina_guidance` through the Cognitum model gateway provided read-only governance advice; its roster and expiry conclusions were not independently validated and are not adopted as findings |
+
+## Validation performed
+
+Node v24.19.0. Existing ANS `npm test`: 10 passed, 0 failed. The new fixture verifier: 12 passed, 0 failed. The latter verifies signed bytes, tamper cases and dual possession signatures only; it does not implement the normative receive algorithm.
+
+Ruflo harness used `npx -y @claude-flow/[email protected] memory search --query 'ANS Nostr protocol governance'`; the fresh checkout had no memory database. Read-only security scan used `npx -y @claude-flow/[email protected] security scan --target plugins/ruflo-x-gateway/src --depth deep --type all` and reported zero issues. The scan did not identify the metadata overwrite found during manual source inspection. No advisory feed timestamp was exposed, and dependency CVE coverage was not established. Zero scanner findings is not a security release gate.
+
+The fixture runtime pins `[email protected]`; this is a reproducibility pin, not a latest-version or vulnerability-free recommendation. Fixture generation used fresh nonproduction keys; only public keys and signatures are retained. All time-based tests must use the fixture time, not wall clock time. See `vectors.json`. The accompanying `fixture-package-lock.json` freezes transitive dependencies; original SHA256 is `4698f1d426a17363b8969b873eed488fabeb23c0797e9bcc2eddd2a39327dd05`.
+
+To repeat the cryptographic checks from the repository root, copy `fixture-package.json` and `fixture-package-lock.json` into a temporary directory as `package.json` and `package-lock.json`, run `npm ci --ignore-scripts` there, and supply the absolute installed module path:
+
+```sh
+NOSTR_PURE_MODULE=/absolute/runtime/node_modules/nostr-tools/lib/esm/pure.js node docs/protocol/verify-vectors.mjs
+```
+
+Expected result: `checks: 12`, `fullConformance: false`. ANS functional tests run separately from its pinned repository with `npm test`.
+
+## Confirmed source gaps
+
+1. `fetchRecent`, `fetchManyOn`, and public `fetchChannel` spread parsed body fields after verified metadata. Thus signed content may override displayed `pubkey`, `id`, timestamp or channel. The signature remains valid for the actual author while the flattened result can misattribute it. Severity depends on downstream authorization use, which this documentation review does not establish. Remediation: preserve `{event, message}` and add reserved-field collision regression tests before v1 promotion.
+2. `publish` spreads the payload after generated `type` and `ts`; callers can introduce conflicting body type and k tag. Remediation: separate envelope fields and reject collisions; do not normalize already signed content.
+3. ANS is explicitly local and Ed25519 based. Nostr identity binding, distributed issuer discovery and global name uniqueness are not implemented. The proposed extension is not deployed by publishing these documents.
+4. NIP-98 receiver replay storage, URL reconstruction and transactional side effects are outside the inspected client. Their enforcement is unknown, not proven absent.
+
+## Threat model
+
+| Asset and boundary | Failure | Required control | Residual risk |
+| --- | --- | --- | --- |
+| Key to identity | Curve confusion or forged binding | Distinct suites, pinned issuer, dual proofs | Compromised issuer requires trust reset |
+| HTTP request to handler | Replay or body substitution | Exact body digest, URL binding, durable atomic consumption | Crash recovery requires application integration |
+| Relay event to execution | Metadata shadowing or unauthorized commands | Separate verified event, schema and capability gate | Valid sender can still submit harmful data |
+| Registry to receiver | Stale or revoked name | Authoritative revocation check and expiry | Registry outage denies execution |
+| Parser to verifier | Oversize input or ambiguous JSON | Precheck limits and duplicate rejection | Rate limiting remains deployment specific |
+| Draft to ecosystem | False standard or conformance claims | Independent review, fixtures, public receipts | Adoption cannot be compelled |
+
+## Required conformance matrix
+
+These are normative acceptance cases for a future Candidate harness. Only rows explicitly marked tested have been executed. This matrix is not a full test suite.
+
+| ID | Case and expected outcome | Evidence state |
+| --- | --- | --- |
+| A01 | Valid binding accepted; changed name, unknown field, wrong issuer, invalid key, future or expired binding rejected | Existing ANS tests passed |
+| A02 | Challenge accepted once; wrong audience, unknown or expired challenge rejected | Existing ANS tests passed |
+| A03 | Replay and revocation survive reopen; duplicate names and capacity denied | Existing ANS tests passed |
+| A04 | Dual Ed25519 and Nostr fixture signatures verify | Fixture tests passed |
+| A05 | Wrong bound key, wrong federation, expired dual proof, revoked binding or unavailable registry denied | Required, not run |
+| H01 | HTTP event verifies; changing URL or method invalidates signature; changed entity digest differs | Fixture tests passed |
+| H02 | Exact query ordering, escaped path and trusted proxy origin accepted only when equal | Required, not run |
+| H03 | Time boundary plus/minus 60 accepted; 61 rejected; duplicate security tags and duplicate JSON rejected | Required, not run |
+| H04 | Empty mutation entity requires correct digest; altered bytes and content encoding rejected | Required, not run |
+| H05 | Concurrent and post-restart auth reuse cannot execute twice; replay outage denies | Required, not run |
+| M01 | Machine event signature verifies; any content tampering rejected | Fixture tests passed |
+| M02 | Wrong recipient/audience, expiry, unsupported version/critical extension denied | Required, not run |
+| M03 | Valid signed payload with forged metadata cannot change verified author or channel | Required, source gap confirmed |
+| M04 | Same operation/content returns recorded result; changed content produces conflict | Required, not run |
+| M05 | Crash during side effect leads to reconciliation; replay across two workers has at most one effect | Required, not run |
+| M06 | Unknown executable type and unauthorized command denied; legacy readable but not auto-executed | Required, not run |
+| G01 | Two independent implementations exchange fixtures and pass every required case | Not established |
+
+## Release decision
+
+Publish as Draft with gaps intact. Next work is receiver implementation, metadata isolation remediation and the full adversarial conformance harness. No benchmark or scanner score can waive identity, replay or permission invariants. The acceptance test for Stable is G01 plus the public review gates in governance.md.
diff --git a/docs/protocol/fixture-package-lock.json b/docs/protocol/fixture-package-lock.json
new file mode 100644
index 0000000000..f19b3c5ca8
--- /dev/null
+++ b/docs/protocol/fixture-package-lock.json
@@ -0,0 +1,140 @@
+{
+ "name": "protocol-runtime",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "dependencies": {
+ "nostr-tools": "^2.7.2"
+ }
+ },
+ "node_modules/@noble/ciphers": {
+ "version": "0.5.3",
+ "resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-0.5.3.tgz",
+ "integrity": "sha512-B0+6IIHiqEs3BPMT0hcRmHvEj2QHOLu+uwt+tqDDeVd0oyVzh7BPrDcPjRnV1PV/5LaknXJJQvOuRGR0zQJz+w==",
+ "license": "MIT",
+ "funding": {
+ "url": "https://paulmillr.com/funding/"
+ }
+ },
+ "node_modules/@noble/curves": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz",
+ "integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==",
+ "license": "MIT",
+ "dependencies": {
+ "@noble/hashes": "1.3.2"
+ },
+ "funding": {
+ "url": "https://paulmillr.com/funding/"
+ }
+ },
+ "node_modules/@noble/curves/node_modules/@noble/hashes": {
+ "version": "1.3.2",
+ "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz",
+ "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 16"
+ },
+ "funding": {
+ "url": "https://paulmillr.com/funding/"
+ }
+ },
+ "node_modules/@noble/hashes": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz",
+ "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 16"
+ },
+ "funding": {
+ "url": "https://paulmillr.com/funding/"
+ }
+ },
+ "node_modules/@scure/base": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.1.tgz",
+ "integrity": "sha512-ZxOhsSyxYwLJj3pLZCefNitxsj093tb2vq90mp2txoYeBqbcjDjqFhyM8eUjq/uFm6zJ+mUuqxlS2FkuSY1MTA==",
+ "funding": [
+ {
+ "type": "individual",
+ "url": "https://paulmillr.com/funding/"
+ }
+ ],
+ "license": "MIT"
+ },
+ "node_modules/@scure/bip32": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.3.1.tgz",
+ "integrity": "sha512-osvveYtyzdEVbt3OfwwXFr4P2iVBL5u1Q3q4ONBfDY/UpOuXmOlbgwc1xECEboY8wIays8Yt6onaWMUdUbfl0A==",
+ "license": "MIT",
+ "dependencies": {
+ "@noble/curves": "~1.1.0",
+ "@noble/hashes": "~1.3.1",
+ "@scure/base": "~1.1.0"
+ },
+ "funding": {
+ "url": "https://paulmillr.com/funding/"
+ }
+ },
+ "node_modules/@scure/bip32/node_modules/@noble/curves": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.1.0.tgz",
+ "integrity": "sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==",
+ "license": "MIT",
+ "dependencies": {
+ "@noble/hashes": "1.3.1"
+ },
+ "funding": {
+ "url": "https://paulmillr.com/funding/"
+ }
+ },
+ "node_modules/@scure/bip39": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.2.1.tgz",
+ "integrity": "sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==",
+ "license": "MIT",
+ "dependencies": {
+ "@noble/hashes": "~1.3.0",
+ "@scure/base": "~1.1.0"
+ },
+ "funding": {
+ "url": "https://paulmillr.com/funding/"
+ }
+ },
+ "node_modules/nostr-tools": {
+ "version": "2.7.2",
+ "resolved": "https://registry.npmjs.org/nostr-tools/-/nostr-tools-2.7.2.tgz",
+ "integrity": "sha512-Bq3Ug0SZFtgtL1+0wCnAe8AJtI7yx/00/a2nUug9SkhfOwlKS92Tef12iCK9FdwXw+oFZWMtRnSwcLayQso+xA==",
+ "license": "Unlicense",
+ "dependencies": {
+ "@noble/ciphers": "^0.5.1",
+ "@noble/curves": "1.2.0",
+ "@noble/hashes": "1.3.1",
+ "@scure/base": "1.1.1",
+ "@scure/bip32": "1.3.1",
+ "@scure/bip39": "1.2.1"
+ },
+ "optionalDependencies": {
+ "nostr-wasm": "v0.1.0"
+ },
+ "peerDependencies": {
+ "typescript": ">=5.0.0"
+ },
+ "peerDependenciesMeta": {
+ "typescript": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/nostr-wasm": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/nostr-wasm/-/nostr-wasm-0.1.0.tgz",
+ "integrity": "sha512-78BTryCLcLYv96ONU8Ws3Q1JzjlAt+43pWQhIl86xZmWeegYCNLPml7yQ+gG3vR6V5h4XGj+TxO+SS5dsThQIA==",
+ "license": "MIT",
+ "optional": true
+ }
+ }
+}
diff --git a/docs/protocol/fixture-package.json b/docs/protocol/fixture-package.json
new file mode 100644
index 0000000000..ca9d9dba79
--- /dev/null
+++ b/docs/protocol/fixture-package.json
@@ -0,0 +1,5 @@
+{
+ "dependencies": {
+ "nostr-tools": "^2.7.2"
+ }
+}
diff --git a/docs/protocol/governance.md b/docs/protocol/governance.md
new file mode 100644
index 0000000000..f6a760e4d0
--- /dev/null
+++ b/docs/protocol/governance.md
@@ -0,0 +1,37 @@
+# Protocol governance proposal
+
+Version 0.1.0 draft. This document proposes a public review process; it does not claim a standards body or independent governing council already exists.
+
+## Ownership and participation
+
+The repository's existing maintainers are initial editors. Editing authority is not authority to claim ecosystem adoption. Anyone may submit an issue, implementation report, erratum or pull request. Review comments, decisions and dissent remain public, except vulnerability details under coordinated disclosure. No vendor account is required to implement the specification.
+
+Maintainers should recruit at least two independent organizations as reviewers. Affiliations and conflicts are disclosed in review records. Paid sponsorship, model output, swarm votes and automated scores do not count as independent technical review. No participant can self-certify interoperability by running the same implementation under two names.
+
+## Lifecycle
+
+| State | Required evidence |
+| --- | --- |
+| Draft | Source map, threat model, explicit normative requirements and known gaps |
+| Candidate | Two named reviewers, including one security reviewer; schemas and positive/negative vectors; no unresolved critical ambiguity |
+| Stable | At least two independently maintained implementations from two organizations pass the same conformance suite, including persistence and failure cases; minimum 30 calendar days public candidate review; all blocking comments resolved publicly |
+| Deprecated | Successor, reason, compatibility mapping and at least 180 days migration notice unless an active security incident requires an expedited change |
+| Retired | Notice elapsed; archived immutable versions and migration guidance retained |
+
+Stable approval requires two approving maintainers including a reviewer independent of the submitting organization. Until that independence exists, the draft cannot become Stable. If a blocking disagreement remains, keep the lower status and document the disputed invariant. Appeal through a public issue with alternate evidence; a different uninvolved reviewer should chair the reconsideration. Proposal authors may not erase dissent.
+
+## Change control
+
+Every release freezes Markdown, schema, vectors, conformance harness version, source commit and SHA256 file manifest. Version major for incompatible semantics, minor for optional compatible extensions, patch for editorial corrections that do not change acceptance outcomes. Any changed valid/invalid result is semantic, not editorial. No in-place change to a released version. Record upstream NIP revisions used by a Stable release.
+
+The repository registry begins with profile IDs `ans-local-v2`, `ans-nostr-binding-v1`, `rfp-http-strict-v1`, `rfp-message-v1`; message type `IdentityBinding` has the ANS schema. `Status`, `Task` and `Result` are observed legacy labels, not complete command schemas. Additional executable types require a schema, permission contract and negative tests before registration. Unknown critical extensions fail closed. Extension records include name, owner, version, schema, collision review, security considerations and status. No NIP number or global name allocation is claimed by this local registry.
+
+## Security and intellectual property
+
+Report vulnerabilities using the repository's security reporting route. Editors may issue an immediate advisory and disable an unsafe implementation profile; the advisory must identify affected versions, mitigation and subsequent public errata when disclosure is safe. Do not publish keys, bearer invitations or private payloads in vectors. Use dedicated nonproduction keys for tests.
+
+Contributions remain subject to the repository license and contribution rules. Contributors disclose known relevant patent claims and licensing restrictions. A Stable release requires maintainers to record the chosen specification license and an explicit patent policy; this draft does not invent patent grants on behalf of contributors. Upstream Nostr compatibility and legal rights are separate gates.
+
+## Adoption acceptance test
+
+An independent team must implement from the documents without importing Ruflo or Cognitum code, then exchange valid messages and reject every negative vector against another implementation. Publish reproducible source revisions and receipts. Only then seek upstream Nostr review and ecosystem endorsement. Public documentation alone does not establish industry standard status.
diff --git a/docs/protocol/http-auth.md b/docs/protocol/http-auth.md
new file mode 100644
index 0000000000..f3cf2d4447
--- /dev/null
+++ b/docs/protocol/http-auth.md
@@ -0,0 +1,26 @@
+# RFP HTTP strict v1
+
+Version 0.1.0 draft. This is a stricter application profile of [upstream NIP-98](https://github.com/nostr-protocol/nips/blob/master/98.md), not a replacement NIP. Upstream remains the normative source for the base wire format.
+
+## 1. Base format
+
+Use a signed Nostr kind 27235 event in the `Authorization: Nostr <base64>` header. Bind the absolute URL with the `u` tag, method with `method`, and body digest with `payload`. URL comparison includes the query. Validate the Nostr event ID and signature, not merely its fields. Authentication establishes the signing key; permission is a separate check.
+
+## 2. Additional proposed requirements
+
+1. Accept HTTPS only outside explicitly configured loopback tests. The server MUST derive its external URL from a configured origin and raw request target. Trust forwarded headers only from configured proxies. Do not sort queries, decode and reencode paths, strip a trailing slash, or follow redirects using the old proof. Clients sign the exact final URL without fragment or userinfo.
+2. Require exactly one two-element `u` and `method` tag. Require uppercase method matching the request exactly. Require empty content. Reject duplicate security tags, duplicate JSON object members, malformed base64, invalid UTF-8, invalid event fields and unknown critical extensions. Ordinary unknown Nostr tags remain permitted.
+3. Require safe integer `created_at` in Unix seconds and `abs(now - created_at) <= 60`. Keep clocks synchronized. Store authenticated event IDs atomically through `created_at + 61` seconds, including future dated events. A consumed proof MUST NOT cause a second side effect, including across processes or restart. Fail closed if the shared replay store is unavailable or full.
+4. Require exactly one `payload` tag for every request with a nonempty body, and for every POST, PUT, PATCH or DELETE, including an empty body. Its value is lowercase SHA256 hex of the raw entity bytes passed to the application before JSON parsing, without content encoding. This profile rejects Content-Encoding other than absent or identity. Transfer framing is excluded from the hash. For an empty entity, hash the zero length byte string. If supplied on another method, validate it. Do not hash a parsed or reserialized object.
+5. Limit the decoded authorization event to 8192 bytes and the request entity to 32768 bytes. Check limits before expensive cryptography and impose per-source admission limits. A larger upload requires a separately versioned profile.
+6. Validate authorization and reserve the proof atomically before execution. A signature MUST NOT grant membership, admin role or the ability to publish on behalf of another identity. Gate sensitive operations by current capabilities, scope, audience, expiry and revocation. A restart durable operation ledger MUST suppress repeat effects even if the requester signs a fresh auth event for a retry. Use the signed application operation identifier defined in the message profile where applicable.
+
+## 3. Failure and retry
+
+Return 401 for invalid authentication or replayed auth proof, 403 for valid identity without permission, 413 for size violations, and 503 when safe replay or authorization checks cannot run. Do not return internal keys or invite codes in errors or logs. A transport retry generates a fresh auth proof but retains its application operation ID. A previous successful operation may return its recorded result; it MUST NOT execute again. A crash between a side effect and recording completion requires transactional integration or reconciliation, not a blind retry.
+
+## 4. Compatibility and boundary
+
+The inspected Ruflo client signs nonempty bodies. Receiver strictness, distributed replay persistence and proxy URL reconstruction are not proven by that client. Negotiate this profile through explicit endpoint configuration; do not silently reject legacy traffic on an existing endpoint without a migration window.
+
+NIP-42 WebSocket challenges remain a separate handshake. An OAuth token passed to the gateway can authorize a gateway action but is not a Nostr signature by the OAuth subject. Never substitute Ed25519 ANS keys for Nostr signing keys. No new NIP number is assigned.
diff --git a/docs/protocol/signed-messages.md b/docs/protocol/signed-messages.md
new file mode 100644
index 0000000000..067bc02641
--- /dev/null
+++ b/docs/protocol/signed-messages.md
@@ -0,0 +1,53 @@
+# RFP signed machine messages v1
+
+Version 0.1.0 draft. Legacy description is source observed; v1 is a proposed application profile.
+
+## 1. Existing transport
+
+The inspected gateway uses Nostr kind 1, `t=ruflo-swarm`, `k=<message type>`, and JSON content. Public channels use `c=pub:<name>`; private channels use opaque channel IDs and NIP-44 ciphertext. Private ciphertext is not a JSON v1 message on the wire and is outside this draft's execution profile. Relay acknowledgment is acceptance of an event, not proof of work.
+
+## 2. Signed envelope
+
+Use the upstream [NIP-01](https://github.com/nostr-protocol/nips/blob/master/01.md) event ID, serialization and signature rules. Preserve the original content string for verification. A receiver MUST verify an unmodified event before parsing content. Never flatten content into the verified `id`, `pubkey`, `created_at`, `kind`, `tags` or `sig` fields. Store `{event, message}` separately. The verified event author is the sender; a payload's claimed agent name is untrusted until separately bound.
+
+For v1 require exactly one two-element `t` tag equal to `ruflo-swarm`, one `k` tag equal to the content type, and one `rfp` tag equal to `1`. Kind remains 1 for compatibility. The application profile allocates no new Nostr event kind. Optional `c` must be unique and is limited to a configured public channel. Duplicate reserved tags are rejected. Unknown noncritical tags are permitted. Auth kind 27235 and relay auth kind 22242 MUST NOT be accepted as machine messages.
+
+## 3. Content schema
+
+Content is UTF-8 JSON, at most 32768 bytes. Reject duplicate JSON members, invalid UTF-8, nonfinite numbers and nesting deeper than 16 containers. Total serialized event limit is 65536 bytes. The top level contains exactly these members, with optional `critical` and `extensions`:
+
+| Member | Requirement |
+| --- | --- |
+| `protocol` | Literal `rfp` |
+| `version` | Integer 1 |
+| `type` | String matching `^[A-Za-z][A-Za-z0-9_-]{0,63}$`; matches k tag |
+| `audience` | Configured deployment identifier, exact string, 1 through 256 UTF-8 bytes |
+| `recipient` | Lowercase 64 hex public key of executing recipient; no wildcard |
+| `operationId` | 32 random bytes encoded as 64 lowercase hex characters; generated once per logical operation |
+| `expiresAt` | Safe integer Unix seconds; event.created_at < expiresAt <= event.created_at + 300 |
+| `payload` | JSON object with type-specific schema |
+| `critical` | Optional array of unique extension names; each must exist in extensions and be understood |
+| `extensions` | Optional object keyed by registered extension name |
+
+Example unsigned content (illustrative, not a cryptographic test vector):
+
+```json
+{"protocol":"rfp","version":1,"type":"Status","audience":"urn:example:federation:lab","recipient":"0000000000000000000000000000000000000000000000000000000000000000","operationId":"1111111111111111111111111111111111111111111111111111111111111111","expiresAt":1800000300,"payload":{"state":"ready"}}
+```
+
+The zeros are placeholders, not an assigned identity. No second JSON canonicalizer is applied to content. Equivalent JSON spelling produces different event IDs; both can be valid signatures, but deduplication uses the logical operation key below. Ed25519 envelopes from other Ruflo packages are not this wire format.
+
+## 4. Receive and execute algorithm
+
+1. Enforce size, structure, signature, tags and schema. Unsupported versions and critical extensions fail closed.
+2. Require configured audience and local recipient key. Require `created_at <= now + 60` and `now < expiresAt`. Check expiry again before executing queued work.
+3. Verify sender permissions through local policy, including current membership and revocation. Discovery, relay membership and a verified signature alone never permit shell execution or tool calls. Unknown message types may be archived as data but MUST NOT execute.
+4. Reserve `(verified sender pubkey, audience, recipient, operationId)` atomically in durable shared storage. Store the SHA256 digest of the exact content bytes. Duplicate with the same digest returns recorded status; duplicate with different bytes is `OPERATION_CONFLICT` and never replaces prior work. The operation ID is never reused by a sender.
+5. Bound application acceptance independently from relay retention. Keep operation tombstones at least 24 hours after completion or expiry, and longer than the local recovery horizon. Authorization for commands also requires a local capability or operation ledger whose consumed command identifier survives that horizon. This profile promises bounded deduplication, not perpetual exactly once delivery.
+6. Execute only an allowlisted handler with explicit resource and spend limits. Record `accepted`, `running`, `completed`, `failed` or `reconciliation_required`. If a side effect cannot be atomically coupled to its receipt, recover through reconciliation. A signed Result is the author's claim; verify artifact hashes and the required acceptance tests independently.
+
+## 5. Migration and failure codes
+
+Legacy messages without rfp=1 remain readable as legacy data and MUST NOT be auto-promoted into v1 executable commands. Advertise support through configuration or an independently authenticated capability record. During migration a gateway may dual read, but must not dual execute. Never silently reinterpret unknown versions as legacy executable content.
+
+Stable local rejection codes: `MALFORMED`, `SIGNATURE_INVALID`, `PROFILE_UNSUPPORTED`, `EXPIRED`, `AUDIENCE_MISMATCH`, `RECIPIENT_MISMATCH`, `UNAUTHORIZED`, `REPLAY_UNAVAILABLE`, `OPERATION_CONFLICT`. Relay error strings are not standardized here. Private execution, delegation chains, distributed name consensus and transport confidentiality beyond TLS require separate proposals.
diff --git a/docs/protocol/vectors.json b/docs/protocol/vectors.json
new file mode 100644
index 0000000000..1b239b0d49
--- /dev/null
+++ b/docs/protocol/vectors.json
@@ -0,0 +1,81 @@
+{
+ "fixtureTime": 1800000000,
+ "note": "Public test keys only. Verify time relative to fixtureTime; never use as production credentials.",
+ "binding": {
+ "id": "69682a8b-76e2-45e8-9b14-fd75037f4589",
+ "name": "worker.one",
+ "subject": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAgMJWGku5NFUn1bwCmkprBqtIjF25Jv10n/JKcKDviBw=\n-----END PUBLIC KEY-----\n",
+ "issuer": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAhpprXiSEabBjPEAA67fxrp6VbYbxSu48GeGfxv3mJyQ=\n-----END PUBLIC KEY-----\n",
+ "issuedAt": 1800000000000,
+ "expiresAt": 1800003600000,
+ "signature": "XeK8vhW3ApLB0Cg6+JY/aRjXbudosC8Y/e2dFG2vYXwC4jwZ2eVh1bpHQXvpLNFzT3pNH9Vz8+nS57VXf+GICQ=="
+ },
+ "bindingDigest": "b4624524bdde30a2e8caa813af2c9a1287786da236e7afc52b721ae19d3005d0",
+ "httpBody": "{\"operation\":\"fixture\"}",
+ "http": {
+ "kind": 27235,
+ "created_at": 1800000000,
+ "tags": [
+ [
+ "u",
+ "https://example.org/api/fixture"
+ ],
+ [
+ "method",
+ "POST"
+ ],
+ [
+ "payload",
+ "e982976e606bc8eeeb226a4a09e541b4521d58ee74ef8d776e5d778346a2dc5b"
+ ]
+ ],
+ "content": "",
+ "pubkey": "0a519e2ac620ad2c4690237426e43e402602f6f5f6590a5257b4062068c6beb4",
+ "id": "dae5e2dbbe7f24bcc3c73fd056c1a82d8d8ddb8b5fb02b8fddb736eb3887ed3b",
+ "sig": "e1d46b0ea1201cdcc9a6807dec28490e487eb6b8f136031b84266a2369050c26deb97acf059aa839a01943537accbbe7587ac60566dc84665ae389d986508011"
+ },
+ "message": {
+ "kind": 1,
+ "created_at": 1800000000,
+ "tags": [
+ [
+ "t",
+ "ruflo-swarm"
+ ],
+ [
+ "k",
+ "Status"
+ ],
+ [
+ "rfp",
+ "1"
+ ]
+ ],
+ "content": "{\"protocol\":\"rfp\",\"version\":1,\"type\":\"Status\",\"audience\":\"urn:example:federation:lab\",\"recipient\":\"0a519e2ac620ad2c4690237426e43e402602f6f5f6590a5257b4062068c6beb4\",\"operationId\":\"1111111111111111111111111111111111111111111111111111111111111111\",\"expiresAt\":1800000300,\"payload\":{\"state\":\"ready\"}}",
+ "pubkey": "0a519e2ac620ad2c4690237426e43e402602f6f5f6590a5257b4062068c6beb4",
+ "id": "a6e818d730793ffb941c2a2c715333175f246040137d55158fc41b667fe68620",
+ "sig": "6f951f986883093b15e9fd875b9750d4e11c8f75efbd8708e31b04b30f873b75526c8652d24b4ed8f5fff2a9f441637a19d75e78f33af4f06242863607dadfa8"
+ },
+ "identity": {
+ "kind": 1,
+ "created_at": 1800000000,
+ "tags": [
+ [
+ "t",
+ "ruflo-swarm"
+ ],
+ [
+ "k",
+ "IdentityBinding"
+ ],
+ [
+ "rfp",
+ "1"
+ ]
+ ],
+ "content": "{\"protocol\":\"rfp\",\"version\":1,\"type\":\"IdentityBinding\",\"audience\":\"urn:example:federation:lab\",\"recipient\":\"0a519e2ac620ad2c4690237426e43e402602f6f5f6590a5257b4062068c6beb4\",\"operationId\":\"2222222222222222222222222222222222222222222222222222222222222222\",\"expiresAt\":1800000300,\"payload\":{\"binding\":{\"id\":\"69682a8b-76e2-45e8-9b14-fd75037f4589\",\"name\":\"worker.one\",\"subject\":\"-----BEGIN PUBLIC KEY-----\\nMCowBQYDK2VwAyEAgMJWGku5NFUn1bwCmkprBqtIjF25Jv10n/JKcKDviBw=\\n-----END PUBLIC KEY-----\\n\",\"issuer\":\"-----BEGIN PUBLIC KEY-----\\nMCowBQYDK2VwAyEAhpprXiSEabBjPEAA67fxrp6VbYbxSu48GeGfxv3mJyQ=\\n-----END PUBLIC KEY-----\\n\",\"issuedAt\":1800000000000,\"expiresAt\":1800003600000,\"signature\":\"XeK8vhW3ApLB0Cg6+JY/aRjXbudosC8Y/e2dFG2vYXwC4jwZ2eVh1bpHQXvpLNFzT3pNH9Vz8+nS57VXf+GICQ==\"},\"nostrPubkey\":\"0a519e2ac620ad2c4690237426e43e402602f6f5f6590a5257b4062068c6beb4\",\"audience\":\"urn:example:federation:lab\",\"notBefore\":1800000000,\"expiresAt\":1800000300,\"subjectProof\":\"ELI/AzTfRX9TJKiNWP/4ijkY1Xh1fXGNHQSjTdwZpMyVeFcJrSTlIcntVqSeQYmN262m6L0yoD0a9+LjzXd6AQ==\"}}",
+ "pubkey": "0a519e2ac620ad2c4690237426e43e402602f6f5f6590a5257b4062068c6beb4",
+ "id": "8672378258f1953105715414fa47fdfafee2fdba0a92733cfe9dc2f8fb1064a9",
+ "sig": "369405cdded0252794863aac958505c7bed5bb9b9afa93253173cef9efd1cabebd2645287ceba58749dd8f883802959e52a167bd5b05231808139e4f1de81d06"
+ }
+}
diff --git a/docs/protocol/verify-vectors.mjs b/docs/protocol/verify-vectors.mjs
new file mode 100644
index 0000000000..1bb9017cd5
--- /dev/null
+++ b/docs/protocol/verify-vectors.mjs
@@ -0,0 +1,27 @@
+// Cryptographic fixture checks, NOT full protocol conformance.
+// Run with Node 24. Supply the exact installed nostr-tools/pure module path.
+import {readFileSync} from 'node:fs';
+import {createPublicKey, verify, createHash} from 'node:crypto';
+import assert from 'node:assert/strict';
+import {pathToFileURL} from 'node:url';
+if (!process.env.NOSTR_PURE_MODULE) throw Error('Set NOSTR_PURE_MODULE to nostr-tools 2.7.2 lib/esm/pure.js');
+const {verifyEvent, getEventHash} = await import(pathToFileURL(process.env.NOSTR_PURE_MODULE));
+const v = JSON.parse(readFileSync(new URL('./vectors.json', import.meta.url), 'utf8'));
+let checks = 0;
+const check = (label, fn) => { fn(); checks++; console.log(`PASS ${label}`); };
+const fresh = x => JSON.parse(JSON.stringify(x)); // avoid verification cache on mutable objects
+const bytes = b => Buffer.from(JSON.stringify(['ans-v2',b.id,b.name,b.subject,b.issuer,b.issuedAt,b.expiresAt]));
+const valid = b => verify(null,bytes(b),createPublicKey(b.issuer),Buffer.from(b.signature,'base64'));
+check('ANS binding signature',()=>assert.equal(valid(v.binding),true));
+check('ANS changed name signature rejection',()=>assert.equal(valid({...v.binding,name:'attacker'}),false));
+check('ANS signed serialization digest',()=>assert.equal(createHash('sha256').update(bytes(v.binding)).digest('hex'),v.bindingDigest));
+check('Nostr HTTP signature and ID',()=>{assert.equal(verifyEvent(fresh(v.http)),true);assert.equal(getEventHash(v.http),v.http.id);});
+check('Nostr URL tamper',()=>{const e=fresh(v.http);e.tags[0][1]+='?changed=1';assert.equal(verifyEvent(e),false);});
+check('Nostr method tamper',()=>{const e=fresh(v.http);e.tags[1][1]='DELETE';assert.equal(verifyEvent(e),false);});
+check('HTTP body digest',()=>assert.equal(v.http.tags.find(t=>t[0]==='payload')[1],createHash('sha256').update(v.httpBody).digest('hex')));
+check('HTTP changed body digest differs',()=>assert.notEqual(v.http.tags.find(t=>t[0]==='payload')[1],createHash('sha256').update(v.httpBody+' ').digest('hex')));
+check('Machine message signature',()=>assert.equal(verifyEvent(fresh(v.message)),true));
+check('Machine message content tamper',()=>{const e=fresh(v.message);e.content+=' ';assert.equal(verifyEvent(e),false);});
+check('Subject dual proof',()=>{const p=JSON.parse(v.identity.content).payload;const data=Buffer.from(JSON.stringify(['ans-nostr-binding-v1',p.binding.id,p.nostrPubkey,p.audience,p.notBefore,p.expiresAt]));assert.equal(verify(null,data,createPublicKey(p.binding.subject),Buffer.from(p.subjectProof,'base64')),true);});
+check('Outer identity proof',()=>assert.equal(verifyEvent(fresh(v.identity)),true));
+console.log(JSON.stringify({checks, scope:'cryptographic fixtures only', fullConformance:false}));
diff --git a/plugins/ruflo-x-gateway/README.md b/plugins/ruflo-x-gateway/README.md
index b196983384..c480fd56a5 100644
--- a/plugins/ruflo-x-gateway/README.md
+++ b/plugins/ruflo-x-gateway/README.md
@@ -41,3 +41,10 @@ not `wss://x.ruv.io`. Otherwise you get `auth-required: verification failed`.
Signed events (secp256k1/Schnorr) → verifiable authorship. Relay membership +
NIP-42 auth gate participation. Never put secrets in payloads. Treat message
content as data, not privileged commands.
+
+## Open protocol specifications
+
+[Ruflo Federation Protocol draft](../../docs/protocol/README.md) documents ANS identity,
+the proposed strict NIP-98 profile, signed machine messages, governance and validation
+evidence. Proposed requirements are distinguished from this gateway's current behavior.
+The draft is not a claim of full implementation conformance or industry ratification.