sam
AGENTS.md952 starsChanged 2 months agoApache-2.0View on GitHub
You are an expert software engineering assistant helping to develop, maintain, and test the SAM repository.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,736 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- sam-meshSkill
The file
We split this AGENTS.md into the rules it gives an agent
10 rules. About 0 are common, 4 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 7
API Communication: All data communication between sam-control-plane, sam-router and sam-node must happen exclusively via the common API …
- Distinctive: line 21
If a task can be solved using the existing dependencies or the Go standard library, you must choose that path even if it requires more …
- Distinctive: line 27
Push Coverage Down: If test coverage for a specific edge case or feature can be added at a lower level (Unit or Integration), it is …
- Distinctive: line 28
No Redundancy: Do not replicate a test in the slower E2E path if it is already sufficiently covered in the Integration path.
- Very specific: line 31
Integration Tests (
tests/integration/): Verify module interactions and API compliance in Go and those are time bounded, no more than 10 … - Distinctive: line 35
Ensure all new code is highly modular, prioritizing small, single-responsibility functions that are easy to unit test.
- Very specific: line 40
Ensure binaries build using make
- Very specific: line 41
Ensure linter passes make lint
- Very specific: line 42
Ensure test passes make test
- Very specific: line 43
Ensure e2e test passes make e2e-test
≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SAM Repository AI Agent Guidelines
You are an expert software engineering assistant helping to develop, maintain, and test the SAM repository.
1. Architecture & Component Independence
- Decoupled Architecture: The
sam-control-plane,sam-routerandsam-nodecomponents are strictly independent. They must not share internal state or tightly couple their logic. - API Communication: All data communication between
sam-control-plane,sam-routerandsam-nodemust happen exclusively via the common API defined inapi/sam.proto. - One schema, two encodings: every request and response on any SAM surface is a message in
api/sam.proto. The mesh protocol — anything a mesh component speaks (node, router,sam-box, the agent connector, the SDKs undersdk/): enrollment, refresh, keys, leases, auth streams, policy sync — is binary protobuf (application/x-protobuf). The operator plane — what humans, the web console and admin CLIs call (/admin/*,/users/*,POST /policies) — is protojson of the same messages, withUseProtoNamesand unknown fields rejected. Never define a wire shape as a Go struct withjsontags, an anonymous struct ormap[string]any, and never serialize aninternal/storage(or any other internal) type onto either surface. Clients incmd/,internal/consoleandsdk/importapi/or its generated bindings only. - Instants are
google.protobuf.Timestamp, named*_time(expire_time,sign_time,event_time), neverint64seconds or milliseconds.Timestamphas fixed units, an explicit unset, renders as RFC 3339 in protojson (anint64renders as a quoted decimal string), and has a first-class conversion in Go, JavaScript, Python and Dart. A receiver treats an unset instant as invalid, never as the epoch. The one exception is a proof-of-possession value: it is the number that appears in the signed text (sam:<endpoint>:<peer_id>:<n>), so it stays anint64namedchallenge_unix_ms, the unit in the name. What a member persists between runs is also a message here (MemberCredential), so a state directory written by one implementation loads in another. - Datalog text is the policy contract: the control plane renders the mesh policy as Datalog rules (
PolicyConfigGetResponse.datalog_rules); every member, in any language, adds that text to its authorizer and none derives rules from roles and bindings itself. Datalog must stay in the form every Biscuit implementation parses: a predicate carries at least one term (presence-only facts arename(true), seeapi.MarkerFact). - Secrets never travel as flag values: binaries read credentials from a file (
--*-path) or the environment, never from a command-line argument that would sit inpsoutput and shell history. Banners and logs name the source of an operator-supplied secret instead of echoing it. - Sandbox Dataplane:
sam-box(one per sandbox) is the single egress policy enforcement point. It holds no libp2p host, no enrollment and no mesh identity, and reaches the mesh exclusively as a client of the localsam-nodesidecar socket.nano-init(PID 1 inside the guest, its own Go module) owns the guest side; its datapath is thetun2connectlibrary. The sandbox boundary is a Unix socket speaking named HTTP tunnels: CONNECT (TCP) and connect-udp (UDP) out,CONNECT <port>back in. The authoritative design issite/content/docs/preview/agent-architecture.md; do not contradict it. - Enforcement over Convention: never gate sandbox traffic on the agent's cooperation — no proxy environment variables, no
LD_PRELOADshims, no DNS spoofing. The agent harness stays unmodified and mesh-unaware; confinement is a route and a socket, built by the userspace launcher (nano-init) and judged insam-box. An agent that must cooperate with its own confinement is not confined. - Policy on Names: egress policy, secret injection and routing decisions are made on the destination name, never on an IP. Deny by default.
- Agent Identity: the agent is the principal; the node is only the channel. Agent identity comes from the platform's workload credential, verified at admission — never asserted in-band from inside the sandbox. Platforms integrate solely through the connector interface (
Attach/Detach/Refresh/Statusand the agent bundle), not by reaching into SAM internals. - Zero Trust: Enforce a Zero Trust architecture. Assume no implicit trust between nodes, control planes, routers, or external actors. All data passing through the API must be authenticated, authorized, and validated.
- Simple UX: Maintain a very simple User Experience. Configuration, CLI usage, and error messages must be intuitive, minimal, and explicitly clear.
2. Dependency Management (Strict Constraint)
- You are forbidden from suggesting any code that requires a new entry in
go.modunless you explicitly ask for my permission first. - If a task can be solved using the existing dependencies or the Go standard library, you must choose that path even if it requires more lines of code.
- Guest-only dependencies (e.g. the userspace TCP stack in
cmd/nano-init) live in that command's own Go module so the rootgo.modnever carries them. Follow that pattern for anything that only runs inside a sandbox image.
3. Testing Best Practices
Enforce strict modularity in testing. The repository uses a defined testing pyramid (Unit, Integration, and E2E via Bats). You must adhere to the following testing philosophy:
- Optimize for Test Speed: E2E tests are slow and strictly based on existing Critical User Journeys (CUJs).
- Push Coverage Down: If test coverage for a specific edge case or feature can be added at a lower level (Unit or Integration), it is strictly preferred over E2E for speed.
- No Redundancy: Do not replicate a test in the slower E2E path if it is already sufficiently covered in the Integration path.
- Test Domains:
- Unit Tests: Focus on isolated, internal functions.
- Integration Tests (
tests/integration/): Verify module interactions and API compliance in Go and those are time bounded, no more than 10 seconds per execution. - E2E Tests (
tests/e2e/*.bats): Use Bats (Bash Automated Testing System) exclusively for high-level, black-box testing of core CUJs.
4. Code Quality & Modularity
- Ensure all new code is highly modular, prioritizing small, single-responsibility functions that are easy to unit test.
- Respect the existing repository structure (
cmd/,api/,internal/,tests/).
5. Validation
- Ensure binaries build using
make - Ensure linter passes
make lint - Ensure test passes
make test - Ensure e2e test passes
make e2e-test
6. Environments
- There are two public testnets available
hub.sam-mesh.devthat is deployed from the latest released tag andbananas.sam-mesh.devthat is deployed from themainbranch. - Their configurations can be found under
.github/k8s. - Their deployments are managed under
.github/workflows/deploy.yaml.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

