mirror of
https://github.com/qybaihe/bla.git
synced 2026-11-20 08:20:59 +08:00
test(agents): guard the AGENTS.md shield inventory against drift (#222)
AGENTS.md is the map an agent reads before touching this repo, and two bullets had drifted again after the inventory sync in #198: the formats bullet omitted dex-layout.ts and the deception bullet omitted hypothesis-revision-decoy.ts. Name both files and add a guard test that compares each bullet against its directory, so the next shield lands with its inventory entry.
This commit is contained in:
@@ -15,13 +15,13 @@ This repository contains **BLA (`bla-agents` — Blind LLM Agents)**, an open-so
|
||||
- `token-estimator.ts`: Models REA MCP tool turns and token cost across Claude Opus 4, Sonnet 4, and o3.
|
||||
- `src/shields/`:
|
||||
- `exhaustion/`: Surgical Resource-Exhaustion Engine (`rea-budget-matrix.ts`, `obligation-flooder.ts`, `callgraph-labyrinth.ts`, `bpe-token-amplifier.ts`, `wasm-interface-exhaustion.ts`, `cdp-shape-budget-breaker.ts`, `frida-capture-saturation.ts`, `regex-worker-tarpit.ts`, `asar-header-amplifier.ts`).
|
||||
- `deception/`: Surgical Model-Misjudgment Induction & Cognitive-Armor Engine (`shadow-business-logic.ts`, `evidence-contract-poison.ts`, `architecture-mirage.ts`, `semantic-honeypot.ts`, `decompiler-illusion.ts`, `prompt-completion-poison.ts`, `diff-noise-injector.ts`, `crash-trace-decoy.ts`, `canary-honeypot.ts`, `system-diagnostic-decoy.ts`, `cognitive-armor-trigger.ts`, `format-payloads.ts`).
|
||||
- `deception/`: Surgical Model-Misjudgment Induction & Cognitive-Armor Engine (`shadow-business-logic.ts`, `evidence-contract-poison.ts`, `architecture-mirage.ts`, `semantic-honeypot.ts`, `decompiler-illusion.ts`, `prompt-completion-poison.ts`, `diff-noise-injector.ts`, `crash-trace-decoy.ts`, `canary-honeypot.ts`, `system-diagnostic-decoy.ts`, `cognitive-armor-trigger.ts`, `hypothesis-revision-decoy.ts`, `format-payloads.ts`).
|
||||
- `chaff/chaff-generator.ts`: Generates benign hardware-enclave delegation manifests and decoy offset contracts.
|
||||
- `tarpit/opaque-predicates.ts` & `tarpit-generator.ts`: Number-theoretic opaque predicates ($O(1)$ runtime invariants) and REA Semantic Budget Breakers.
|
||||
- `runtime/runtime-shield.ts` & `runtime/memory-diff-shield.ts`: "Truman Show" Anti-CDP / Anti-Inspector / Anti-Frida dynamic runtime deception shield, plus Synchronized Shadow Heap Churn and Split-Share Rolling XOR memory masking against $M_0 \to M_1$ runtime memory diffing. Also `runtime/self-seal.ts` (opt-in self-integrity preamble) and `runtime/sidecar-entangle.ts` (interleaved strip⇒fail sibling binding).
|
||||
- `javascript/ast-shield.ts` & `javascript/node-runtime-carrier.ts`: Babel AST shield combining opaque ternaries, Electron IPC de-literalization, exhaustion suite, and deception suite; the runtime carrier binds the shield into the emitted entry.
|
||||
- `weave/weave-decoy.ts`: AST-level surgical weave workorder + structural weave verifier (`bla-weave-plan/v1`, `bla-weave-verify/v1`).
|
||||
- `formats/`: Format-specific shields — `sourcemap.ts`, `asar.ts`, `electron-fuses.ts`, `wasm.ts`, `python.ts`, `python-ast-weave.ts`, `python-pyc-weave.ts`, `native.ts`, `sqlite.ts`, `model.ts`, `gguf-layout.ts`, `mobile-game.ts`, `apple-plist.ts`, `dotnet-managed.ts`, `headers.ts`, `archive.ts`, `android-dex-xref.ts`, `android-manifest.ts`, `android-r8.ts`, `bun-standalone.ts`, `erlang-beam.ts`, `evm-bytecode.ts`, `firmware-uf2.ts`, `go-flutter-exhaustion.ts`, `gpu-ptx.ts`, `jvm-bytecode.ts`, and `pcap-capture.ts`.
|
||||
- `formats/`: Format-specific shields — `sourcemap.ts`, `asar.ts`, `electron-fuses.ts`, `wasm.ts`, `python.ts`, `python-ast-weave.ts`, `python-pyc-weave.ts`, `native.ts`, `sqlite.ts`, `model.ts`, `gguf-layout.ts`, `mobile-game.ts`, `apple-plist.ts`, `dotnet-managed.ts`, `headers.ts`, `archive.ts`, `android-dex-xref.ts`, `dex-layout.ts`, `android-manifest.ts`, `android-r8.ts`, `bun-standalone.ts`, `erlang-beam.ts`, `evm-bytecode.ts`, `firmware-uf2.ts`, `go-flutter-exhaustion.ts`, `gpu-ptx.ts`, `jvm-bytecode.ts`, and `pcap-capture.ts`.
|
||||
- `src/bundler/index.ts`: Vite, Rollup, Webpack, and esbuild bundler plugins (`bla-agents/bundler`).
|
||||
- `src/engine/`: `defender.ts` (One-Click 5-Stage `defendTarget`), `auditor.ts`, `protector.ts`, `verifier.ts`, and `benchmark.ts` (14-target showcase benchmark); plus `harden.ts`, `bind-scope.ts`, `encrypt-strings.ts`, `packaging-gates.ts`, `integrity-coverage.ts`, `run-evidence.ts`, `polymorph-report.ts`, `rea-observability.ts`, `defense-score-honesty.ts`, and the `*-lint.ts` packaging / red-blue gates.
|
||||
- `src/mcp/server.ts`: JSON-RPC 2.0 MCP stdio server exposing 31 tools (full catalogue in `docs/cli-and-mcp.md`), including `bla_harden`, `bla_defend`, `bla_audit`, `bla_protect`, `bla_verify`, `bla_benchmark`, `bla_lint`, `bla_weave_plan`, `bla_verify_weave`, `bla_emit_headers`, and `bla_doctor`.
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import { readFileSync, readdirSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const ROOT = process.cwd();
|
||||
const agents = readFileSync(join(ROOT, "AGENTS.md"), "utf8");
|
||||
|
||||
function bulletLine(marker: string): string {
|
||||
return agents.split(/\r?\n/).find((line) => line.includes(marker)) ?? "";
|
||||
}
|
||||
|
||||
function claimedShields(marker: string): Set<string> {
|
||||
return new Set(
|
||||
[...bulletLine(marker).matchAll(/`([a-z0-9-]+\.ts)`/g)].map((match) => match[1]!),
|
||||
);
|
||||
}
|
||||
|
||||
function shieldFiles(directory: string): Set<string> {
|
||||
return new Set(
|
||||
readdirSync(join(ROOT, directory)).filter(
|
||||
(entry) => entry.endsWith(".ts") && entry !== "index.ts",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function missingFromAgents(directory: string, marker: string): string[] {
|
||||
const claimed = claimedShields(marker);
|
||||
return [...shieldFiles(directory)].filter((file) => !claimed.has(file));
|
||||
}
|
||||
|
||||
describe("AGENTS.md module inventory", () => {
|
||||
it("lists every format shield", () => {
|
||||
expect(missingFromAgents("src/shields/formats", "`formats/`: Format-specific shields")).toEqual(
|
||||
[],
|
||||
);
|
||||
});
|
||||
|
||||
it("lists every deception module", () => {
|
||||
expect(missingFromAgents("src/shields/deception", "`deception/`:")).toEqual([]);
|
||||
});
|
||||
|
||||
it("does not name shields that no longer exist", () => {
|
||||
for (const [directory, marker] of [
|
||||
["src/shields/formats", "`formats/`: Format-specific shields"],
|
||||
["src/shields/deception", "`deception/`:"],
|
||||
] as const) {
|
||||
const actual = shieldFiles(directory);
|
||||
expect([...claimedShields(marker)].filter((file) => !actual.has(file))).toEqual([]);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user