Skip to main content
Glama
README.md
# LLA (Look LLM Agents)

[![ci](https://github.com/Shataraimut/lla/actions/workflows/ci.yml/badge.svg)](https://github.com/Shataraimut/lla/actions/workflows/ci.yml)
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![node](https://img.shields.io/badge/node-%E2%89%A524-brightgreen.svg)](package.json)

Local-first, read-only analysis companion for owner-authorized software protected by
LLM-agent hardening pipelines ("Blind LLM Agents"). It inventories artifacts, classifies
structural protection indicators, plans bounded next steps, statically unseals sealed
containers back to JavaScript source, runs registered behavioral tests inside a Node
permission-model sandbox, counterfactually recovers behavior-verified code slices from
woven artifacts, validates claims against evidence, and emits bounded evidence-backed
reports.

Out of scope for third-party software: license bypass, secret extraction, arbitrary
execution, general-purpose protection stripping. The recovery path operates only on
owner-authorized artifacts registered in the fixture manifest.

## Requirements
- Node 24 (uses `node:sqlite`, the permission model, and modern ESM)
- npm with `package-lock.json` (exact pins)

## Build and gates
```sh
npm ci
npm run build            # tsc -> dist/
npm run typecheck        # src + tests
npm run lint
npm test                 # unit + adversarial (vitest)
npm run test:integration # CLI/MCP/sandbox/adapters/benchmark
npm run fixtures:generate
npm run benchmark:quick
npm run build:skill      # repackage skills/lla + hash manifest
```

## CLI
```sh
node dist/cli/main.js doctor
node dist/cli/main.js detect    synthetic-lab fixtures/generated/development/dev-arith-protected.js
node dist/cli/main.js inspect   synthetic-lab fixtures/generated/development/dev-arith-protected.js
node dist/cli/main.js test      synthetic-lab fixtures/generated/development/dev-arith-protected.js arith-plan
node dist/cli/main.js unseal    synthetic-lab fixtures/generated/development/dev-arith-sealed.bin arith-plan
node dist/cli/main.js recover   synthetic-lab fixtures/upstream/bla-3.7.0/seed-1/arith-balanced.js arith-plan
node dist/cli/main.js report    synthetic-lab fixtures/generated/development/dev-arith-protected.js
node dist/cli/main.js benchmark --manifest fixtures/manifests/lab.json --jsonl run.jsonl
node dist/cli/main.js mcp       # stdio MCP server
```
Every command prints one JSON envelope: `{schemaVersion, status, data, warnings, usage, errorCode?, nextCursor?}`.

Exit codes: `0` ok · `2` partial · `3` refused (OUT_OF_SCOPE, SANDBOX_UNAVAILABLE, TEST_NOT_APPROVED, TARGET_CHANGED) · `4` executed test failed · `1` internal.

## MCP server
Stdio server exposing eleven typed tools: `lla_open`, `lla_detect`, `lla_plan`,
`lla_inspect`, `lla_evidence`, `lla_test`, `lla_unseal`, `lla_recover`, `lla_report`,
`lla_benchmark`, `lla_doctor`; and three resources: `lla://guides/architecture`,
`lla://guides/testing`, `lla://guides/skill`.

Example client config:
```json
{
  "mcpServers": {
    "lla": {
      "command": "node",
      "args": ["D:/mmmm/lla/dist/mcp/server.js"],
      "cwd": "D:/mmmm/lla"
    }
  }
}
```

## Scope authorization
Admission is host-owned and file-based: scopes live in `fixtures/scopes/*.json`
(override with `LLA_SCOPE_DIR`), fixtures in `fixtures/` (override with `LLA_FIXTURES_DIR`).
A scope names an approved root, allowed operations, registered test plans, budget
profile, and optional trusted key files. Targets are realpath-checked against the root
before any read; junction/symlink escapes refuse with `OUT_OF_SCOPE`.

## Sandbox
`lla test` executes only registered fixture entrypoints, only when the fixture hash
matches the manifest pin, in a child process started with
`node --permission --allow-fs-read=<worker> --allow-fs-read=<fixture> --allow-fs-read=<request>`,
inside a `vm` script with a wall-clock timeout. Disable with `LLA_SANDBOX=off` (tests then
refuse; nothing executes on the host).

## Static unseal
`lla unseal` (CLI, MCP `lla_unseal`) recovers source from executable-shaped containers
without ever executing or patching them: ASAR pickles (including inside an EXE prefix),
ZIP archives (EOCD + central directory, stored and deflate, tolerant of prepended
bytes), and `#LLA-SEALED#` raw blobs are extracted structurally; decryption keys and
declared sha256 digests are harvested from the loader text embedded in the artifact
itself (hex/base64 literals, `Buffer.from` calls, ASCII/UTF-16 strings — no external key
source); ciphertexts are tried against AES-256/128-GCM, AES-256/128-CBC, RC4 and
repeating-XOR, and a plaintext is accepted only on a declared-digest match or structural
validation (UTF-8, ≥90% printable, ≥3 JS signals). When a loader derives the key at
runtime instead of embedding it, that loader text is evaluated inside the
permission-model sandbox (stubbed fs, 5 s vm bound, capture at the `createDecipheriv`
boundary) and the derived key/plaintext feed the same acceptance gate. Because the
binary is only read, embedded integrity checks stay intact on disk — the recovered
source is verified behaviorally instead. The plaintext is registered as a derived
fixture under
`out/unsealed/<id>/` (`container-map` evidence, single-entry `manifest-entry.json`
bound to the plan) and becomes a first-class target for `lla test` and `lla recover`:
sealed EXE → unseal → derived fixture → oracle test → recovery slice, all in one chain.

## Counterfactual recovery
`lla recover` (CLI, MCP `lla_recover`) eliminates decoy code from an admitted artifact by
differential testing: candidate statement deletions are evaluated over a grid of
registered plan assertions plus numeric probes inside the same permission sandbox, a
deletion is kept only when every grid output is byte-identical, and the final slice is
re-verified against the full registered plan. Output slices land in `out/recovery/` with a
`recovery-slice` evidence record (`originalBytes`, `recoveredBytes`, `acceptedDeletions`,
`rounds`, `verification`). Originals are never modified.

The recovered slice is the hand-off artifact for semantic reconstruction — see
`docs/rea-integration.md` for the combined LLA + REA MCP setup and the detect → test →
recover → analyze → re-verify workflow.

## Evidence and claims
Every observation becomes an immutable evidence record (`ev-…`, content-hashed).
Claims are validated by evidence kind only: independent-oracle match → `verified`;
oracle mismatch → `contradicted`; declarations alone → never `verified`; anything else →
`observed`/`unknown`. Report pages are cursor-bound and size-capped.

## Fixtures
`npm run fixtures:generate` writes deterministic synthetic fixtures (seeds 1337
development / 9001 holdout): arithmetic, string, and state-machine modules in clean /
BLA-like protected / minified / generically-obfuscated / decoy / mutant variants, plus
python, wasm, asar, sqlite, malformed, loop, sealed containers (EXE-prefixed ASAR +
AES-256-GCM, ASAR + AES-256-GCM with a runtime-derived key, ZIP + AES-256-CBC, raw
`#LLA-SEALED#` + XOR), and ed25519-signed manifest
sidecars. Manifest hash and test-vector hash are reproducible (`fixtures/manifests/lab.json`).
`fixtures/upstream/bla-3.7.0` holds 12 owner-authorized `bla-agents@3.7.0` Stage-1
`protect` outputs with `PROVENANCE.json`; their manifest is
`fixtures/manifests/bla-real.json`.

## Status and honest limits
- 88/88 tests green (unit 36, adversarial 14, integration 38) on Windows + Node 24.
- Benchmark numbers are `offline-mock`. Synthetic corpus: LLA tp 8 / fp 0 / tn 12 /
  fn 0. Real corpus (12 Stage-1 outputs, no credentials used): provenance confirms
  12/12 and the sandbox oracle passes 84/84 assertions; the blind structural heuristics
  fire on none of them (fn 12) — recorded honestly, thresholds not retuned
  (docs/upstream-review.md, DECISIONS D016).
- Recovery on the real corpus: 12/12 artifacts recovered, 1,655,599 → 263,720 bytes
  (15.9%, per-artifact 6.0%–30.7%), 15,516 deletions, and all 84 plan assertions still
  match on the produced slices (reports/recovery.md, DECISIONS D017). Stage-1 only.
- Sealed chain (A15): ASAR+GCM, ZIP+CBC, raw-marker+XOR and runtime-derived-key
  containers unseal with digest-confirmed plaintext, pass the registered oracle on the
  derived fixture, and recover to a smaller module.exports-preserving slice — container
  bytes unchanged, tampered copies refused (DECISIONS D019/D020). Runtime keys are
  reachable for loaders that derive them through `require("crypto")`; ZIP64 and keys
  computed entirely outside the loader are out of reach.
- REA bridge documented and pinned (`rea-agents@7.0.0`) in docs/rea-integration.md;
  REA was not executed in these runs (DECISIONS D018).
- Per-format capabilities: reports/capabilities.json. Detection defaults: DECISIONS.md.

## Contributing
Contributions are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md) for dev setup, the
full gate list, and project conventions (evidence-first claims, deterministic fixtures,
DECISIONS entries). Issues labelled `good first issue` are scoped for newcomers.

## License
MIT (see LICENSE). Scope authorization remains with the artifact owner.