@aliip/pilah 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/BUILD_STATUS.md +23 -0
  2. package/LICENSE +21 -0
  3. package/README.md +108 -2
  4. package/assets/logo.svg +5 -0
  5. package/docs/ACCEPTANCE_GATE.md +41 -0
  6. package/docs/ADAPTIVE_RCA_WORKFLOW.md +93 -0
  7. package/docs/AGENT_DECISION_REVIEW.md +17 -0
  8. package/docs/ALWAYS_ON_5_WHYS.md +75 -0
  9. package/docs/ARCHITECTURE.md +43 -0
  10. package/docs/BEHAVIORAL_5_WHYS_V2_0_1.md +117 -0
  11. package/docs/CHECKPOINT_RECOVERY.md +86 -0
  12. package/docs/CI_EFFICIENCY.md +63 -0
  13. package/docs/COMPATIBILITY.md +84 -0
  14. package/docs/CONTRACTS.md +177 -0
  15. package/docs/CONVERSATION_USAGE.md +52 -0
  16. package/docs/ENGINEERING_METHOD.md +68 -0
  17. package/docs/HOST_VALIDATION.md +35 -0
  18. package/docs/INDEPENDENT_ACCEPTANCE_RUNBOOK.md +72 -0
  19. package/docs/INTERVENTION_LEDGER.md +25 -0
  20. package/docs/MAIN_VALIDATION_BACKLOG.md +19 -0
  21. package/docs/NATIVE_FIRST_WORKFLOW.md +27 -0
  22. package/docs/OPEN_SOURCE_ENGINEERING_STANDARDS.md +62 -0
  23. package/docs/ORCHESTRATION_ADVISOR.md +36 -0
  24. package/docs/PRE_VNEXT_INTEGRATION.md +27 -0
  25. package/docs/README.md +54 -0
  26. package/docs/RELEASE.md +33 -0
  27. package/docs/RELEASE_AUTHORIZATION.md +33 -0
  28. package/docs/RISK_GUIDANCE.md +18 -0
  29. package/docs/SECURITY.md +76 -0
  30. package/docs/SECURITY_RELIABILITY_AUDIT_V2_0_1.md +55 -0
  31. package/docs/SEMANTIC_EVIDENCE.md +27 -0
  32. package/docs/SOURCES.md +13 -0
  33. package/docs/TOKEN_EFFICIENCY.md +71 -0
  34. package/docs/TOKEN_PROVENANCE.md +15 -0
  35. package/docs/V2_0_1_TRACEABILITY.md +66 -0
  36. package/hooks.json +45 -0
  37. package/mcp_config.json +16 -0
  38. package/package.json +31 -4
  39. package/plugin.json +27 -0
  40. package/rules/AGENTS.md +2 -0
  41. package/schemas/database.sql +84 -0
  42. package/schemas/mcp-tools.json +552 -0
  43. package/scripts/a2a.mjs +344 -0
  44. package/scripts/check-release.mjs +42 -0
  45. package/scripts/check-syntax.mjs +30 -0
  46. package/scripts/checkpoint.mjs +50 -0
  47. package/scripts/compare-agent-traces.mjs +53 -0
  48. package/scripts/context-guardian.mjs +132 -0
  49. package/scripts/evaluate-acceptance.mjs +110 -0
  50. package/scripts/export-benchmark.mjs +31 -0
  51. package/scripts/generate-contracts.mjs +6 -0
  52. package/scripts/hook.mjs +406 -0
  53. package/scripts/host-check.mjs +40 -0
  54. package/scripts/intervention-ledger.mjs +94 -0
  55. package/scripts/pilah.mjs +3 -0
  56. package/scripts/release-authorization.mjs +137 -0
  57. package/scripts/review-agent-decisions.mjs +34 -0
  58. package/scripts/semantic-evidence.mjs +15 -0
  59. package/scripts/verifykit.mjs +3 -0
  60. package/skills/pilah/SKILL.md +24 -0
  61. package/src/acceptance-matrix.mjs +84 -0
  62. package/src/browser-evidence.mjs +40 -0
  63. package/src/context-health.mjs +14 -0
  64. package/src/conversations.mjs +302 -0
  65. package/src/engine.mjs +494 -0
  66. package/src/graph.mjs +169 -0
  67. package/src/mcp-diagnostics.mjs +53 -0
  68. package/src/mcp.mjs +151 -0
  69. package/src/model-recovery.mjs +108 -0
  70. package/src/native-tool-recovery.mjs +45 -0
  71. package/src/node-runtime.mjs +13 -0
  72. package/src/orchestration-advisor.mjs +24 -0
  73. package/src/rca.mjs +174 -0
  74. package/src/risk-guidance.mjs +95 -0
  75. package/src/scanner.mjs +303 -0
  76. package/src/security.mjs +793 -0
  77. package/src/semantic-evidence.mjs +144 -0
  78. package/src/skill-discovery.mjs +23 -0
  79. package/src/sqlite-compat.mjs +11 -0
  80. package/src/storage.mjs +455 -0
  81. package/src/tokens.mjs +627 -0
  82. package/src/tools.mjs +164 -0
  83. package/src/verification.mjs +567 -0
  84. package/src/workflow-router.mjs +34 -0
@@ -0,0 +1,23 @@
1
+ # PILAH — build and validation status
2
+
3
+ **As of 24 November 2026:** PILAH is on `main` with source manifest version `1.0.0`. The canonical repository remains `the existing repository` until a separate GitHub rename. `@aliip/pilah` is the package manifest name, **not confirmation of publication**.
4
+
5
+ | Area | Observable evidence | Boundary |
6
+ | --- | --- | --- |
7
+ | PILAH rebrand | PR #107, 9/9 matrix | Source-level Node 22/24/26.13.1 CI across three OS |
8
+ | Reduced CI and native routing | PR #108 | 1 full-suite job/PR, 3 on main, 9 manually available |
9
+ | Latest verified main source CI | Run #45313799636 | **3/3** Ubuntu/macOS/Windows Node 24 jobs passed at `9426397` |
10
+ | Engineering hardening | PRs #111–#115 | MCP contracts, directional graph, SAFE handoffs, consent-gated privacy, Python imports, and fail-closed CLI host preflight passed their PR suites; no live host proof |
11
+ | Installed Antigravity | [Backlog](docs/MAIN_VALIDATION_BACKLOG.md) | No complete independent live-host acceptance for PILAH |
12
+ | Context Guardian overhead | [Backlog](docs/MAIN_VALIDATION_BACKLOG.md) | Host per-invocation latency/CPU/token effect not measured |
13
+ | Token savings | [Validation backlog](docs/MAIN_VALIDATION_BACKLOG.md) | Not established through matched independent trials |
14
+ | Real Acceptance F01–F18 | [Independent runbook](docs/INDEPENDENT_ACCEPTANCE_RUNBOOK.md) | Runtime HTTP/DB/browser cases not established as PASS |
15
+ | npm / GitHub Package / tagged release | [Release authorization](docs/RELEASE_AUTHORIZATION.md) | **NO-GO** without signed external evidence and approval |
16
+
17
+ Green CI means the complete checked-in test suite and static release checks passed for the specified commit and runner—not actual browser, printing, database race, installed plugin, autonomous tool selection, or cost evidence. Keep missing acceptance marked **not tested**.
18
+
19
+ ## Earlier PILAH provenance
20
+
21
+ The original `v2.0.1` integration was promoted to `main` through PR #105; PILAH branding followed in PR #107. Issues #15, #71, #91 and #92 were closed **administratively as deferred/superseded**, not completed evidence. Historical 213/213 tests and 4/4 OS/runtime jobs describe an older source snapshot, not the current version.
22
+
23
+ Check [documentation](docs/README.md), [CI lanes](docs/CI_EFFICIENCY.md), and [outstanding validation](docs/MAIN_VALIDATION_BACKLOG.md). Do not infer release authorization from a merge.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 VerifyKit Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,109 @@
1
- # Temporary Holding Version
1
+ # PILAH
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Project Intelligence, Logic, Analysis & Handoffs** — a small, native-first engineering layer for Google Antigravity.
4
+
5
+ PILAH helps coding agents find relevant cross-file context, reason about change impact, plan verification and track evidence **only when native tools cannot efficiently resolve the uncertainty**. PILAH does **not** edit project files, run shell commands, launch agents, replace Antigravity, or guarantee token savings.
6
+
7
+ **CI:** view the repository's Actions tab · [Documentation](docs/README.md) · [MIT License](LICENSE)
8
+
9
+ > **Source status — 24 November 2026:** The plugin is named **PILAH** (manifest `1.0.1`); the repository is accessed through the current URL displayed in GitHub's **Code** menu. The package manifest uses `@aliip/pilah`, but **publication is not verified**. The source-level CI passed on the latest main push (3/3 OS jobs on Node 24). Real installed Antigravity adoption, independent Acceptance F01–F18 runtime validation and matched token benchmarks are **not yet verified**. See [current status](BUILD_STATUS.md) and [validation backlog](docs/MAIN_VALIDATION_BACKLOG.md).
10
+
11
+ ## What it provides
12
+
13
+ | MCP tool | Use it for | Does not do |
14
+ | --- | --- | --- |
15
+ | `pilah_context` | Targeted symbol, source and cross-file relationship queries | Automatically read an entire repository for each prompt |
16
+ | `pilah_impact` | Scoped change-impact and candidate tests | Prove that every dependency or behavior was covered |
17
+ | `pilah_verify` | Risk-aware acceptance planning and named test-evidence assessment | Run or independently certify actual tests |
18
+ | `pilah_evidence` | Source-bound incidents, optional checkpoints and recovery guidance | Replay unknown tools or grant new permissions |
19
+
20
+ The scanner resolves basic local Python imports, configured Composer PSR-4 PHP class imports, and explicit JS/TS path aliases only when exact target files exist. Runtime framework dispatch remains unknown. Only `pilah_context` is eager by default; the other tools remain lazy. **A clear task should trigger zero PILAH calls.** One precise call is preferable to an automatic chain. For difficult bugs: reproduce → test a hypothesis → make the smallest complete fix → run relevant tests → report what remains unverified. See the [PILAH skill](skills/pilah/SKILL.md) and [engineering method](docs/ENGINEERING_METHOD.md).
21
+
22
+ ## Requirements and source setup
23
+
24
+ In the command below, replace `REPOSITORY_URL` with the HTTPS clone URL from the repository's GitHub **Code** menu.
25
+
26
+ - Node.js **22.13.0 or newer** with built-in `node:sqlite`; no third-party npm runtime dependencies.
27
+ - Google Antigravity with support for the plugin/MCP features used here.
28
+ - Permission to inspect the intended workspace; protected roots, sensitive files and revoked workspaces remain denied.
29
+
30
+ ```sh
31
+ git clone REPOSITORY_URL pilah
32
+ cd pilah
33
+ node --version
34
+ npm run check
35
+ node scripts/check-release.mjs
36
+ node scripts/pilah.mjs doctor
37
+ node scripts/pilah.mjs doctor --public # Redacted diagnostics for issue reports
38
+ node scripts/pilah.mjs host-check # requires agy; may report blocked
39
+ ```
40
+
41
+ The optional `host-check` command only validates the CLI's plugin manifest and whether PILAH appears in plugin listings. It cannot certify tool selection, browser workflows or independent E2E behavior. Missing `agy` is reported as blocked, not passed.
42
+
43
+ Install/register this **source checkout** using the native plugin manager supported by your Antigravity version. If the `agy` CLI is available, validate it with `agy plugin validate --strict .` and inspect `agy plugin list`. These are **steps for your machine**, not claims of a completed live installation test. For real host acceptance criteria, see [the host-validation runbook](docs/HOST_VALIDATION.md). The bundle includes `plugin.json`, `mcp_config.json`, `hooks.json`, `rules/AGENTS.md` and `skills/pilah/SKILL.md`.
44
+
45
+ Do not rely on the unpublished `@aliip/pilah` package identifier as an installation command. Avoid registering duplicate plugin instances unless explicitly intended.
46
+
47
+ ## CLI from a checkout
48
+
49
+ The supported source CLI is `scripts/pilah.mjs`, and the package manifest declares `pilah` as its preferred binary name. The following commands are **CLI subcommands**, not guaranteed Antigravity slash commands:
50
+
51
+ ```sh
52
+ node scripts/pilah.mjs help
53
+ node scripts/pilah.mjs doctor
54
+ node scripts/pilah.mjs mode on-demand
55
+ node scripts/pilah.mjs mode always-on # optional, explicit opt-in
56
+ node scripts/pilah.mjs toggle
57
+ node scripts/pilah.mjs compact on
58
+ node scripts/pilah.mjs autotrust active-only
59
+ node scripts/pilah.mjs allow /absolute/path/to/project
60
+ node scripts/pilah.mjs revoke /absolute/path/to/project
61
+ node scripts/pilah.mjs inspect /absolute/path/to/project
62
+ node scripts/pilah.mjs privacy status /absolute/path/to/project
63
+ node scripts/pilah.mjs impact /absolute/path/to/project src/auth.js
64
+ node scripts/pilah.mjs tokens --limit 5 --json
65
+ node scripts/pilah.mjs route --profile economy --task cross-file --uncertain
66
+ ```
67
+
68
+ **Defaults:** On-Demand and Compact. Always-On remains opt-in and does not require a tool call for simple tasks. Context Guardian is separate, also opt-in, and does not compact conversations automatically. `tokens` distinguishes observed metadata and estimates from provider-reported usage; **model token savings cannot be inferred from a smaller response or fewer MCP calls**.
69
+
70
+ For intentionally clearing locally stored workspace records, run `node scripts/pilah.mjs privacy purge /absolute/path/to/project --confirm-purge`. This deletes only the project's scoped SQLite records; it **does not** delete source files, evidence artifacts on disk, trust grants, or unscoped historic notes. Back up anything you need first.
71
+
72
+ `inspect` includes bounded file-scan I/O diagnostics. Use `node benchmarks/bench.mjs` to measure cold/warm local indexing, rather than treating bytes scanned as model token usage.
73
+
74
+ ## Verification example
75
+
76
+ Send the following arguments to `pilah_verify` with `operation="plan"`:
77
+
78
+ ```json
79
+ {
80
+ "workspace": "/absolute/path/to/project",
81
+ "operation": "plan",
82
+ "criteria": [{
83
+ "id": "duplicate-checkin",
84
+ "given": "A guest already checked in",
85
+ "when": "The QR code is scanned again",
86
+ "then": "No second print job is produced",
87
+ "evidence_type": "hardware",
88
+ "negative": true
89
+ }]
90
+ }
91
+ ```
92
+
93
+ Planning produces `not_tested` until evidence exists. A passing build or a local test report is **not** proof of real printer hardware, UI state, security, browser behavior or independent release acceptance. Run the actual tests with native Antigravity tools and report the names of the tests that ran. See [MCP contracts](docs/CONTRACTS.md), [security](docs/SECURITY.md) and [independent acceptance](docs/INDEPENDENT_ACCEPTANCE_RUNBOOK.md).
94
+
95
+ ## Compatibility with earlier installations
96
+
97
+ Public MCP tools use the `pilah_*` prefix. Previous tool and CLI aliases, environment settings and local data remain supported internally, so existing installations retain their workspace authorization and saved history. For the exact compatibility identifiers, consult [tool definitions](src/tools.mjs) and [security source](src/security.mjs). Do not guess or rename configuration keys.
98
+
99
+ Use the repository URL from the GitHub **Code** menu to clone. Do not delete existing configuration or database folders when installing PILAH.
100
+
101
+ ## Testing, CI and release
102
+
103
+ Routine CI now uses **1 full-suite PR job** on Ubuntu/Node 24, **3 jobs on main** (Ubuntu/macOS/Windows, Node 24), with the **full 9-job OS × Node 22/24/26.13.1 matrix** available by manually dispatching the workflow. A green repository CI run is not a live Antigravity acceptance or publication authorization. No automatic release or new package publication was performed.
104
+
105
+ - [Documentation index](docs/README.md) · [Architecture](docs/ARCHITECTURE.md) · [Compatibility](docs/COMPATIBILITY.md)
106
+ - [CI and efficiency methodology](docs/CI_EFFICIENCY.md) · [Release process](docs/RELEASE.md)
107
+ - [Status](BUILD_STATUS.md) · [Outstanding independent validation](docs/MAIN_VALIDATION_BACKLOG.md)
108
+
109
+ [MIT](LICENSE) © 2026 Alif Akbar and contributors.
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" width="256" height="256" role="img" aria-label="PILAH mark">
2
+ <rect width="256" height="256" rx="44" fill="#F4F3EF"/>
3
+ <path d="M73 198V60h65c37 0 65 21 65 54s-28 54-65 54h-29" fill="none" stroke="#181C22" stroke-width="23" stroke-linejoin="round" stroke-linecap="round"/>
4
+ <circle cx="143" cy="114" r="12" fill="#4263EB"/>
5
+ </svg>
@@ -0,0 +1,41 @@
1
+ # PILAH Independent Release Assessment (#4)
2
+
3
+ `pilah_verify(operation="assess")` checks named JUnit/TAP/JSON assertions **only**. It now states `release_ready:false` even when tests pass.
4
+
5
+ For critical release readiness, use `pilah_verify(operation="assess_release",artifact="reports/release.json")` in an authorized workspace or `node scripts/evaluate-acceptance.mjs release.json [trusted-public-keys.json]` offline.
6
+
7
+ ## Trust configuration
8
+ PILAH reads **public** Ed25519 evaluator keys from `~/.config/pilah/trusted-evaluators.json` when using the MCP action. A user/independent CI administrator must provision and protect this file **outside the coding agent's project**. Example:
9
+
10
+ ```json
11
+ {"ci-reviewer":"-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----\n"}
12
+ ```
13
+
14
+ Do **not** generate or trust a public key submitted inside the implementation repository; the key is only meaningful when controlled independently from the agent being evaluated. Never commit the private signing key.
15
+
16
+ A release manifest provides `revision`, `evaluator:{"name":"independent-ci","independent":true}`, `scenarios` and `critical_defects`. Each `passed` scenario needs machine evidence of type junit/tap/browser/security/integration/etc. with `outcome:passed`, the current `revision`, an opaque `reference`, `checked_at`, a 64-hex `artifact_sha256`, a positive `assertion_count`, `key_id` and a base64 Ed25519 `signature`.
17
+
18
+ The signature covers the canonical UTF-8 JSON serialization produced by `attestationPayload({revision,scenarioId,evidence})` in `scripts/evaluate-acceptance.mjs`. The independent test runner must create the payload **after executing and checking its assertions**, then sign it. The code only **verifies signature and metadata**; it does not run the tests itself.
19
+
20
+ Critical scenarios without an independently verified signature are downgraded to `not-tested`. Stale revision, mismatched evidence types and open critical defects block readiness. Successful evaluation means **eligible for independent review**, not production security certification. A valid signature proves possession of a trusted issuer key, not semantic correctness of the tests.
21
+
22
+ No PILAH tool launches a CI runner, changes filesystem permission, or approves a PR automatically.
23
+
24
+
25
+ ## Mandatory frozen acceptance scope
26
+
27
+ A signed test result is not proof that the agent submitted every required scenario. Release eligibility now fails closed unless an independent user-pinned registry matches all scenario IDs, requirement SHA-256 hashes, critical flags and required evidence types. The agent must not be able to edit the registry or signing keys.
28
+
29
+ Place the registry at `~/.config/pilah/acceptance-registry.json` outside the generated application workspace:
30
+
31
+ ```json
32
+ {"schema":"<registry-schema-id-from-source>","scenarios":[{"id":"offline-restart","requirement_sha256":"64-character-sha256-of-the-exact-requirement","critical":true,"required_evidence_types":["browser","integration"]}]}
33
+ ```
34
+
35
+ The registry is read by `pilah_verify(operation="assess_release")`. The CLI `scripts/evaluate-acceptance.mjs` also accepts an optional pinned-registry path after the trust-keys path.
36
+
37
+ Without a matching registry, `release_ready` stays false even if all submitted assertions have valid signatures. A true result means eligible for independent review of signed evidence, not proof of test execution or production certification. File permissions and reviewer keys must be protected by the user's OS.
38
+
39
+ ## Behavioral completion versus release gate (v2.0.1)
40
+
41
+ PR #36 added a separate **typed** plan/assessment contract: each criterion may declare `given`, `when`, `then` and `evidence_type`; browser and visual criteria require `viewport`, `ui_state` and `reference`. Planning is `not_tested`. Local `assess` can report passed **named machine assertions** but its `completion.fully_verified` stays false, and local test artifacts cannot independently establish UI/browser, hardware, security or release evidence. `assess_semantic` and `assess_browser` remain **unattested structural reviews**. Only the separately signed, pinned `assess_release` plus the [publish authorization policy](RELEASE_AUTHORIZATION.md) can contribute to release eligibility. F01–F18 external evidence is still pending.
@@ -0,0 +1,93 @@
1
+ > **Historical research record:** Terminology has been standardized to PILAH. Dates, CI results and observed limitations refer to the source revision investigated at that time, not necessarily the current plugin.
2
+
3
+ # Adaptive 5 Whys — evidence-guided RCA in PILAH v2.0.1
4
+
5
+ **Status:** Local software workflow and verification contract; not an automatic investigator, model chain, forensic proof, native test runner or independent release approval. See issue #48 and the original [behavioral Five Whys](BEHAVIORAL_5_WHYS_V2_0_1.md).
6
+
7
+ ## Zero-first workflow
8
+
9
+ 1. **Fast path (zero RCA tool calls):** simple typo, isolated change or cause already reproduced and understood → native edit and targeted regression. Do not invoke PILAH merely to ask five questions.
10
+ 2. **RCA-lite (native reasoning, zero or one context/impact call):** for uncertain nontrivial bugs, state expected versus actual, the observed symptom, one or two *competing* causes, a falsifier for each and the cheapest differentiating experiment. A chain may stop after two or three Whys. No storage unless explicitly approved.
11
+ 3. **RCA-deep (opt-in):** recurrent failure, regression after a fix, inconsistent browser/printer result, concurrency, authorization, financial effects or multi-module ambiguity. If useful, one targeted `pilah_context(query,limit=5)` OR `pilah_impact(summary=true)`. The native Antigravity agent still runs experiments; PILAH records only explicitly approved, bounded structured notes.
12
+ 4. **Evidence:** use a real named unit/integration JUnit/TAP/PILAH JSON testcase with `pilah_verify(assess)`. Do not infer a root cause from a successful build, UI test name, tester's narrative or the mere presence of an evidence ID.
13
+ 5. **Countermeasure:** minimize the fix; include controlled negative controls, recurrence scenario and non-regression cases. Re-check source revisions and evidence artifacts after any edit. Report separately what the test supports, what was refuted and what remains unverified.
14
+
15
+ ## Explicit local RCA lifecycle (four existing MCP tools)
16
+
17
+ ### 1. Record observed incident (not a proven root cause)
18
+
19
+ ```json
20
+ {
21
+ "workspace": "/authorized/project",
22
+ "operation": "record_incident",
23
+ "persist_rca": true,
24
+ "title": "Second QR scan triggers duplicate print",
25
+ "root_cause": "Possible UI handler replay",
26
+ "paths": ["src/checkin.js"]
27
+ }
28
+ ```
29
+
30
+ Invoke via `pilah_evidence` only with user consent to retain RCA text locally. `root_cause` is retained for backwards compatibility but treated as a **candidate**, never verified. Incident state is `investigating`. A linked evidence ID is checked for authorized workspace, fresh source and intact artifact, but **does not prove relevance or cause**. A repeat incident signature may suggest a prior related incident ID, not its cause.
31
+
32
+ ### 2. Create falsifiable hypothesis
33
+
34
+ ```json
35
+ {
36
+ "workspace": "/authorized/project",
37
+ "operation": "add_hypothesis",
38
+ "persist_rca": true,
39
+ "incident_id": "<incident ID>",
40
+ "hypothesis": "The check-in UI sends the same print event twice",
41
+ "experiment": "Disable UI handler, replay one check-in and compare server print counts",
42
+ "predicted_observation": "No second print after disabling the handler",
43
+ "disconfirming_test": "Observe duplicate backend queue prints with UI handler disabled",
44
+ "expected_criterion_id": "qr-print-guard"
45
+ }
46
+ ```
47
+
48
+ Optional `parent_hypothesis_id` creates **branches** of a Why chain up to eight levels; multiple hypotheses can represent competing causes. Optional `plan_id` ensures the criterion belongs to an intact, current, opt-in acceptance plan. An arbitrary string is **not** an executed test or independent witness.
49
+
50
+ ### 3. Run native test then assess it
51
+
52
+ Run the controlled experiment with native Antigravity tools. Produce JUnit/TAP/PILAH JSON and assess the *exact named* unit/integration test with `pilah_verify(operation="assess")`. Capture its `evidence_id`. Then:
53
+
54
+ ```json
55
+ {
56
+ "workspace": "/authorized/project",
57
+ "operation": "assess_hypothesis",
58
+ "persist_rca": true,
59
+ "hypothesis_id": "<hypothesis ID>",
60
+ "experiment_outcome": "supports",
61
+ "observation": "The named regression passed after suppressing the duplicate handler",
62
+ "evidence_ids": ["<fresh exact named-test evidence ID>"]
63
+ }
64
+ ```
65
+
66
+ Allowed outcomes: `supports`, `refutes`, `inconclusive`. Results are `locally_supported`, `refuted` or `inconclusive`, **never `proven`**. For supports/refutes, the evidence must be a passing exact named **unit/integration** assertion for the hypothesis' `expected_criterion_id`, from the same authorized workspace/source revision and an intact report. A passing negative-control test can be submitted with the agent's interpretation `refutes`; that interpretation is not cryptographically attested. **Failed, build-only, visual, browser, hardware, security, stale, unrelated and altered artifacts cannot promote a hypothesis.**
67
+
68
+ ### 4. Read status and re-evaluate when source changes
69
+
70
+ `pilah_evidence(operation="hypotheses",incident_id="...")` lists branches, recorded outcomes and source freshness; `operation="incidents"` shows candidate causes with `root_cause_verified:false`. When source changes, old hypotheses are reported `stale`; create a new reviewed hypothesis and run new tests. Do not silently reuse an earlier `locally_supported` status. The final response distinguishes **reproduced, locally supported, refuted, stale, blocked and untested**.
71
+
72
+ ## Safety and token budget
73
+
74
+ - Default **On-Demand**: no automatic RCA calls, session notices, extra models or teamwork. Compact output retains all causal proof warnings. The skill adds only one short adaptive branch, staying under its existing 3,000-character CI limit.
75
+ - **Consent:** `persist_rca:true` is required for local writes. Persist only minimal text; common plaintext secret assignments are rejected as defense in depth, not perfect secret filtering. No raw transcripts, credentials or customer artifacts should be copied into notes.
76
+ - **Bounded:** max 8 Why depth, up to 20 evidence links, 40 criteria and standard MCP response limits. Existing SQLite history remains locally stored; disabling other snapshot features does **not** automatically erase RCA records.
77
+ - **No automatic evidence creation:** risk-guidance templates are suggestions, `required_test_ids` remains empty for that advisory, and only explicit user-reviewed acceptance criteria are mandatory.
78
+ - **Locality vs causality:** a named passing unit/integration assertion and an agent's observation may be useful diagnostic support, but they cannot independently establish production behavior or causal truth. The signed release process is separate.
79
+
80
+ ## Regression acceptance
81
+
82
+ The repository tests cover consent, hypothetical competing causes and parent branches, refutation, missing/unrelated/build-only/altered/stale evidence, source revision changes, existing SQLite migration, Compact warnings and actual MCP stdio+SQLite lifecycle. These are **synthetic tests**. The external release issue #15 still requires real installed Antigravity, F01–F18, browser/physical printer where applicable, independent validation and repeated matched Native/PILAH trials with official provider usage.
83
+
84
+ Source of truth: [`src/rca.mjs`](../src/rca.mjs), [MCP contracts](CONTRACTS.md), [database schema](../schemas/database.sql), [tests](../tests/rca_lifecycle.test.mjs).
85
+
86
+ ### 5. Inspect bounded history or delete RCA notes
87
+
88
+ In default Compact, `pilah_evidence(operation="incidents"|"hypotheses")` returns up to **8** entries, including `total`, `more_available` and a proof-warning. Use `compact off` to inspect up to 50 records. Reading a prior locally supported/refuted hypothesis re-checks all its linked artifact hashes; missing/modified evidence changes the displayed status to **stale**, even if source revision itself is unchanged.
89
+
90
+ For explicit local cleanup, `pilah_evidence(operation="delete_incident",incident_id="...",persist_rca=true,confirm_deletion=true)` logically removes **one** incident and its attached hypotheses, leaving independent test artifacts, acceptance plans and other incidents untouched. Require user approval: deletion cannot be undone through PILAH, but SQLite WAL/backups may retain old bytes, so it is **not cryptographic erasure**. Do not claim this deletes all related personal data.
91
+
92
+ Each assessment also appends a local immutable-in-application **experiment history entry** (observation, outcome, exact criterion, evidence IDs, revision and time). The `hypotheses` response returns up to three recent outcomes and the `experiments_total` count; it never upgrades those user-reported interpretations to independent proof. Deleting an incident logically deletes its hypotheses **and this experimental history**, leaving unrelated reports intact.
93
+
@@ -0,0 +1,17 @@
1
+ > **Historical research record:** Terminology has been standardized to PILAH. Dates, CI results and observed limitations refer to the source revision investigated at that time, not necessarily the current plugin.
2
+
3
+ # Independent Observable Agent-Decision Review
4
+
5
+ **Purpose:** inspect *observable* Antigravity tool and work decisions, **not hidden model reasoning**. This optional source-checkout utility was introduced for issue #12.
6
+
7
+ ## Local usage
8
+
9
+ ```bash
10
+ node scripts/review-agent-decisions.mjs local-transcript.jsonl independent-review.json
11
+ ```
12
+
13
+ The external review JSON identifies `reviewer.role="independent"` and annotations with `step_index`, `area` (planning, diagnosis, tool-selection, verification, error-recovery, handoff), `grade` (supported, incomplete, contradicted, not-observable) and opaque `evidence_ref` such as `trace:step10`.
14
+
15
+ The utility validates that referenced observable steps exist and summarizes **reviewer-reported judgments**. It cannot certify reviewer independence, inspect hidden chain-of-thought, authenticate raw transcript observations, or demonstrate that an PILAH intervention caused better code. Store transcripts privately; remove credentials and user content before any sharing.
16
+
17
+ **Current context:** behavioral reliability PR #36 merged into `v2.0.1`, with local MCP/SQLite E2E passing. Live Antigravity/18-case acceptance remains open in #15. See [5 Whys](BEHAVIORAL_5_WHYS_V2_0_1.md).
@@ -0,0 +1,75 @@
1
+ > **Historical research record:** Terminology has been standardized to PILAH. Dates, CI results and observed limitations refer to the source revision investigated at that time, not necessarily the current plugin.
2
+
3
+ # Always-On Token Efficiency: Five-Whys Scenarios
4
+
5
+ ## Scope and evidence level
6
+ **Code-observed:** persistent plugin rules, lifecycle hooks, skeleton output, repeated tool instructions, estimated telemetry. **Not yet measured:** per-task increase/decrease in Gemini token consumption. Use [TOKEN_EFFICIENCY.md](TOKEN_EFFICIENCY.md) for real A/B trials. Do not turn these causal hypotheses into claimed percent savings.
7
+
8
+ ## Scenario 1 — Simple typo edit consumes unnecessary context
9
+ 1. **Why** may the task use more input tokens? Plugin guidance is present even for a trivial change.
10
+ 2. **Why** is guidance always present? The bundled `rules/AGENTS.md` is continuously active, independent of the current mode.
11
+ 3. **Why** was it large? The rules bundled all verification, dependency, token metrics and teamwork procedures.
12
+ 4. **Why** are those unnecessary? A one-file typo does not require graph analysis, handoff reports or incident handling.
13
+ 5. **Why** was there no separation? Mode-specific decisions were expressed as persistent instructions rather than a concise router plus a one-time policy.
14
+
15
+ **Fix:** Reduce persistent rule to a tiny router; inject adaptive Always-On guidance at `SessionStart` only when enabled. Never auto-call PILAH for docs, typos, styles or isolated changes. **Proof:** static size budget test for `rules/AGENTS.md`, hook startup test.
16
+
17
+ ## Scenario 2 — The agent asks for skeleton and still reads full source
18
+ 1. **Why** might two context payloads be consumed? Both skeleton output and native full-source output reach the model.
19
+ 2. **Why** are both used? The agent still needs implementation details after initial navigation.
20
+ 3. **Why** does skeleton often not answer that need? `skeletonizeCode()` strips comments/blank lines, not method bodies.
21
+ 4. **Why** was it treated as a general context replacement? The policy encouraged skeletonization for every unfamiliar file.
22
+ 5. **Why** did this persist? The savings calculation compares hypothetical raw source with skeleton output, not two complete task traces.
23
+
24
+ **Fix:** In Always-On, use `pilah_context(action="query")` for names/locations. Use skeleton only for orientation, avoid the full-read duplication when the preview suffices, and use native reads for exact implementation. **Proof:** rule/skill contract review; require empirical A/B for net effect. A true semantic outline parser is out of scope and is not claimed.
25
+
26
+ ## Scenario 3 — Every meaningful edit causes a chain of optional checks
27
+ 1. **Why** does agent reasoning/tool output grow? It calls impact, context, plan, testing, assess and history in sequence.
28
+ 2. **Why** does it call every stage? The workflow's descriptions looked mandatory rather than conditional.
29
+ 3. **Why** was no early exit allowed? The policy lacked an explicit minimum-work stop condition.
30
+ 4. **Why** did impact contribute output bloat? The full response includes up to 25 affected items, multiple test files and telemetry.
31
+ 5. **Why** wasn't a light first-pass available? PILAH offered only the full impact payload.
32
+
33
+ **Fix:** Add `pilah_impact(summary=true)` as a one-call triage that caps affected/test previews but **retains risk, uncertainty, coverage flags, and full counts**. Expand only when needed. Skip token telemetry in summary. Do not automatically call `plan` and `assess` if direct report assessment suffices. **Proof:** summary contract and integration test ensure smaller payload and no missing uncertainty.
34
+
35
+ ## Scenario 4 — High-frequency lifecycle hooks add repeated work
36
+ 1. **Why** is there overhead during each turn? The plugin spawns a Node process in `PreInvocation`.
37
+ 2. **Why** does the process run so often? Antigravity fires `PreInvocation` before model calls.
38
+ 3. **Why** does PILAH use it? To maintain active session metadata.
39
+ 4. **Why** is that repetitive? Most session identifiers are stable until a new conversation.
40
+ 5. **Why** wasn't `SessionStart` sufficient? The original architecture registered a hook for every lifecycle opportunity.
41
+
42
+ **Fix:** Remove `PreInvocation` from `hooks.json`. Use the officially supported `SessionStart` session ID, retain targeted `PostToolUse` for test/artifact bookkeeping. This reduces local CPU/process overhead, **not automatically model tokens**. **Proof:** hook configuration test. Mid-session mode toggles are communicated by command responses; start a new conversation for guaranteed startup-policy refresh.
43
+
44
+ ## Scenario 5 — Dashboard reports savings while total session tokens increase
45
+ 1. **Why** can reported savings be positive? `tokens_saved=max(0, raw_scope_tokens-response_tokens)`.
46
+ 2. **Why** is `raw_scope_tokens` a generous baseline? It estimates how much source **might** be read.
47
+ 3. **Why** isn't this net savings? Native may not read that scope, and PILAH adds its own instructions, reports and follow-up calls.
48
+ 4. **Why** aren't those included? Local telemetry sees size of its own outputs, not a counterfactual native task.
49
+ 5. **Why** was this called measured? Scoped data was confused with controlled model-session consumption.
50
+
51
+ **Fix (implemented in PR #2):** Stop exposing computed `tokens_saved`, savings percentages or dollar savings as if observed. Display source-size and tool-response estimates separately, keep net savings `null`, and accept only officially reported Antigravity CLI JSON for per-run usage. For task-level savings, a controlled [A/B evaluation](TOKEN_EFFICIENCY.md) is mandatory.
52
+
53
+ ## Always-On policy invariants
54
+ - **Correctness first:** no output compression that hides `risk`, `uncertainty`, `freshness`, or evidence status.
55
+ - **No false PASS:** relevant native tests + mapped acceptance evidence are still required for testable code deliverables.
56
+ - **No redundant work:** one impact triage per affected scope; context lookup only when needed; no auto history/telemetry calls.
57
+ - **Native-first:** PILAH does not force Teamwork, subagents, tool execution or a particular browser.
58
+ - **Privacy:** do not use internal transcripts as a billing-grade source or include private session data in task output.
59
+
60
+ ## Acceptance criteria
61
+ 1. Default `on-demand` adds no startup instruction injection; explicit `always-on` injects one adaptive policy.
62
+ 2. Persistent rule fits a 400-character budget. `PreInvocation` does not spawn PILAH.
63
+ 3. `pilah_impact(summary=true)` reports full risk/uncertainty and is smaller than the comparable full response on a dependency fixture.
64
+ 4. MCP `verify_handoff` accepts its documented parameters and does not require reports for research-only tasks.
65
+ 5. CI runs on Windows, macOS and Linux.
66
+ 6. Publish no net token savings percentage until controlled sessions demonstrate it.
67
+
68
+ ## Official platform references
69
+ - [Google Antigravity — Rules](https://antigravity.google/docs/rules/)
70
+ - [Google Antigravity — Hooks](https://antigravity.google/docs/hooks)
71
+ - [Google Antigravity — Build plugins](https://antigravity.google/docs/build-plugins/)
72
+
73
+ ## Current v2.0.1 behavioral alignment
74
+
75
+ The historical Always-On improvements remain present: on-demand by default, tiny rule, no PreInvocation, scope-limited summary and no invented token savings. Behavioral PR #36 subsequently added **typed Given/When/Then acceptance with evidence types**, **source-fresh explicit checkpoint decisions**, nonexecuting native tool failure guidance, and a stricter independence requirement for parallel teamwork recommendations. Only request these optional tools when they materially reduce uncertainty; never transform the 71.5% repeated-read *path* statistic into a measured token saving. A green local report does not make `completion.fully_verified` true. Live IDE and controlled performance benefits are still open in issue #15.
@@ -0,0 +1,43 @@
1
+ # PILAH — architecture
2
+
3
+ PILAH is a **local-first, native-first engineering support layer** for Google Antigravity. Antigravity remains responsible for reasoning, file edits, terminal/browser actions, host permissions and optional native agents. PILAH provides scoped code intelligence, candidate impact, structured verification planning, and evidence/recovery diagnostics. It is **not** an agent runtime, language server, arbitrary shell executor or a guarantee of model cost savings.
4
+
5
+ ## Runtime surface
6
+
7
+ - **Plugin:** `plugin.json`, `mcp_config.json`, `hooks.json`, `rules/AGENTS.md`, `skills/pilah/SKILL.md`.
8
+ - **Four public MCP tools:** `pilah_context`, `pilah_impact`, `pilah_verify`, `pilah_evidence`. They use JSON-RPC 2.0 over stdio and require an authorized absolute workspace. `pilah_context` is the only eager tool; others are lazy.
9
+ - **Compatibility:** public calls use `pilah_*`, and the preferred source CLI is `scripts/pilah.mjs`. Earlier internal tool aliases, configuration keys and database paths remain recognized without exposing retired names in public guides. Inspect source before changing persisted identifiers.
10
+ - **Runtime:** Node.js >=22.13.0 with built-in SQLite, no third-party npm runtime dependency, no automatic network service and no arbitrary project-command MCP tool.
11
+
12
+ ## Components
13
+
14
+ | Component | Function | Known boundary |
15
+ | --- | --- | --- |
16
+ | [Security](../src/security.mjs) | Workspace trust/revocation, protected paths, settings and bounded file reads | No authorization from untrusted tool arguments |
17
+ | [Scanner](../src/scanner.mjs) and [graph](../src/graph.mjs) | Static symbols, directional imports (including local Composer PSR-4 and configured JS/TS aliases), and heuristic test candidates | Not a compiler, full LSP or complete cross-language dependency graph |
18
+ | [Engine](../src/engine.mjs) and [MCP server](../src/mcp.mjs) | Four bounded public operations, JSON-RPC errors, read-first calls | Cannot edit code or control Antigravity |
19
+ | [Storage](../src/storage.mjs) | Local SQLite index, revision metadata, opt-in checkpoints, incident evidence and consent-gated workspace purge | Explicitly saved notes may include private user-supplied content |
20
+ | [Verification](../src/verification.mjs) | Given/When/Then scope, machine-report assessment | Local tests do not independently certify visual, security, hardware or production outcomes |
21
+ | [Token diagnostics](../src/tokens.mjs) | Local provenance, size estimates and eligible session usage | Does not prove model token savings or billing |
22
+ | [RCA](../src/rca.mjs) | Bounded hypothesis and falsification notes | Local evidence is not independent causal proof |
23
+ | [Router](../src/workflow-router.mjs) | Deterministic native-only versus scoped PILAH advice | Does not switch models or auto-call tools |
24
+
25
+ ## Versioned graph index
26
+
27
+ `src/scanner.mjs` includes an explicit `GRAPH_INDEX_VERSION` in each source snapshot fingerprint. This invalidates a previously persisted SQLite dependency graph when PILAH's static parsing semantics are upgraded, even if project files themselves are untouched. The engine rebuilds the graph using the authorized workspace's current files. This is distinct from user edits: the source-index revision may change after a plugin update, intentionally invalidating prior evidence freshness claims rather than reusing relationships from an older scanner.
28
+
29
+ Do not automatically increment this version for documentation changes. Bump it when symbol/import/relationship generation changes and preserve a regression test that loads an older index revision. Existing workspace grants, user notes and project source are not deleted.
30
+
31
+ ## Engineering flow
32
+
33
+ 1. **Native first.** If the task is clear, use zero PILAH calls. Prefer existing project code or platform primitives before adding code.
34
+ 2. **Bound uncertainty.** When cross-file ownership/risk is unclear, request only one specific `pilah_context` or `pilah_impact` result; do not automatically chain.
35
+ 3. **Reproduce and implement.** Antigravity executes approved project commands and changes source. Use a minimal complete patch, preserving validation, permissions, accessibility and public contracts.
36
+ 4. **Verify at the right level.** Define typed plans for risk, run existing native test tools, attach exact named evidence where available. Changed source revisions invalidate stale evidence. Browser/security/hardware/independent claims need independent execution.
37
+ 5. **Handoff.** State changed scope, observed results, failures, `not tested` cases and provenance. Never derive savings from response sizes or call counts.
38
+
39
+ ## Trust, privacy and release
40
+
41
+ Project root authorization is mandatory; protected paths, credential files, unsafe symlinks, unauthorized descendants and source/evidence staleness are denied or flagged. Automatic full Markdown snapshots and user-global Context Guardian are disabled by default; opt-in features may retain local state or add invocation overhead. No agent or plugin may manufacture passing independent acceptance evidence.
42
+
43
+ The [current status](../BUILD_STATUS.md), [security model](SECURITY.md), [MCP contracts](CONTRACTS.md) and [validation backlog](MAIN_VALIDATION_BACKLOG.md) determine operational claims. **Repository CI is not an installed Antigravity E2E or authorized package release.**
@@ -0,0 +1,117 @@
1
+ > **Historical research record:** Product terminology is standardized to PILAH. Earlier test results and open/closed issue states describe historical snapshots, not current release eligibility.
2
+
3
+ # Behavioral reliability — evidence-driven Five Whys and remediation
4
+
5
+ **Scope:** PILAH v2.0.1 candidate, derived from a **private** Antigravity behavioral audit covering 110 parseable sessions and 90,407 events, 28 October–18 November 2026. This document contains **sanitized aggregate observations only**. It does not embed source transcripts, private URLs, credentials, customer IDs, or screenshots.
6
+
7
+ **Method:** An observed failure mode → five explicit causal hypotheses → a bounded PILAH mechanism → a falsifiable regression. Five Whys is **causal analysis**, not a claim that every intermediate hypothesis was independently proven. The plugin does not control Google's native browser, model or tools. See #15 for real installed Antigravity and STOCKROOM live acceptance, which automated Node tests cannot replace.
8
+
9
+ ## BA-01 and BA-05 — Completion claims exceed the observed tests (P0)
10
+
11
+ **Evidence:** Agent claims of completion were followed by user reports of broken behavior in Wedding Planner, Caseverity, UsherApp QR check-in and Mitra. The audit records transitions and timestamps, **not live reproduction of the underlying bugs**.
12
+
13
+ 1. Why was a task described as completed? Some positive signal such as build, a passing testcase, or a screenshot was available.
14
+ 2. Why did that signal fail to cover reported behavior? Specific negative, dynamic-data, viewport and repeat-flow conditions weren't shown to have been executed.
15
+ 3. Why weren't all conditions visible? Free-form acceptance descriptions do not identify exact observable transitions and required evidence types.
16
+ 4. Why was reporting too broad? Named machine reports were mixed with unsupported release/functional claims in narrative summaries.
17
+ 5. Why wasn't there a reliable boundary? Completion lacked a consistently inspectable, scenario-scoped evidence matrix.
18
+
19
+ **Root-cause candidate:** missing explicit contract separating implementation, machine assertions, visual/hardware observations and independent acceptance; *not* proof of a single prompt/model bug.
20
+
21
+ **Fix:** `pilah_verify(operation="plan")` accepts optional structured criteria with `given/when/then`, `evidence_type`, source revision and UI state/viewport/reference. Planning is `not_tested` by default. Assessment returns criterion states and a separate `completion` object with `fully_verified:false` unless authenticated acceptance uses the distinct release path. Named local reports remain **local test assertions only**. For typed browser, visual, security, hardware and independent claims, ordinary local unit/build JSON cannot grant a PASS. Evidence cannot be retroactively promoted by task narrative.
22
+
23
+ **Regression scenario:** a build-only `passed` testcase offered as proof of a functioning duplicate-check-in printer, Figma hover, dynamic data or offline restart must remain **inconclusive/not_tested** for that higher-level behavior. A genuine named local integration test may pass its own narrow assertion, but never the overall independent completion gate.
24
+
25
+ ## BA-02 — Design parity remains unproved after visual inspection (P1)
26
+
27
+ **Evidence:** 719 Figma MCP calls, 5,536 DevTools calls and repeated UI mismatch reports; these counts do not identify exactly which states or viewports were executed.
28
+
29
+ 1. Why does the user still see mismatched layout/behavior? An unobserved UI state or viewport may be wrong.
30
+ 2. Why unobserved? A screenshot or page-load smoke test covers only one moment.
31
+ 3. Why not caught? State, reference, dimensions, interactions and dynamic content aren't bound to specific checks.
32
+ 4. Why? Generic test cases do not encode UI observations as structured acceptance.
33
+ 5. Why? The workflow's default notion of verification is tool activity, not complete behavioral evidence.
34
+
35
+ **Fix:** Every typed `visual` or `browser` criterion must declare viewport, UI state and design/behavior reference. It cannot be verified by an unrelated build result. Actual screenshots/interactions remain native Antigravity work, with independent evidence gate unchanged.
36
+
37
+ **Regression scenario:** a successful Vite build offered as proof that a hover button matches a Figma node at 375×812 must return `inconclusive`, not visual parity.
38
+
39
+ ## BA-03 and BA-06 — Native tool churn and low effective PILAH adoption (P1)
40
+
41
+ **Evidence:** 412 indicative invalid argument errors, 150 missing paths, 136 edit mismatches, 64 timeouts, 14 stale browser contexts; 13 directly observed PILAH/VerifyKit calls across four sessions. Several events came from earlier plugin versions, not the current candidate.
42
+
43
+ 1. Why repeated failures? Arguments, paths or browser state sometimes become invalid.
44
+ 2. Why might the next call fail similarly? Agent may retry before refreshing the contract or state.
45
+ 3. Why isn't recovery deterministic? Timeouts, permission rejection, schema validation and edit conflicts demand different next actions.
46
+ 4. Why isn't failure easy to classify? Native tools expose varied messages while PILAH does not intercept their calls.
47
+ 5. Why is tool use inefficient? No concise, optional shared triage response for these failure classes.
48
+
49
+ **Fix:** `pilah_evidence(operation="tool_recovery")` gives bounded and privacy-safe guidance; it **never** runs, retries, modifies or proxies a native tool. Raw error hints aren't persisted or copied into responses. After repeated attempts it explicitly warns against identical retry loops. The tiny always-present rule and optional Always-On guidance remind the agent to check current state and proof scope.
50
+
51
+ **Regression scenario:** a `-32602` invalid `pageId` error yields schema/state inspection; lost browser execution context yields a fresh page/selector check; `403` yields **stop and request permission**, never bypass. Credential-bearing error text is never echoed.
52
+
53
+ ## BA-04 — Long-session rereads and ambiguous 'continue' (P1)
54
+
55
+ **Evidence:** 13,379 `read_file` calls, 9,562 repeats of the same (session,path); 111 minimal user follow-ups. Repeated paths can be **correct** after edits. These are *not* counts of objectively wasted tokens.
56
+
57
+ 1. Why repeated inspection? The same files are revisited after long tasks and edits.
58
+ 2. Why not skip unchanged work? The agent lacks a short, authenticated map of which decisions and tests remain valid.
59
+ 3. Why unavailable? Human commitments, source revisions and machine evidence are separate.
60
+ 4. Why ambiguous on continue? Without a persisted status, 'completed' might mean changed but not tested.
61
+ 5. Why costly? Recovery from entire conversations instead of concise source-fresh checkpoints increases uncertainty.
62
+
63
+ **Fix:** extend the existing, opt-in `save_checkpoint` with bounded `decisions` and `pending_tests`; on `model_recovery` return `source_freshness` and `verified:false` with the latest full-inventory source revision. Existing stored checkpoints migrate additively; no new memory backend, automatic transcript ingest or third-party component.
64
+
65
+ **Regression scenario:** record three pending QR states, edit source, call recovery: decisions remain readable but checkpoint is **stale**, and completed notes cannot be accepted as machine evidence.
66
+
67
+ ## BA-07 — Teamwork is not necessarily beneficial (P2)
68
+
69
+ **Evidence:** About 1,389 observed native teamwork/subagent calls over 82 sessions, but no such calls in the paired STOCKROOM benchmark. Two sessions do not establish the optimum number of workers.
70
+
71
+ 1. Why did some large tasks stay single-agent? Size alone doesn't guarantee delegation should happen.
72
+ 2. Why might splitting be harmful? Workers may touch overlapping files and share dependencies.
73
+ 3. Why not caught earlier? Ownership isn't always explicit.
74
+ 4. Why was a mode suggested? Previous advisor prioritized high-level horizon/workstream counts.
75
+ 5. Why a productivity risk? Parallel plans can add coordination and verification overhead.
76
+
77
+ **Fix:** advisor recommends parallel native modes only when **file ownership is explicitly independent** and dependencies low, with a user approval requirement; otherwise use one agent. Hard tightly-coupled reasoning may still receive non-parallel assistance if supported.
78
+
79
+ **Regression scenario:** overlapping owners or high dependency => `single-agent`; independent owners and confirmed native command => opt-in recommendation only. No swarm is ever launched by PILAH.
80
+
81
+ ## BA-08 — Raw transcripts contain confidential information (P0)
82
+
83
+ **Evidence:** The private audit observed at least one login credential in plaintext. No secrets are included in this document. This is not evidence of PILAH outbound data exfiltration.
84
+
85
+ 1. Why sensitive content exists? Users sometimes paste authentication details into prompts.
86
+ 2. Why could audit output expose it? Raw events or error strings may be copied to public fixtures.
87
+ 3. Why dangerous? Untrusted model-visible logs can contain credentials, paths and cookies.
88
+ 4. Why not enough to 'sanitize later'? A public GitHub push is irreversible in common operational workflows.
89
+ 5. Why protect ingestion by default? Privacy and debug convenience have different trust requirements.
90
+
91
+ **Fix:** sanitized **synthetic** test fixtures only; no original raw archive in Git; recovery messages never echo native raw errors; explicit checkpoint rejects common plaintext secret assignments. All E2E tests use disposable generated workspaces. Keep raw original private, and rotate exposed active credentials.
92
+
93
+ **Regression scenario:** `password=...` note rejected, an error containing a token never appears in PILAH guidance or GitHub test output.
94
+
95
+ ## Scope of executed verification
96
+
97
+ - `tests/behavioral_acceptance.test.mjs`: typed criteria, false-completion negative controls, source revision mismatch, checkpoint privacy/freshness, failure triage and teamwork preconditions.
98
+ - `tests/behavioral_mcp_e2e.test.mjs`: **real local Node MCP stdio process + SQLite**, with permission denial, four-tool listing, typed planning and assessment, recovery, changed-source invalidation and JSON-RPC schema rejection.
99
+ - Other existing Node unit/security/MCP tests and cross-platform CI remain mandatory.
100
+
101
+ **Important limitations:** local Node/MCP E2E is *not* a real Antigravity installation, Figma screenshot comparison, printer/QR hardware test, Laravel backend, independent STOCKROOM F01–F18 browser/DB acceptance or repeated model benchmark. The live evidence for those remains **open in #15**. PILAH cannot force the upstream native agent to follow its advice, guarantee all bugs disappear, or assert token savings from repeated-read counts.
102
+
103
+ ## Re-audit: five subsequent failure modes (19 November 2026)
104
+
105
+ The subsequent source review opened #38–#42. These are **code-confirmed gaps with isolated function reproductions**, not proof of errors in a live installed IDE:
106
+
107
+ 1. **#38 / P0 — Handoff could certify the wrong evidence kind.** Why? Positive named test plus local hook record → handoff omitted evidence-type restrictions → two verification paths diverged → regression only tested ordinary `assess` → no shared local evidence policy. **Remediation:** central `localEvidencePolicy` and positive-provenance restricted-type negative controls.
108
+ 2. **#39 / P0 — Failed native command could look successful.** Why? PostToolUse lacked a top-level error → command exit code ignored → completion conflated with success → existing report hashes could be reattached → no fail-closed exit contract. **Remediation:** explicit numeric zero exit code required; nonzero/missing/conflicting exit clears positive provenance.
109
+ 3. **#40 / P1 — Authorization denial could be hidden by a page ID.** Why? Broad `pageid` matched → first regex branch won → caller-specified deny lost → permission guidance suppressed → no severity-aware classification. **Remediation:** denial-first detection, user authorization required.
110
+ 4. **#41 / P1 — Planned acceptance cases could disappear.** Why? `plan` was transient → `assess` rebuilt scope from its own input → missing cases absent from total → no plan ID → no source-bound immutable manifest. **Remediation:** optional persisted `plan_id`, complete-scope assessment with omissions and stale/tamper detection; explicit user-triggered reissue on the new revision *without reducing the frozen criterion set*; opt-in local retention.
111
+ 5. **#42 / P2 — Full brain Markdown could be stored without explicit consent.** Why? edit-event hook called snapshot → artifact versioner stored full content → retention was optimized for history → user settings did not distinguish metadata from content → docs were unclear. **Remediation:** automatic content snapshots off by default, opt-in CLI and transparent persistent-data disclosure.
112
+
113
+ This hardening is tested with synthetic fixtures and local MCP JSON-RPC/SQLite E2E; full Antigravity/browser/QR-printer and external STOCKROOM evaluation remains in issue #15. Do not import private transcript archives into public fixtures.
114
+
115
+ ## Release and merge policy
116
+
117
+ This behavioral work **merged only into `v2.0.1`** via PR #36, commit `67ea5888caf61751952c8a7daa1eb222d738d4b6`, and all six code-level issues #30–#35 were closed as **implemented**. Post-merge GitHub CI passed 4/4 OS/runtime jobs with 213/213 tests on Ubuntu Node 22. External #15 remains open. Do not merge to `main`, create a tag, publish an npm package or declare production-readiness without independent acceptance and explicit approval.