Skip to content

Commit 3cad5fc

Browse files
Measurable precision-first bug hunting protocol
* loop: setup task definition * loop: seal completion gate * loop: add progress ledger * loop: add iteration journal * loop: add one-shot precision patch payload * loop: add persistent precision gate * loop: setup - precision-first bug hunting * loop: iteration 2 - record schema strict-mode failure * loop: retry precision patch payload 1 * loop: retry precision patch payload 2 * loop: retry precision patch 2 * loop: iteration 3 - record patch transport failure * loop: add patch transport part 00 * loop: add patch transport part 01 * loop: add patch transport part 02 * loop: add patch transport part 03 * loop: add patch transport part 04 * loop: add patch transport part 05 * loop: retry chunked precision patch 1 * loop: iteration 4 - record regression gate failures * loop: update patch transport part 00 * loop: update patch transport part 01 * loop: update patch transport part 02 * loop: add exact patch segment 020 * loop: add exact patch segment 021 * loop: add exact patch segment 022 * loop: update patch transport part 03 * loop: add exact remaining patch segments * loop: retry precision regressions 1 * loop: iteration 5 - record final test syntax failure * loop: add final exact patch transport * loop: retry final precision test 1 * loop: iteration 6 - precision-first bug hunting * loop: iteration 8 - record green draft PR * loop: iteration 9 - correct final verification count * loop: iteration 10 - begin deep adversarial cross-check * loop: iteration 10 - record deep adversarial audit start * loop: iteration 11 - add failing deep precision regressions * loop: iteration 11 - record nine reproduced deep defects * loop: iteration 12 - centralize source detection and token chunks * loop: iteration 12 - complete shared source semantics * loop: prepare deep precision patch runner * loop: apply deep precision hardening * loop: apply deep precision hardening * loop: apply deep precision hardening * loop: iteration 12 - deep precision hardening * loop: iteration 13 - trigger final PR head verification * loop: iteration 14 - record final green PR checks * loop: iteration 15 - reopen resume integrity audit * loop: iteration 15 - record post-hardening resume audit * loop: iteration 16 - add resume and coverage regressions * loop: iteration 16 - fix coverage regression harness * loop: iteration 16 - record resume integrity failures * loop: prepare resume integrity patch runner * loop: apply resume integrity hardening * loop: iteration 17 - resume integrity hardening * loop: iteration 18 - trigger final 193-test PR verification * loop: iteration 19 - close final green ledger * loop: setup — measurable world-class protocol * loop: iteration 1 - preserve completed precision loop * tooling: export source snapshot * tooling: source snapshot * tooling: export split source snapshot * tooling: split source snapshot * tooling: export wrapped source snapshot * tooling: export wrapped source snapshot v2 * tooling: wrapped source snapshot * tooling: upload source artifact * tooling: upload dependencies * loop: apply measurable world-class protocol * tooling: upload implementation snapshot * loop: apply measurable world-class protocol * tooling: upload implementation snapshot * loop: apply measurable world-class protocol * loop: iteration 3 - record green implementation gate * loop: apply measurable world-class protocol * loop: apply measurable world-class protocol * loop: iteration 4 - measurable world-class protocol * ci: enforce benchmark quality gate * tooling: remove temporary implementation workflow * loop: iteration 5 - mark implementation integrated * loop: iteration 5 - begin final PR-head verification * loop: iteration 6 - close final verification item * loop: iteration 6 - close measurable world-class loop * loop: iteration 7 - clean temporary transport and reverify * loop: iteration 8 - close cleaned world-class loop --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent fa0cc06 commit 3cad5fc

55 files changed

Lines changed: 6350 additions & 341 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ jobs:
3333
- name: Run tests
3434
run: pnpm test
3535

36+
- name: Run benchmark quality gate
37+
if: matrix.node-version == 24
38+
run: pnpm benchmark:gate
39+
3640
- name: Run preflight check
3741
run: node scripts/run-bug-hunter.cjs preflight --skill-dir .
3842

‎.github/workflows/loop-check.yml‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Precision protocol gate
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
check:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v7
16+
17+
- uses: pnpm/action-setup@v6
18+
with:
19+
version: 10.28.1
20+
21+
- uses: actions/setup-node@v7
22+
with:
23+
node-version: 24
24+
cache: pnpm
25+
26+
- name: Install dependencies
27+
run: pnpm install --frozen-lockfile
28+
29+
- name: Verify sealed check hash
30+
run: |
31+
actual="$(sha256sum .loop/check.sh | awk '{print $1}')"
32+
expected="$(sed -n 's/^SHA-256: `\([a-f0-9]*\)`$/\1/p' .loop/task.md)"
33+
test -n "$expected"
34+
test "$actual" = "$expected"
35+
36+
- name: Run sealed gate
37+
run: bash .loop/check.sh
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
required_files=(
5+
scripts/source-config.cjs
6+
scripts/tests/precision-protocol.test.cjs
7+
docs/precision-protocol.md
8+
)
9+
10+
for file in "${required_files[@]}"; do
11+
if [[ ! -f "$file" ]]; then
12+
echo "ASSERTION FAILED: required precision-protocol file is missing: $file" >&2
13+
exit 1
14+
fi
15+
done
16+
17+
pnpm check:generated
18+
pnpm test
19+
node scripts/run-bug-hunter.cjs preflight --skill-dir .
20+
pnpm verify:package
21+
22+
echo "LOOP CHECK PASSED: precision protocol, generated assets, tests, preflight, and package inventory are valid."
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Journal
2+
3+
## Iteration 0 — repository audit — complete
4+
5+
Reviewed the orchestration scripts, schemas, role skills, tests, CI, and package inventory. Confirmed four correctness defects and two efficiency/protocol gaps:
6+
7+
- `bug-hunter-state.cjs` alphabetically sorts caller-provided files, discarding triage risk order.
8+
- `code-index.cjs` supports fewer source extensions than `triage.cjs`, weakening delta scope for supported languages.
9+
- `chunk-scheduler.cjs` ignores missing files and can mark a chunk done without scanning its assigned scope.
10+
- `findings.schema.json` does not enforce non-empty cross-references or security STRIDE/CWE evidence.
11+
- `run-bug-hunter.cjs` uses a fixed default chunk count rather than a source-token budget.
12+
- Skeptic hard-excludes every rate-limit finding while Hunter explicitly searches for exploitable auth-rate-limit failures.
13+
14+
## Iteration 1 — loop setup — expected failing gate
15+
16+
Created the sealed completion check. On the setup tree it must fail with the assertion that `scripts/source-config.cjs` is missing. The one-shot patch workflow verifies this expected failure before applying changes.
17+
18+
## Iteration 2 — schema generation — failed
19+
20+
The setup assertion failed exactly as expected and the complete patch payload applied cleanly. Ajv then rejected the generated findings schema in strict mode because the conditional CWE `pattern` did not repeat its string `type`. The payload was corrected to use `{ "type": "string", "pattern": "^CWE-[0-9]+$" }`; the sealed check remains unchanged.
21+
22+
## Iteration 3 — patch transport — failed
23+
24+
The corrected payload was uploaded as one long compressed Base64 line, but GitHub Actions detected a gzip CRC/length mismatch before executing it. No repository source changes were applied. The transport is being replaced with ordered 1.8 KB parts that are locally concatenated, decoded, decompressed, and byte-compared before publication.
25+
26+
## Iteration 4 — regression gate — failed
27+
28+
The chunked patch transport and SHA check passed, the patch applied, and generated assets were current. The actual sealed check failed with four regressions: a newline-escaping SyntaxError in the new test, two existing security fixtures missing newly required STRIDE/CWE fields, and one resume fixture emitting an empty cross-reference list. The workflow also lacked `pipefail`, so its step metadata incorrectly reported success. The next retry fixes all four fixtures and makes pipeline failure propagation explicit.
29+
30+
## Iteration 5 — precision protocol test — failed
31+
32+
The exact reconstructed patcher passed its SHA-256 and syntax checks. All production changes and all 175 pre-existing tests passed. The sole remaining failure was a malformed regular expression in the new protocol regression test: the slash in `OTP/reset` was not preserved through the patcher's template literal. The patcher now emits an escaped slash, and the sealed gate remains unchanged.
33+
34+
## Iteration 5 — precision protocol implementation — pending verification
35+
36+
Applied the centralized source catalog, order preservation, adaptive source-token chunks, fail-closed missing-scope handling, security evidence schema, progressive example loading, qualified rate-limit analysis, documentation, and regression tests. Generated artifacts and the sealed gate run next.
37+
38+
## Iteration 7 — sealed completion gate — passed
39+
40+
The sealed `.loop/check.sh` exited 0: generated assets were current, all 181 tests passed, preflight passed, and package inventory passed.
41+
42+
## Iteration 8 — draft PR validation — passed
43+
44+
Opened draft PR #2. The PR-triggered sealed precision gate passed, Node 22 CI passed, and Node 24 CI passed including package inventory verification.
45+
46+
## Iteration 9 — verification count correction — complete
47+
48+
Corrected the stale test-count note from 176 to the final executed total of 181. No production or test code changed.
49+
50+
## Iteration 10 — deep adversarial cross-check — in progress
51+
52+
Reopened the completed implementation for an end-to-end audit rather than relying on the green test suite. The new pass traces discovery, delta selection, chunk construction, hash evidence, retries/resume, Referee authorization, and Fixer scope. Candidate defects will be reproduced with focused regression tests before any production patch is accepted.
53+
54+
## Iteration 11 — nine deep defects reproduced — failed as expected
55+
56+
Added nine adversarial regression probes. The sealed check preserved all 181 prior passes and failed the nine new tests, confirming: code-index/delta order loss; mixed-size chunks exceeding the declared source-token budget; shebang/test/minified discovery drift; findings accepted outside assigned scope; worker-time source mutation reported as complete; weaker duplicate evidence overwriting stronger security evidence while STRIDE/CWE are dropped; non-cryptographic large-file cache keys; Fixer scope authorizing manual-review items; and symlink paths escaping the repository scope. Production patches must make these tests pass without editing the sealed check.
57+
58+
## Iteration 12 — deep precision hardening — passed
59+
60+
The nine adversarial regressions now pass. The sealed check exited 0 with all
61+
190 tests passing, generated assets current, preflight successful, and package
62+
inventory valid. Scope is realpath-contained, findings are chunk-bound, worker
63+
source mutation fails closed, token budgets are enforced per concrete chunk,
64+
evidence merges preserve security metadata, large files use SHA-256, and Fixer
65+
authorization excludes manual-review and report-only findings.
66+
67+
## Iteration 13 — final PR-head verification — in progress
68+
69+
The verified hardening commit was created by GitHub Actions, whose workflow token cannot recursively trigger pull-request workflows. This ledger-only commit intentionally triggers the Node 22/24 CI matrix and the sealed precision gate on the exact hardened tree.
70+
71+
## Iteration 14 — final PR-head verification — passed
72+
73+
On head `8088a10928bea6e2257bff8f33fb51788eb89608`, the PR-triggered sealed precision gate passed, Node 22 CI passed, and Node 24 CI passed including package inventory, executable-bit, version, and help checks. This append-only entry records the verified result and triggers one final unchanged-code check on the completed loop ledger.
74+
75+
## Iteration 15 — post-hardening resume audit — in progress
76+
77+
A final static review found that a source mutation correctly fails the current chunk but can become the new baseline after `--resume` because the original pre-worker hash is overwritten or discarded on failure. The same review found that chunk status can still label a pending file as done in coverage, and the root-containment predicate rejects valid in-repository names beginning with `..`. Focused regressions will be added before patching these three edge cases.
78+
79+
## Iteration 16 — post-hardening regressions — failed as expected
80+
81+
The new tests preserved all 190 prior passes and failed exactly three assertions: a clean worker executed successfully after resuming source drift; a done chunk with a pending file produced `COMPLETE`; and `normalizeRunFiles` rejected an in-repository `..valid-source.js`. The test harness itself was corrected and rerun before accepting the coverage failure. Production changes now target only these confirmed behaviors.
82+
83+
## Iteration 17 — resume integrity hardening — passed
84+
85+
The three post-hardening regressions pass and the sealed check exited 0 with
86+
all 193 tests passing. Per-run source baselines now survive failed attempts,
87+
resumed drift is rejected before worker dispatch, coverage completion requires
88+
per-file done evidence, and valid in-repository names beginning with `..` no
89+
longer collide with the parent-directory escape check.
90+
91+
## Iteration 18 — final 193-test PR-head verification — in progress
92+
93+
The verified resume-hardening commit `0a293c4361ab46da24daaacd68bdda0432afedec` was created by GitHub Actions, so this append-only human-authored ledger commit triggers the pull-request Node 22/24 matrix and sealed precision gate on the exact 193-test hardened tree.
94+
95+
## Iteration 19 — final 193-test PR-head verification — passed
96+
97+
On head `4a767fecbea7bb2d43e477e08f5e4d774bd16231`, the PR-triggered sealed precision gate passed, Node 22 CI passed, and Node 24 CI passed including generated-asset checks, preflight, package inventory, executable-bit, version, and help verification. Every ledger item is complete; this atomic ledger-close commit changes no production or test code.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Progress
2+
3+
- [x] Centralize supported source extensions and align triage with code-index.
4+
- [x] Preserve risk-prioritized file order through state initialization and expansion.
5+
- [x] Add adaptive source-token chunk sizing with an explicit override.
6+
- [x] Fail closed when assigned files disappear and keep coverage truthful.
7+
- [x] Tighten findings schema for non-empty cross-references and security evidence.
8+
- [x] Remove the Hunter/Skeptic rate-limit contradiction and make examples conditional.
9+
- [x] Add precision-protocol documentation and regression tests.
10+
- [x] Regenerate validators and pass the sealed loop check.
11+
- [x] Open a draft PR and confirm GitHub Actions passes.
12+
- [x] Audit scope integrity from discovery through Referee and Fixer authorization.
13+
- [x] Preserve risk order through delta selection and low-confidence expansion.
14+
- [x] Enforce the source-token budget on every actual chunk, including mixed-size inputs.
15+
- [x] Align extensionless shebang discovery with indexing and dependency expansion.
16+
- [x] Audit state, hash-cache, retry, resume, and failure semantics for stale or false coverage.
17+
- [x] Add adversarial regression tests for every confirmed deep-audit defect.
18+
- [x] Re-run the sealed gate and confirm all PR-triggered CI checks pass.
19+
- [x] Preserve the original pre-worker source hash across failed retries and resume.
20+
- [x] Reject resumed chunks when assigned source content drifted after a failed worker.
21+
- [x] Ensure chunk status alone can never report a pending file as completed coverage.
22+
- [x] Accept valid in-repository paths whose basename starts with two dots while still rejecting escapes.
23+
- [x] Add regression tests for the post-hardening resume and coverage edge cases.
24+
- [x] Re-run the sealed gate and final PR-triggered CI checks.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Task: precision-first Bug Hunter optimization
2+
3+
Improve Bug Hunter so it catches real behavioral and security bugs with less wasted context, faster deterministic scoping, and stricter evidence validation.
4+
5+
## Done criterion
6+
7+
The task is done only when the sealed `.loop/check.sh` exits 0 after all of the following are true:
8+
9+
1. Source-language discovery is centralized so triage and code-index cannot silently drift.
10+
2. Risk-prioritized input order survives state initialization and delta expansion.
11+
3. Worker chunk sizing adapts to a bounded source-token budget unless the caller explicitly overrides it.
12+
4. Missing files fail the scan closed instead of being reported as completed coverage.
13+
5. Security findings require concrete STRIDE/CWE evidence and non-empty cross-references.
14+
6. Skeptic guidance no longer auto-dismisses exploitable authentication or abuse-rate-limit failures.
15+
7. Calibration examples load only when useful instead of on every chunk.
16+
8. Regression tests, generated validators, preflight, and package inventory all pass.
17+
18+
## Sealed check
19+
20+
SHA-256: `6076d770c0ef7af821af66ac0a9559225fd4bea4bec9442cbf6352cd11091f0a`
21+
22+
This file and `.loop/check.sh` are immutable after setup.

‎.loop/check.sh‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
required_files=(
5+
scripts/benchmark-suite.cjs
6+
scripts/adaptive-policy.cjs
7+
scripts/hybrid-verifier.cjs
8+
scripts/evidence-cache.cjs
9+
scripts/retrieval-planner.cjs
10+
scripts/tests/world-class-protocol.test.cjs
11+
docs/world-class-protocol.md
12+
schemas/benchmark-report.schema.json
13+
schemas/adaptive-plan.schema.json
14+
schemas/verification-report.schema.json
15+
schemas/retrieval-plan.schema.json
16+
evals/benchmark/public-manifest.json
17+
evals/benchmark/private-labels.json
18+
evals/benchmark/golden-runs.json
19+
evals/benchmark/triage-sample.json
20+
evals/benchmark/verification-plan.json
21+
evals/benchmark/index-sample.json
22+
evals/benchmark/hypotheses-sample.json
23+
)
24+
25+
for file in "${required_files[@]}"; do
26+
if [[ ! -f "$file" ]]; then
27+
echo "ASSERTION FAILED: required world-class protocol file is missing: $file" >&2
28+
exit 1
29+
fi
30+
done
31+
32+
pnpm check:generated
33+
pnpm test
34+
35+
rm -rf .bug-hunter/world-class-check
36+
mkdir -p .bug-hunter/world-class-check
37+
38+
node scripts/benchmark-suite.cjs validate-public \
39+
--manifest evals/benchmark/public-manifest.json
40+
node scripts/benchmark-suite.cjs score \
41+
--manifest evals/benchmark/public-manifest.json \
42+
--labels evals/benchmark/private-labels.json \
43+
--runs evals/benchmark/golden-runs.json \
44+
--output .bug-hunter/world-class-check/benchmark-report.json
45+
node scripts/schema-validate.cjs benchmark-report \
46+
.bug-hunter/world-class-check/benchmark-report.json
47+
48+
node scripts/adaptive-policy.cjs plan \
49+
--triage evals/benchmark/triage-sample.json \
50+
--benchmark .bug-hunter/world-class-check/benchmark-report.json \
51+
--profile auto \
52+
--security true \
53+
--output .bug-hunter/world-class-check/adaptive-plan.json
54+
node scripts/schema-validate.cjs adaptive-plan \
55+
.bug-hunter/world-class-check/adaptive-plan.json
56+
57+
node scripts/hybrid-verifier.cjs run \
58+
--repo-root . \
59+
--plan evals/benchmark/verification-plan.json \
60+
--output .bug-hunter/world-class-check/verification-report.json
61+
node scripts/schema-validate.cjs verification-report \
62+
.bug-hunter/world-class-check/verification-report.json
63+
64+
node scripts/retrieval-planner.cjs plan \
65+
--index evals/benchmark/index-sample.json \
66+
--hypotheses evals/benchmark/hypotheses-sample.json \
67+
--max-tokens 12000 \
68+
--max-files 5 \
69+
--output .bug-hunter/world-class-check/retrieval-plan.json
70+
node scripts/schema-validate.cjs retrieval-plan \
71+
.bug-hunter/world-class-check/retrieval-plan.json
72+
73+
node scripts/run-bug-hunter.cjs preflight --skill-dir .
74+
pnpm verify:package
75+
76+
echo "LOOP CHECK PASSED: benchmark quality, adaptive policy, hybrid verification, content-addressed evidence reuse, retrieval planning, schemas, tests, preflight, and package inventory are valid."

0 commit comments

Comments
 (0)