Agent Skillsmonotykamary/pi-fabric › fabric-schema

fabric-schema

GitHub

提供 Fabric Schema 的受控变更流程,通过假设、验证和提交确保文件修改的安全性与正确性,适用于需要严格状态纪律和后置条件检查的开发场景。

skills/fabric-schema/SKILL.md monotykamary/pi-fabric

Trigger Scenarios

需要进行安全且经过验证的文件编辑 要求执行带后置条件的突变操作

Install

npx skills add monotykamary/pi-fabric --skill fabric-schema -g -y
More Options

Use without installing

npx skills use monotykamary/pi-fabric@fabric-schema

指定 Agent (Claude Code)

npx skills add monotykamary/pi-fabric --skill fabric-schema -a claude-code -g -y

安装 repo 全部 skill

npx skills add monotykamary/pi-fabric --all -g -y

预览 repo 内 skill

npx skills add monotykamary/pi-fabric --list

SKILL.md

Frontmatter
{
    "name": "fabric-schema",
    "description": "Uses Fabric's typed Schema evidence loop and, when enabled, its bounded local-file transaction channel. Use when surprise must void a plan and mutation claims need explicit postconditions.",
    "disable-model-invocation": true
}

Fabric Schema

Start with const status = await schema.status();.

  • off: compatibility mode; state discipline is optional and does not gate direct pi.edit, pi.write, or pi.bash.
  • audit: reports actions enforce mode would block without changing behavior.
  • enforce: host authorization for protected-workspace file changes. Reads remain available; mutations require one same-fabric_exec schema.hypothesize → schema.verify → schema.commit sequence. Direct mutations, agents, state/mesh writes, compaction, MCP, extensions, and external providers are blocked.

Evidence is not proof. Verification confirms falsifiable observations at one fingerprinted workspace state; postconditions confirm scoped observations after declared operations. Either can pass without establishing general semantic correctness.

Enforce loop

Observe, hypothesize with literal/SHA evidence or a host-configured trusted command, verify, then commit only with the returned short-lived certificate and observed SHA:

await pi.read({ path: "src/parser.ts" });
const hypothesis = await schema.hypothesize({
  label: "parser-local-form",
  summary: "The declared parser edit accepts the local form while focused checks remain green",
  evidence: [
    { kind: "file_contains", path: "src/parser.ts", literal: "old literal" },
    { kind: "trusted_command", name: "parser-focused-tests" },
  ],
});
const verification = await schema.verify({ hypothesisId: hypothesis.hypothesisId });
const { certificate: _certificate, ...safeVerification } = verification;
if (!verification.verified || !verification.certificate) {
  if (verification.certificate) {
    await schema.abort({
      hypothesisId: hypothesis.hypothesisId,
      certificate: verification.certificate,
    });
  }
  return { status: "failed", verification: safeVerification };
}

const observed = verification.results.find(
  (result) => result.evidence.path === "src/parser.ts",
)?.observedSha256;
if (!observed) {
  await schema.abort({
    hypothesisId: hypothesis.hypothesisId,
    certificate: verification.certificate,
  });
  return {
    status: "failed",
    reason: "missing observed SHA-256",
    verification: safeVerification,
  };
}

const commit = await schema.commit({
  hypothesisId: hypothesis.hypothesisId,
  certificate: verification.certificate,
  operations: [{
    kind: "edit",
    path: "src/parser.ts",
    oldText: "old literal",
    newText: "new literal",
    expectedSha256: observed,
  }],
  postconditions: [
    { kind: "file_contains", path: "src/parser.ts", literal: "new literal" },
    { kind: "trusted_command", name: "parser-focused-tests" },
  ],
});
return { status: commit.outcome === "committed" ? "success" : "failed", commit };

Any missing, stale, failed, timed-out, cancelled, or workspace-changing evidence voids the plan. Never invent trusted-command shell text or arguments: names resolve to static host configuration.

The certificate is random, single-use, invocation-bound, and tied to the hypothesis, state head/version, workspace fingerprint, and generation. Do not return it for later use. If stopping after verification, call this with the values from that verification:

await schema.abort({
  hypothesisId: hypothesis.hypothesisId,
  certificate: verification.certificate,
});

Operations are project-relative regular files:

  • edit: oldText, newText, expectedSha256
  • write: expected: { absent: true } for creation or { sha256 } for replacement
  • delete: expectedSha256

Path/symlink escape is rejected. Keep operations declared, local, and small. Treat only committed as success; rolled_back restored declared paths after failure, while quarantined means rollback needs operator inspection.

Evidence/postcondition forms are file_exists, file_absent, file_contains (literal, not regex), file_sha256, and trusted_command (static host executable/argv). Trusted commands should be deterministic, local, and read-only. Remote/network/database effects are not transactional and remain blocked in enforce mode.

For a complexity-reduction claim, set complexityReduction: true and include behavior-preservation postconditions. Certification means those scoped checks passed, not that complexity was objectively measured.

Off-mode state discipline

When mode is off, the independent labeled state layer can still record and verify a falsifiable claim:

const transition = await state.transition({
  label: "claim",
  to: "claim-stated",
  summary: "A falsifiable delta",
  evidence: ["pnpm exec vitest run tests/focused.test.ts"],
});
const verification = await state.verify();
if (!verification.certified) {
  return { status: "failed", transition, verification };
}
return { status: "success", transition, verification };

This is workflow discipline, not enforcement. The linked guarantee and recovery model in <skill-dir>/../../docs/schema-enforcement.md and labeled timeline in <skill-dir>/../../docs/state-layer.md are soft pointers for deeper explanation.

Completion criterion

In enforce mode, only status: "success" with a committed outcome establishes the declared postconditions; preserve rollback/quarantine details under commit. Audit mode changes no behavior and grants no authorization—summarize would_block events only when the audit trace was actually inspected. In off mode, return the explicit certification status.

Version History

  • 843dadb Current 2026-08-16 15:40

Same Skill Collection

skills/fabric-advisor/SKILL.md
skills/fabric-ambient/SKILL.md
skills/fabric-council/SKILL.md
skills/fabric-exec/SKILL.md
skills/fabric-fusion/SKILL.md
skills/fabric-guide/SKILL.md
skills/fabric-rlm/SKILL.md
skills/fabric-spec/SKILL.md
skills/fabric-supervisor/SKILL.md
skills/fabric-swarm/SKILL.md
skills/fabric-workflow/SKILL.md

Metadata

Files
0
Version
843dadb
Hash
819118cb
Indexed
2026-08-16 15:40

Home - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-16 20:45
浙ICP备14020137号-1 $Map of visitor$