synapse
A component of the AienOS ecosystem.
Brought by drakestapleton
synapse / AGENTS.md
| 1 | # Synapse (agent-native changeset and integration service) |
| 2 | |
| 3 | Development follows [Human-Directed Agentic Engineering (HDAE)](README.md#human-directed-agentic-engineering). |
| 4 | The README defines the human and agent responsibilities and cites Gregory M. Kurtzer's report. |
| 5 | |
| 6 | > Synapse is source control for AI agents. Agents submit signed changesets, inspect virtual trees and diffs without a working-tree checkout, attach evidence and queue integration. Accepted changesets materialize deterministically into standard Git objects, GitHub pull requests are only a human projection, and canonical promotion needs a verified Radicle delegate quorum. The repository is one Rust Cargo workspace under `crates/`. |
| 7 | |
| 8 | Shared rules: read https://www.aienos.com/agents/RULES.md first. This file adds what is specific to this repository; where the two differ, this file wins here. |
| 9 | |
| 10 | ## Scope |
| 11 | |
| 12 | - Applies to the whole repository. |
| 13 | - Code: the Cargo workspace in `Cargo.toml` with the crates `synapse-core`, `synapse-store`, `synapse-auth`, `synapse-api`, `synapse-git`, `synapse-radicle`, `synapse-bench`, `synapse-crumb`, `synapse-coord`, `synapse-evidence` and `synapse-wire`. The root `.crumb` gives each crate's role. |
| 14 | - Design: `CONTEXT.md` (glossary), `docs/adr/` (decisions 0001 to 0004), and one specification per work item in `docs/` (for example `docs/SCHEMA_AND_CONSISTENCY.md`, `docs/THREAT_MODEL.md`, `docs/G1_WIRE_FRAMES.md`). |
| 15 | - Evidence: `evidence/<item>/` holds recorded qualification runs with `SHA256SUMS`. Treat recorded evidence as immutable; a new run writes new evidence, it does not edit old files. |
| 16 | - Verification: `tests/gates/*.gate` and `tests/gates/run.sh` (the Spark gates), `.aien/` (always-run gates, paths that need only those, and the bundle verification key), `.github/workflows/aien-verification.yml`. |
| 17 | |
| 18 | ## Installation |
| 19 | |
| 20 | ```bash |
| 21 | git clone https://github.com/aien-dev/synapse.git |
| 22 | cd synapse |
| 23 | cargo build --locked --workspace |
| 24 | ``` |
| 25 | |
| 26 | You need a Rust toolchain (the gates record Rust 1.98.1), `git`, and a C compiler (`cc`) for the crumb qualification scripts. There is no `rust-toolchain.toml`; use a current stable toolchain. |
| 27 | |
| 28 | ## Configuration |
| 29 | |
| 30 | - The library crates read no configuration files. Behaviour such as the WAL `fsync` policy, quotas and capability grants is set through the crate APIs; see `docs/SCHEMA_AND_CONSISTENCY.md` and `docs/THREAT_MODEL.md`. |
| 31 | - `crumb.lock` pins the aien-architecture commit whose `crumb` tool checks `.crumb`. |
| 32 | - `scripts/ci/portable.sh` writes its logs to `$CI_EVIDENCE_DIR` (default `target/ci-evidence`). |
| 33 | - `scripts/run_gate4_qualification.sh` takes `FIXTURE_REPO`, `FIXTURE_REV`, `OUT_DIR`, `WORK_PARENT`, `REPS`, `TIERS`, `ARMS`, `SEED`, `RADICLE_REPO` and `SMOKE=1`; its header documents each one. |
| 34 | - The interop and Gate 4 scripts honour `CARGO_TARGET_DIR`. |
| 35 | |
| 36 | ## Usage |
| 37 | |
| 38 | ```bash |
| 39 | # The SYNAPSE-WORKSPACE gate: fmt check, cargo metadata --locked, clippy -D warnings, all tests |
| 40 | bash scripts/ci/portable.sh workspace |
| 41 | |
| 42 | # The same steps one at a time |
| 43 | cargo fmt --all --check |
| 44 | cargo clippy --locked --workspace --all-targets -- -D warnings |
| 45 | cargo test --locked --workspace |
| 46 | |
| 47 | # The SYNAPSE-ZERO-DISK-SECRETS gate: no plaintext .env* file in the tree |
| 48 | tests/gates/run.sh zero-disk-secrets |
| 49 | ``` |
| 50 | |
| 51 | These gates need a sibling checkout of aien-architecture at `../aien-architecture`: |
| 52 | |
| 53 | ```bash |
| 54 | # CRUMB-VERIFY: builds the crumb tool at the commit in crumb.lock, then runs `crumb verify .` |
| 55 | tests/gates/run.sh crumb-verify |
| 56 | |
| 57 | # SYNAPSE-CONFORMANCE: the combined Crumb-Synapse qualification at the pinned architecture commit |
| 58 | tests/gates/run.sh conformance |
| 59 | ``` |
| 60 | |
| 61 | `scripts/run_gate4_qualification.sh` is the Gate 4 comparative benchmark (Synapse against Git worktree and Git plumbing workflows). It needs a real fixture repository (`FIXTURE_REPO`) and writes `evidence/gate4-qualification/`; `SMOKE=1` runs a tiny end-to-end check of the harness. Published performance numbers come from runs on the DGX Spark, not from a laptop. |
| 62 | |
| 63 | ## Conventions |
| 64 | |
| 65 | - Keep the identity types distinct. `ChangesetId`, `BlobDigest`, `GitOid`, `WalSeq`, `RadicleCanonicalHead` and `GitHubPullRequestProjection` are different things; `CONTEXT.md` lists the terms to use and the ones to avoid. |
| 66 | - `WalSeq` order and GitHub pull request state never confer authority to advance a canonical branch. Only a verified Radicle delegate threshold does (ADR 0001). |
| 67 | - Git is a bridge for import, export and existing tooling, not the primary history format (ADR 0002). Materialized Git objects must stay deterministic and pass `git fsck`. |
| 68 | - Fail closed: an unknown version, a malformed input or a conflicting `IdempotencyKey` is refused with a `RefusalCode`, never accepted with a guess. |
| 69 | - Every crate passes `cargo fmt` and `cargo clippy -D warnings`. Tests live beside the code and under each crate's `tests/`. |
| 70 | - A new work item gets its specification in `docs/` and its evidence in `evidence/<item>/`, and the README or the spec links both. |
| 71 | - Keep `.crumb` exactly what the pinned compiler produces; CI runs `crumb verify .`. |
| 72 | |
| 73 | ## Safety and approvals |
| 74 | |
| 75 | - The DGX Spark is the test judge (`docs/PIPELINE.md`). GitHub checks on pull requests are advisory; nothing on GitHub builds this repository's code. |
| 76 | - A change to `.aien/`, `tests/gates/`, `.github/workflows/` or `.forgejo/` is `BLOCKED_OPERATOR`: it runs only when the operator starts it by hand. Ask before touching those paths, and never relax a gate to make a change pass. |
| 77 | - Do not run benchmark or qualification scripts on the Spark unless the operator has given you a window; the Spark hosts other work. |
| 78 | - No plaintext secrets: `.env*` files are refused by `SYNAPSE-ZERO-DISK-SECRETS` and ignored by `.gitignore`. Never commit keys, tokens or agent signing material. |
| 79 | - Do not edit recorded evidence or rewrite published history. Work on a branch and merge through a pull request; `docs/PIPELINE.md` explains the `ready-to-merge` label. |
| 80 | |
| 81 | ## Further reading |
| 82 | |
| 83 | - `README.md`: architecture overview and the crate table. |
| 84 | - `CONTEXT.md`: the domain glossary. |
| 85 | - `docs/adr/`: architecture decisions 0001 to 0004. |
| 86 | - `docs/PIPELINE.md`: how the Spark gates test and merge a pull request. |
| 87 | - `docs/GATE4_QUALIFICATION.md`: the comparative qualification report. |