π‘οΈ BLA (Blind LLM Agents) β Adversarial defense shield that protects binaries, Electron apps, JS bundles, Python, and WebAssembly against AI reverse-engineering agents like REA. Poison -> Exhaust -> Hallucinate.
JavaScript adversarial-aiclaude-codecursorelectron-securityllm-securitymcpmcp-serverobfuscationreverse-engineeringwebassembly
test+docs: prove discover paging covers full inventory
qybaihe52e63f2f0455
diff --git a/.agents/skills/blind-llm-agents/SKILL.md b/.agents/skills/blind-llm-agents/SKILL.mdindex db68405..fe83911 100644--- a/.agents/skills/blind-llm-agents/SKILL.md+++ b/.agents/skills/blind-llm-agents/SKILL.md@@ -97,7 +97,9 @@ Optional args (safe defaults): `intensity` (bankrupt), `emit_manifest` (false),## Write safety (principles)- Unsure what will be touched? `bla_discover` or `bla_harden` `{ "dry_run": true }` β- both write nothing. If `truncated: true`, say so and narrow the directory.+ both write nothing. If `truncated: true`, page with `offset` from `nextOffset` until+ the tail is retrieved (do not silently drop artifacts past the 64 default cap), or+ raise `max_artifacts` / narrow the directory.- Never overwrite without the user's go-ahead. On `confirmation_required`, show`wouldOverwrite`, ask, then retry with `confirm_overwrite: true` (or a new path).Same rule for `in_place: true` (overwrites the input).@@ -118,7 +120,7 @@ Optional args (safe defaults): `intensity` (bankrupt), `emit_manifest` (false),| :--- | :--- || Project / build dir | **`bla_harden`** || Named artifact | **`bla_defend`** (or granular `bla_audit` β `bla_protect` β `bla_verify`) |-| Inventory only | **`bla_discover`** |+| Inventory only (page 64+ with `offset`/`nextOffset`) | **`bla_discover`** || Structural decoys (esp. Python) | Resource `bla://directives/weave-decoy` β `bla_weave_plan` β `weave_decoys: true` || Packaging footguns before harden (entitlement tree) | **`bla_lint`** `{ "directory": "." }` (CLI: `bla lint .`) β unified R1βR7+lanes/panel || Custom license/activation gate review | **`bla_lint_lanes`** `{ "path": "<gate.js>" }` (CLI: `bla lint-lanes`) |diff --git a/docs/cli-and-mcp.md b/docs/cli-and-mcp.mdindex ba73d29..19c5d77 100644--- a/docs/cli-and-mcp.md+++ b/docs/cli-and-mcp.md@@ -22,7 +22,7 @@ For coding agents, the **[`blind-llm-agents` skill](../.agents/skills/blind-llm-## MCP Tools (`bla` Server)- `bla_harden`: Preferred one-sentence harden of a project directory (`directory`, `intensity`, `emit_manifest` default false, `llm_directives` default false, `weave_decoys` default false, `self_seal` default false, `wasm_preserve_exports`, `allow_lane_independent`, `allow_plaintext_seal`, `allow_wasm_clear_params`, `allow_stable_panel_derive`, `seed`, `dry_run` default false, `max_artifacts` default 64, `confirm_overwrite` default false, `output_directory` optional). The report carries `dryRun`, `truncated`, `maxArtifacts`, `wouldOverwrite`, and `outputDirectory`.-- `bla_discover`: Read-only inventory using the same discovery as `bla_harden` (`directory`, `max_artifacts`) β `{ directory, artifacts[{path, relativePath, format}], truncated, maxArtifacts }`. Writes nothing.+- `bla_discover`: Read-only inventory using the same discovery as `bla_harden` (`directory`, `max_artifacts`, `offset`) β `{ directory, artifacts[{path, relativePath, format}], truncated, maxArtifacts, offset, nextOffset? }`. When `truncated`, pass `nextOffset` as the next `offset` to page 64+ trees without losing the tail. Writes nothing.- `bla_defend`: Full Counter-REA pipeline on a known path (`input_path`, `output_path`, `intensity`, `emit_manifest` default false, `llm_directives` default false, `weave_decoys` default false, `self_seal` default false, `wasm_preserve_exports`, `allow_lane_independent`, `allow_plaintext_seal`, `seed`, `in_place` default false, `confirm_overwrite` default false).- `bla_audit`: Pre-flight REA exposure and token-economics audit (`path`).- `bla_protect`: Granular shield injection (`input_path`, `output_path`, `intensity`, `seed`, `llm_directives` default false, `weave_decoys` default false, `self_seal` default false, `wasm_preserve_exports`, `allow_lane_independent`, `allow_plaintext_seal`, `in_place` default false, `honey_source_maps` default true, `confirm_overwrite` default false).@@ -47,7 +47,7 @@ For coding agents, the **[`blind-llm-agents` skill](../.agents/skills/blind-llm-### Write safety (dry-run, confirmation, receipts)- `bla_harden` with `dry_run: true` (CLI `bla harden . --dry-run`) discovers targets and plans outputs with **zero bytes written** (no `.bla-hardened/`, no summary, no `.blarc` seed). Dry-run sets `overallSuccess: false` β it never claims a successful harden.-- Discovery is capped (`max_artifacts`, default 64); when more targets exist the result sets `truncated: true` instead of silently dropping them.+- Discovery is capped (`max_artifacts`, default 64); when more targets exist the result sets `truncated: true` and `nextOffset` instead of silently dropping them β page with `offset` until `truncated` is false.- `bla_harden` / `bla_defend` / `bla_protect` refuse to overwrite an existing output file unless `confirm_overwrite: true`. A refusal is `isError: true` with `{ status: "confirmation_required", wouldOverwrite: [...], wrote: [] }`; nothing is written.- Successful `bla_harden` / `bla_defend` / `bla_protect` writes add `writeReceipt: { status: "written", wrote, overwrote, confirmed }` (`bla_harden` dry-run omits it).- `in_place: true` (MCP) / `--in-place` (CLI) plans the output as the input path; because that path already exists, `confirm_overwrite: true` is required on MCP or the call is refused with `confirmation_required`.diff --git a/tests/agent-write-safety.test.ts b/tests/agent-write-safety.test.tsindex b88cab8..829056b 100644--- a/tests/agent-write-safety.test.ts+++ b/tests/agent-write-safety.test.ts@@ -68,6 +68,8 @@ async function call(name: string, args: Record<string, unknown>) {readonly [key: string]: unknown;artifacts?: ReadonlyArray<{ relativePath?: string; outputPath?: string }>;truncated?: boolean;+ offset?: number;+ nextOffset?: number;dryRun?: boolean;overallSuccess?: boolean;hardenedCount?: number;@@ -220,3 +222,74 @@ describe("overwrite confirmation boundary", () => {expect(again.structuredContent.wouldOverwrite).toEqual([expected]);});});++describe("discover offset paging (issue #75)", () => {+ it("pages through a 70-artifact tree without losing the tail", () => {+ const root = project(70);+ const pageSize = 20;+ const seen = new Set<string>();+ let offset = 0;+ let pages = 0;+ for (;;) {+ const page = discoverHardenTargets(root, { maxArtifacts: pageSize, offset });+ expect(page.offset).toBe(offset);+ expect(page.artifacts.length).toBeGreaterThan(0);+ expect(page.artifacts.length).toBeLessThanOrEqual(pageSize);+ for (const a of page.artifacts) {+ expect(seen.has(a.relativePath)).toBe(false);+ seen.add(a.relativePath);+ }+ pages += 1;+ if (!page.truncated) {+ expect(page.nextOffset).toBeUndefined();+ break;+ }+ expect(page.nextOffset).toBe(offset + page.artifacts.length);+ offset = page.nextOffset!;+ expect(pages).toBeLessThan(10);+ }+ expect(seen.size).toBe(70);+ expect(pages).toBe(4); // 20+20+20+10+ });++ it("bla_discover MCP returns nextOffset when truncated", async () => {+ const root = project(5);+ const r1 = await call("bla_discover", {+ directory: root,+ max_artifacts: 2,+ });+ expect(r1.isError).toBe(false);+ expect(r1.structuredContent.truncated).toBe(true);+ expect(r1.structuredContent.offset).toBe(0);+ expect(r1.structuredContent.nextOffset).toBe(2);+ expect((r1.structuredContent.artifacts ?? []).length).toBe(2);++ const r2 = await call("bla_discover", {+ directory: root,+ max_artifacts: 2,+ offset: r1.structuredContent.nextOffset,+ });+ expect(r2.isError).toBe(false);+ expect((r2.structuredContent.artifacts ?? []).length).toBe(2);+ expect(r2.structuredContent.offset).toBe(2);+ expect(r2.structuredContent.truncated).toBe(true);+ expect(r2.structuredContent.nextOffset).toBe(4);++ const r3 = await call("bla_discover", {+ directory: root,+ max_artifacts: 2,+ offset: r2.structuredContent.nextOffset,+ });+ expect(r3.isError).toBe(false);+ expect((r3.structuredContent.artifacts ?? []).length).toBe(1);+ expect(r3.structuredContent.truncated).toBe(false);+ expect(r3.structuredContent.nextOffset).toBeUndefined();++ const all = [+ ...(r1.structuredContent.artifacts ?? []),+ ...(r2.structuredContent.artifacts ?? []),+ ...(r3.structuredContent.artifacts ?? []),+ ].map((a) => a.relativePath);+ expect(new Set(all).size).toBe(5);+ });+});