{
  "schema": "weave.protocol-reference/1",
  "contracts": {
    "Protocols/events/weave.json": {
      "id": "weave/1",
      "name": "Weave",
      "version": "0.4.0",
      "status": "active-infrastructure-runtime",
      "purpose": "Shared event semantics, versioned wire formats and symbolic codebooks for application infrastructure.",
      "catalogSchema": "crew.event-catalog/1",
      "compatibility": "Existing format IDs and bytes retain their meanings. Weave names and packages the infrastructure; it does not silently change a deployed wire format.",
      "api": {
        "descriptor": "/v1/vmfactory/infrastructure/protocols/weave",
        "events": "/v1/vmfactory/infrastructure/protocols/weave/events",
        "localCatalog": "/events.json",
        "localPage": "/events",
        "runtime": "/v1/vmfactory/infrastructure/protocols/weave/runtime"
      },
      "applications": [
        {
          "id": "fmvision",
          "binding": "Existing authenticated central hub; infrastructure descriptor and event catalog discovery",
          "binaryMessaging": "40-byte send and 4-byte receipt remain reference codecs"
        },
        {
          "id": "stratum",
          "binding": "Existing native roster snapshot/delta and durable replica transport; source-derived kinds 0\u20134",
          "scope": "Roster state replication; not an arbitrary task-event dispatcher"
        },
        {
          "id": "capsule",
          "binding": "Shared infrastructure catalog discovery alongside the existing methods/tool library",
          "taskExecution": "No model dispatch, paid work or task completion is authorized by catalog discovery"
        }
      ],
      "ownership": {
        "coordination": "merritt",
        "wireTransport": "celyn"
      },
      "boundaries": [
        "Canonical identities, catalog allocation and permissions remain in the central authority",
        "Delivery ACK, recipient action, optional substantive reply and independent verification remain distinct",
        "Merritt task-event presentation remains tracker-inbox",
        "Kanji assignments are a draft vocabulary, not an automatic permission or guaranteed one-token encoding",
        "Generic bounded replies are integrated with the native/relay runtime; oversize optional content is rejected without truncation"
      ],
      "eventFoundation": {
        "protocol": "weave.event/1",
        "implementation": "tools/crew/event_system.py",
        "status": "deployed-native-relay-and-task-adapters"
      },
      "entryLearning": {
        "contract": "Protocols/events/weave-learning-v1.json",
        "hook": "tools/project-entry/weave_briefing.py",
        "script": "tools/crew/weave_learning.py",
        "progressAPI": "/v1/vmfactory/infrastructure/protocols/weave/runtime/learning",
        "coverage": "Existing local primary and secondary entry gateway; portable walkthrough on Backstage. Current sessions are not restarted.",
        "evidence": "Brief emission, scripted practice and live status are recorded separately."
      }
    },
    "Protocols/events/crew-event-system-v1.json": {
      "id": "crew.event-system/1",
      "status": "deployed-active",
      "title": "Crew daemon events and bounded replies",
      "authority": {
        "operator": "Jay",
        "scope": "Specify daemon event behavior and one capped substantive reply to an initiating coordinator; preserve current central coordination policy."
      },
      "lifecycle": [
        {
          "kind": "event_created",
          "owner": "source daemon",
          "meaning": "Persist a source observation with its canonical reference."
        },
        {
          "kind": "delivery_ack",
          "owner": "receiving daemon",
          "meaning": "Exact recipient context received the event. No agent action or task completion implied."
        },
        {
          "kind": "action_result",
          "owner": "recipient",
          "meaning": "Report actual handler disposition using crew.event-return/1."
        },
        {
          "kind": "reply",
          "owner": "addressed recipient",
          "meaning": "One optional substantive bounded reply to the original initiator."
        },
        {
          "kind": "completion_claim",
          "owner": "task owner",
          "meaning": "A claim with evidence, separate from verification."
        },
        {
          "kind": "independently_verified",
          "owner": "independent verifier",
          "meaning": "Acceptance criteria checked against independent evidence."
        }
      ],
      "routing": {
        "correlation": "The daemon binds the existing message receipt, initiator and recipient IDs, native sessions, accounts, servers and source reference. Do not repeat this metadata in model-authored reply content.",
        "identity": "A stable crew ID alone never substitutes for exact native session/account bindings.",
        "authorization": "Initiation follows the live central policy. A reply uses only the existing original-message reply allowance; no new initiation permission.",
        "deliveryPresentation": "A daemon inbox or explicitly selected coordinator event channel. Preserve tracker-inbox mode for Merritt. Do not inject machine protocol traffic into Jays conversation.",
        "language": "Human/model presentation may use compact Japanese; transport IDs and bit encoding are a separate layer."
      },
      "replyContract": {
        "id": "crew.bounded-reply/1",
        "optIn": "An initiating substantive message explicitly permits one reply; do not infer intent from arbitrary English text.",
        "optional": true,
        "maximumAcceptedReplies": 1,
        "maximumTextBytes": 32,
        "textEncoding": "UTF-8 until an explicitly versioned alternative codec is selected",
        "status": "Four-bit status catalog from crew.event-return/1; identifies actual disposition, not an acknowledgement.",
        "instruction": "Optional response selection from the existing four-bit/eight-bit catalog; zero omits it.",
        "message": "Optional concise substantive text, including a question or useful correction. Empty is allowed when status/instruction suffice.",
        "bodyBudget": "One/two-byte status+instruction body, plus 0\u201332 text bytes. Enclosing transport framing is separate and remains Celyns integration boundary.",
        "eligibleSender": "Only the exact addressed recipient of the delivered initiating message.",
        "eligibleRecipient": "Only that messages exact initiating coordinator; no forwarded or arbitrary reply address.",
        "validation": "Validate UTF-8 byte length, exact correlation, live authorization and unused allowance before accepting. Reject oversize content; never silently truncate.",
        "atomicity": "Consume the allowance and persist/emit the reply event in one transaction. Duplicate event submissions return the existing receipt without consuming again or emitting again.",
        "noReplyChain": "A reply event grants zero further replies. Transport ACKs never grant a reply or trigger a model acknowledgement.",
        "silence": "Choosing not to reply is valid for optional substantive correspondence; do not manufacture a response. Required task-handler status is a separate contract.",
        "scope": "A reply may explain a result, ask one concise question, or correct/help the initiating coordinator. It does not itself launch commands, change task ownership or certify task completion."
      },
      "example": {
        "description": "Cairn sends help to Meridian. Meridian can return one substantive reply event bound to that help receipt.",
        "original": {
          "kind": "help",
          "initiator": "maestro",
          "recipient": "meridian",
          "replyContract": "crew.bounded-reply/1"
        },
        "reply": {
          "kind": "reply",
          "status": 2,
          "instruction": 0,
          "message": "Applied; next bottleneck is IO."
        },
        "daemonOwned": "The existing help receipt supplies reply-to, authenticated identities and return route. No model-authored routing fields.",
        "humanPresentation": "Meridian \u2192 Cairn: Applied; next bottleneck is IO."
      },
      "implementation": {
        "existing": "Live daemon inbox/outbox and exact-session native adapter, owner relay event/results API, canonical task-inbox adapter and filesystem-driven SSE subscriptions.",
        "specifiedHere": "Durable lifecycle and bounded replies implemented and connected to live native and relay transports.",
        "integrationPending": [],
        "ownershipBoundary": "Celyn owns JSON-to-bitpacked transport work; this specification adds semantics without changing her codec or existing transports.",
        "foundation": {
          "module": "tools/crew/event_system.py",
          "protocol": "weave.event/1",
          "tests": "tools/crew/test_event_system.py",
          "demo": "python3 tools/crew/event_system_demo.py",
          "state": "deployed; production native, relay and quiet task-inbox adapters qualified",
          "implemented": [
            "Transactional SQLite inbox and outbox",
            "Immutable content identity and duplicate suppression",
            "Exact crew/session/account/server endpoint binding",
            "Mandatory adapter-supplied live authorization at emit, accept and dispatch",
            "Atomic inbox insertion and one daemon ACK; control events never produce ACK chains",
            "One action disposition and one opt-in 32-byte UTF-8 substantive reply",
            "Separate independent-verification event with evidence and distinct claimant/verifier identity",
            "Crash recovery and explicit evidence-gated uncertain-send reconciliation",
            "Durable local inbox for an authorized consumer; no automatic model turns"
          ]
        },
        "operatingContract": {
          "database": "Dedicated daemon SQLite state; no new central task or crew authority",
          "onStartup": "One owner process invokes recover before dispatch. Never recover while another owner is actively sending.",
          "authorization": "Required injected callback; production adapter must authenticate sender and consult live central grants. Test route callbacks are not production policy.",
          "dispatchReceipt": "delivered requires a durable receiver receipt; successful socket write alone is unknown.",
          "responseInstructions": "Response codes are data; execution belongs to the explicitly authorized consumer.",
          "actionResults": "One bounded disposition per source event; later progress is a separately identified observation, not an overwrite.",
          "timeouts": "Transport deadlines remain in the existing communication daemon. A timeout produces uncertainty, never completion or automatic replay.",
          "verification": "Evidence is recorded and identity separation enforced; the core does not independently execute acceptance checks or certify their truth."
        },
        "productionAdapters": {
          "runtime": "tools/crew/weave_runtime.py",
          "relay": "tools/crew/weave_routes.py",
          "daemon": "tools/crew/communication_daemon.py",
          "routes": "Protocols/events/weave-runtime-v1.json",
          "qualification": "artifacts/coordination/weave-live-qualification.json",
          "nativeStatusBody": "Compact 1/2-byte codec; native bridge selects an explicit Kanji status.",
          "wireBoundary": "Enclosing relay frames remain the existing authenticated transport. Celyns fixed member mapping is cataloged separately; arbitrary event envelopes are not silently encoded as member records."
        }
      },
      "implementationSources": [
        "tools/crew/event_system.py",
        "tools/crew/event_system_demo.py",
        "tools/crew/weave_runtime.py",
        "tools/crew/weave_routes.py"
      ]
    },
    "Protocols/events/weave-runtime-v1.json": {
      "id": "weave.runtime/1",
      "family": "task-supervision",
      "status": "deployed-active",
      "title": "Live Weave runtime adapters",
      "events": [
        {
          "kind": "task.native_stop",
          "meaning": "Canonical task-supervision native_stop observation; source evidence retained, no task result inferred."
        },
        {
          "kind": "task.completion_claim",
          "meaning": "Canonical task-supervision completion_claim observation; source evidence retained, no task result inferred."
        },
        {
          "kind": "task.independently_verified",
          "meaning": "Canonical task-supervision independently_verified observation; source evidence retained, no task result inferred."
        },
        {
          "kind": "task.qualification",
          "meaning": "Canonical task-supervision qualification observation; source evidence retained, no task result inferred."
        }
      ],
      "implementationSources": [
        "tools/crew/weave_runtime.py",
        "tools/crew/weave_routes.py",
        "tools/crew/weave_learning.py",
        "tools/project-entry/project_entry.py",
        "tools/project-entry/weave_briefing.py"
      ],
      "api": {
        "base": "/v1/vmfactory/infrastructure/protocols/weave/runtime",
        "submit": "POST /events",
        "receipt": "GET /events/{id}",
        "inbox": "GET /inbox?crew={id}&session={nativeSessionId}&after={sequence}",
        "return": "POST /events/{id}/result",
        "subscribe": "GET /stream?crew={id}&session={nativeSessionId}; SSE Last-Event-ID reconnect cursor",
        "learning": "GET/POST /learning; owner-authenticated practice receipts and actual adoption summary"
      },
      "authorization": "Owner-authenticated relay plus exact central live session/account/server bindings and Crew CLI initiation grant; returns use original event binding. Task observations use only the canonical task-event grant.",
      "nativePresentation": {
        "instructionTextMaxBytes": 32,
        "resultStatusGlyphs": {
          "\u6e08": "handled",
          "\u969c": "blocked",
          "\u4e2d": "running",
          "\u5f85": "deferred",
          "\u5426": "failed",
          "\u7591": "operator_decision"
        },
        "optionalSecondLineMaxBytes": 32,
        "invalidOutput": "Invalid status produces no inferred result. An explicit valid status is accepted independently; an oversized optional note is rejected without truncation or consuming the reply allowance, and full native evidence is retained.",
        "separator": "One newline or an explicit literal newline escape between status and optional text."
      },
      "notification": "Existing daemon filesystem/native publisher wakes; relay SSE uses filesystem notifications with authorization-only keepalives. No worker polling.",
      "wire": "Existing authenticated relay framing; reference event JSON envelope with compact result codec. Celyns existing binary mappings retain their meanings. No universal binary wire conversion or global type-ID allocation.",
      "preservation": "No historical alert dump, no replay of uncertain sends, no automatic ACK chains. Source task inbox remains quiet."
    },
    "tools/coordination/weave/edrin/design.json": {
      "schema": "weave.architecture-decision/1",
      "task": "FMV-907",
      "owner": "Edrin",
      "status": "implemented-and-locally-qualified; not production activated",
      "intent": "Events are the common medium for information transformation: requests, assignments, delivery receipts, progress, terminal outcomes, completion claims and independent verification remain distinct typed occurrences. Daemons execute registered mechanics; human and artist judgment retains its own authority.",
      "layers": {
        "contract": "Versioned bounded DAG describes possible successors and terminal predicates. Canonical SHA256 pins exact semantics.",
        "occurrence": "A root identifies one execution. Each successor UUID binds root, contract hash and node. Parent identifies the root; causes reference actual predecessor completion events, including joins.",
        "journal": "Existing EventSystem persists incoming events, outbox successors and consumption in one SQLite transaction. Existing WeaveRuntime projects those same IDs centrally.",
        "wire": "Existing event_protocol and catalog remain authoritative. No numeric allocation, alternate codec or assumed compression savings."
      },
      "runtime": {
        "entry": "Existing event-woken WeaveRuntime.sync; inbox root body exactly {continuation: sha256}.",
        "registration": "Existing central records key weave_continuation:<sha256>; value {contract, scheduler}. Scheduler must exactly match recipient endpoint and current roster. No registration or grants created by this module.",
        "dispatch": "Existing transport with live authorization. Repeated wake reconciles persisted outbox and central projection by stable event ID.",
        "errors": "Rejected route is retained in weave_runtime_errors and exposed as recordedIssue in existing event status. It is historical evidence, not an inferred current job outcome.",
        "terminal": "action_result is immutable. A worker reporting RUNNING first must use a distinct registered application completion kind for its terminal result and output reference.",
        "verification": "Flow settled means all nodes terminal or conditionally skipped. jobVerified remains false. Owner claim and independent verification are separate events and cannot be inferred from ACK, successful dispatch or settled graph."
      },
      "guarantees": [
        "Atomic local fanout and input consumption",
        "Duplicate advancement produces the same events",
        "Cross-store crash recovers projection without a second successor",
        "Endpoint or authority changes reject further actions",
        "Uncertain external delivery is held until explicit receipt reconciliation; no automatic replay"
      ],
      "limits": [
        "Schema 1 supports finite DAGs of at most 64 nodes and 32 KiB contracts. Cycles rejected.",
        "Cancellation, timeout and migration require explicit new event/contract semantics; no implicit retry or reinterpretation of old events.",
        "Conditionally skipped nodes are derived graph state, not evidence that an action ran.",
        "External effects require consumer-specific receipts. The crash fixture demonstrates uncertainty handling, not universal exactly-once execution.",
        "Native instruction delivery needs its own qualified adapter; this integration accepts inbox delivery only.",
        "No live crew recipe, daemon deployment or real consumer execution has been performed."
      ],
      "ownership": "App and artist owners keep their consumers and authored worlds. This change adds no roster, approval layer, peer-chat loop, task database or model invocation. Existing core and wire ownership retained.",
      "evolution": "Publish a new immutable contract and hash for changed behavior. Existing roots retain their pins and exact endpoint bindings. Stop admitting new roots for rollback; retain all prior journals and reconcile in-flight external effects. Do not retarget old roots or delete uncertain evidence.",
      "activation_requirements": [
        "Publish an actual owner-defined contract and exact scheduler binding through existing central record authority.",
        "Use registered application types and consumers with explicit terminal/output and external-effect receipt semantics.",
        "Package weave_continuation.py alongside the existing weave_runtime.py in the owning daemon deployment.",
        "Qualify one production consumer under its existing authority with independent evidence before expanding adoption."
      ],
      "evidence": {
        "suite": "tests-available.json: 59 passing tests; HTTP regression import blocked by unavailable aiohttp, retained in tests.json.",
        "durability": "qualification/receipt.json: six reopenings, fanout and join, distinct progress/terminal and claim/verification events.",
        "effect": "effect-qualification/receipt.json: child process exit 73 after fsynced synthetic write; sending -> uncertain -> receipt reconciled delivered, one effect, no replay.",
        "measurement": "9458 canonical envelope bytes across 18 events; 887-byte contract; four bytes of compact result bodies. Fixture costs only, not deployed traffic or codec savings."
      }
    },
    "tools/coordination/weave/edrin/tool-guide.json": {
      "schema": "weave.local-tool-guide/1",
      "task": "FMV-907",
      "version": 1,
      "entry": "python3 -B tools/crew/weave_tool.py",
      "purpose": "Minimal complete local event-driven file integrity verification. Five executable commands; one registered consumer. No resident process, model invocation, shell execution, network or crew session changes.",
      "commands": {
        "catalog": "List implemented commands, consumer limits and pinned contract.",
        "submit FILE --sha256 EXPECTED": "Persist a new UUID job and root request; return queued job ID. Expected digest must come from the caller.",
        "run ID": "Recover local delivery from exact inbox evidence, drain the finite event queue, inspect the file, claim the measured result and check it with a second read against the expected digest.",
        "status ID": "Read durable received outcome and evidence without running the job.",
        "events ID": "Read immutable event envelopes, including causal IDs, without running the job."
      },
      "example": [
        "python3 -B tools/crew/weave_tool.py catalog",
        "python3 -B tools/crew/weave_tool.py submit /absolute/path/to/file --sha256 <expected-64-hex-digest>",
        "python3 -B tools/crew/weave_tool.py run <returned-job-id>",
        "python3 -B tools/crew/weave_tool.py status <returned-job-id>",
        "python3 -B tools/crew/weave_tool.py events <returned-job-id>"
      ],
      "state": "Defaults to ~/.local/share/weave-local; override with --state PATH before the command. Job manifests and per-service EventSystem journals are execution evidence, not a second project tracker.",
      "exitCodes": {
        "0": "Command succeeded; inspect state for queued/pending/verified.",
        "1": "Job has a recorded failed outcome.",
        "2": "Invalid request, missing job, conflicting inputs or execution/storage error; original records retained."
      },
      "bounds": [
        "Regular files up to 16 MiB; bounded streaming read, reject special files and detected in-read changes.",
        "Expected SHA-256 and absolute input path pinned in the submitted event; changed manifests rejected.",
        "Retrying run is idempotent. A failed job remains failed; submit a new job for changed inputs.",
        "Unknown local delivery is reconciled only while exclusively owning all local journals; this proof does not apply to remote or external side effects.",
        "Verified means bytes matched the supplied digest at the recorded reads. It does not guarantee later file contents, authorship, safety, or independent human review.",
        "Local service endpoints are fixed; no crew permissions, roster identities or production grants are created."
      ],
      "evidence": {
        "cli": "tool-qualification/receipt.json",
        "regressions": "tool-tests.json",
        "successJob": "455ed793-743a-4cab-8e99-37ae04f02295",
        "failedJob": "87202746-9621-4c0f-8b4c-bb78155144eb"
      },
      "future": "Extend only with an explicitly registered consumer, bounded input, durable terminal result, recovery contract and acceptance check. Production crew transport remains separate unfinished scope."
    },
    "tools/coordination/weave/edrin/tool-tests.json": {
      "modules": [
        "test_weave_tool",
        "test_weave_continuation",
        "test_event_system",
        "test_event_protocol",
        "test_weave_runtime"
      ],
      "testsRun": 70,
      "passed": true,
      "failures": 0,
      "errors": 0,
      "scope": "Local consumer plus existing continuation, protocol, event core and runtime. HTTP routes not exercised; aiohttp unavailable in this environment."
    }
  },
  "resultCodec": {
    "id": "crew.event-return/1",
    "ack": {
      "bodyHex": "01",
      "meaning": "Exact receiving-context delivery only; no action or completion implied"
    },
    "result": {
      "compactBits": [
        4,
        4
      ],
      "fullBits": [
        4,
        4,
        8
      ],
      "reservedFullBits": 0,
      "noOptionalResponse": 0,
      "statusCodes": {
        "0": "pending",
        "1": "running",
        "2": "handled",
        "3": "already_resumed",
        "4": "completion_verified",
        "5": "blocked",
        "6": "operator_decision",
        "7": "stale",
        "8": "duplicate",
        "9": "no_action",
        "10": "failed",
        "11": "partial",
        "12": "unsupported",
        "13": "invalid_input",
        "14": "cancelled",
        "15": "deferred"
      },
      "responseCodes": {
        "0": null,
        "1": "continue",
        "2": "complete",
        "3": "report",
        "4": "verify",
        "5": "inspect",
        "6": "reconcile-without-replay",
        "7": "hold",
        "8": "escalate",
        "9": "checkpoint",
        "10": "resume-within-authorization",
        "11": "stop",
        "12": "provide-source",
        "13": "review-assignment",
        "14": "independent-review",
        "15": "inspect-full-record"
      },
      "extendedResponseSlots": "16\u2013255 require explicit handler registration; codec supports all slots"
    },
    "nativeTextBridge": "Exactly 2 or 4 hexadecimal characters, decoded by software; these characters are not binary wire bytes",
    "correlation": "Existing authenticated exchange context; no new result-body IDs",
    "automaticActions": false,
    "transportKinds": [
      "delivery_ack",
      "action_result"
    ],
    "framing": "The authenticated transport distinguishes ACK from result and bounds the body to one/two bytes; never infer kind from the body",
    "stateMachine": {
      "registered": [
        "context_delivered"
      ],
      "context_delivered": [
        "action_result"
      ],
      "action_result": [
        "progress",
        "handling_terminal"
      ]
    },
    "completion": "Handling terminal does not complete or verify the underlying task"
  },
  "localConsumer": {
    "schema": "weave.continuation/1",
    "id": "local-file-verification",
    "version": 1,
    "nodes": {
      "inspect": {
        "kind": "file.inspect",
        "completion": "file.finished",
        "recipient": {
          "crew": "weave-local-worker",
          "session": "local-v1",
          "account": "local-tool",
          "server": "localhost"
        },
        "after": {},
        "input": "job:input-file"
      }
    }
  },
  "sourceHashes": {
    "Protocols/events/weave.json": "7debd8f35d30a7fabcb3da9b4be296cce5f80787bdc818ccc3a96a9907e7b92e",
    "Protocols/events/crew-event-system-v1.json": "30b31d7d6e3e5747c91a5b16f6bdd542e29eb7d445dc3b7d3b82dfd2bf32d077",
    "Protocols/events/weave-runtime-v1.json": "703ee1b4482a25c5f0dbb58e19de0d601c155d77f60e7f99ac0b670f2c585049",
    "tools/coordination/weave/edrin/design.json": "20623223866e57d78843616eb469e1dfc81955b8605be7a041241b01c344ac87",
    "tools/coordination/weave/edrin/tool-guide.json": "51c6e7543795ef1cc686e0f101da78f9c0c5cc29d712b6a82ce2eddcb5e1b78f",
    "tools/coordination/weave/edrin/tool-tests.json": "9a94fd0b9e8b0d9a24b865b25e91ed1f4de6c85448ae22947324d80e2292a327",
    "tools/crew/event_protocol.py": "216a95a10dc4aae229644bf409d8b33d16062d49d38564a043e6814ecc6c3901",
    "tools/crew/weave_tool.py": "42050963cccdbecf244f00b0c653338a394f2399e290148a039ea1ae4d3f2f98",
    "tools/crew/weave_continuation.py": "758526199db4f9f26d707e3dfb32aba019bfa6d421c1beb6da8315c43a155cce"
  }
}
