blake-guard

Three packages. One control plane.

blake-guard is the open enforcement spine Blake runs — and any host can. Gate intents, witness the space, keep a compliance trail. Policy outside the model.

suite · Apache-2.0 · Node ≥ 20 · npm public

spine

Gate · witness · trail.

Three independent npm packages. Same contract on Blake or your own runner — no Blake UI required.

  • 01

    Gate blake-gate

    The model proposes intents. The gate decides allow, deny, or require_approval — outside the LLM. Spawn and replicate default to deny so uncontrolled replication stays at zero.

    GitHubnpmdocs

  • 02

    Witness blake-witness

    Who or what touched the personal space on disk — process, OS user, agent, or host — as durable JSONL beside the space.

    GitHubnpmdocs

  • 03

    Trail blake-trail

    Append-only decision → outcome log. If the gate said deny but the action still happened, the trail records a violation — prompt is not fact.

    GitHubnpmdocs

install

Add the suite.

npm install blake-gate blake-witness blake-trail

# Gate before the tool
import { compilePolicy, evaluateIntent } from "blake-gate";

# Witness FS contact
import { createFsAccessLog, recordSpaceAccess } from "blake-witness";

# Trail after the fact
import { createFsComplianceLog, recordDecision, recordOutcome } from "blake-trail";

loop

Before the tool. After the fact.

Compile owner rules → evaluate every dangerous intent → record the decision → run only on allow → record whether the side-effect happened → witness space contact.

const policy = compilePolicy({
  agentId, ownerId,
  agentSpawn: "deny",      // default
  agentReplicate: "deny",  // uncontrolled replication = 0
  connectors: [{ id: "github", tier: "write" }],
});

const decision = evaluateIntent(intent, policy, ctx);
await recordDecision(trail, { …decision fields });

if (decision.effect !== "allow") throw new Error("blocked");

// … run tool …

await recordOutcome(trail, {
  fingerprint: decision.fingerprint,
  expectedEffect: decision.effect,
  occurred: true,
});
await recordSpaceAccess(accessLog, { spaceId, op: "write", actor });

replication

Uncontrolled replication = 0.

agent.spawn and agent.replicate default to deny on the policy artifact. Set require_approval or allow only when the owner explicitly authorizes growth. Anything else is a hard stop — and a trail violation if it still occurs.

intent catalog

What the gate understands.

  • run.start
  • secret.read
  • git.push
  • git.force_push
  • git.open_pr
  • git.merge
  • mail.send
  • chat.send
  • outbound.publish
  • agent.spawn
  • agent.replicate

gate deep dive

Schematics — not a prompt.

How blake-gate compiles artifacts, fingerprints intents, and verifies allow tokens.

01 · gate loopModel proposes. Gate decides. Tool runs only on allow.
LLM / agentproposes intent
evaluateIntentblake-gate
allowrun tool
require_approvalhuman ticket
denyhard stop

Prompts are not enforcement. The decision object carries effect, rules, fingerprint, and optional signed allowToken.

02 · artifactPolicy is compiled once — versioned, hashed, not a prompt.
Owner rulesstops · connectors · env
compilePolicyPolicySource →
policy.jsonpolicyHash · version
gate.mjsworkspace / CI
  1. Host maps product fields → PolicySource.
  2. compilePolicy stamps policyHash / version.
  3. materializePolicyWorkspace writes .blake-policy/ + history jsonl.
  4. diffPolicies shows what changed for this agent.
03 · dual-envPractice never sees personal scopes — compliance suite, not UI.

personal_private

may personal secrets

not practice credentials

org_private

may org secrets

not personal secrets

hire_sandbox

may practice tools only

not personal · org

CI: npx blake-gate env-check · assertEnvIsolation()

04 · before · afterGate before the tool. Audit after the fact.
Gate beforeevaluateIntent
Tool / Cursor / CImerge · push · send
Evidencelog · PR · outbound
evaluatePostActionprior decision vs fact
okmatched allow
ViolationEventdeny / approval ignored

Competitors often stop at “before.” Drift between prompt and merge log becomes a violation event.

05 · capability ticketsSame fingerprint + policyHash → durable allow. Drift asks again.
fingerprinttype · target · repo · branch · agent · env
require_approvalfirst time
ApprovalRequestwebhook · email · Slack
grantApprovalstore ticket
same intent againno drift
allowapproval.durable
allowTokenHMAC · verify before tool

Not chat moderation — capability tickets. Without a valid allow-token, merge/send must refuse even if the model “decides.”

06 · one contractSame package on every runner.
blake-gateHOST_CONTRACT_VERSION
  • Cursor CLI
  • Claude Code
  • GitHub Actions
  • custom worker
  • Blake host

Delivery adapters stay thin. Core is runtime — approval is protocol, not a Blake-only UI.

on Blake

Already on the host.

Blake depends on the public packages — not a private fork. Runs gate run.start, materialize .blake-policy/, witness spaces under .blake-space-access/, append the compliance trail under .blake-compliance/, and owners can probe policy at /api/account/policy.