burnoff 0.0.0-stage → 1.1.0

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.
@@ -0,0 +1,75 @@
1
+ name: Burnoff PR Cost & CI Budget Gate
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, synchronize, reopened]
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ pr-cost-gate:
12
+ runs-on: ubuntu-latest
13
+ outputs:
14
+ summary_path: ${{ steps.gate.outputs.summary_path }}
15
+ steps:
16
+ - name: Checkout repository
17
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
18
+ with:
19
+ fetch-depth: 0
20
+
21
+ - name: Setup Node.js
22
+ uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
23
+ with:
24
+ node-version: '22'
25
+
26
+ - name: Compute PR Cost Attribution
27
+ run: |
28
+ mkdir -p .burnoff-ci
29
+ USAGE_FLAG=""
30
+ if [ -s .burnoff-ci/provider-usage.json ]; then
31
+ USAGE_FLAG="--provider-usage .burnoff-ci/provider-usage.json"
32
+ fi
33
+ npx -y burnoff@1.1.0 pr-cost --base "origin/${{ github.base_ref }}" $USAGE_FLAG --json --out .burnoff-ci/pr-cost.json
34
+ npx -y burnoff@1.1.0 pr-cost --base "origin/${{ github.base_ref }}" $USAGE_FLAG --markdown --out .burnoff-ci/pr-cost.md
35
+
36
+ - name: Enforce CI Token-Budget Gate
37
+ id: gate
38
+ run: |
39
+ npx -y burnoff@1.1.0 ci-gate --input .burnoff-ci/pr-cost.json --strict --github-annotations --out .burnoff-ci/ci-gate.md
40
+ cat .burnoff-ci/pr-cost.md >> "$GITHUB_STEP_SUMMARY"
41
+ cat .burnoff-ci/ci-gate.md >> "$GITHUB_STEP_SUMMARY"
42
+ echo "summary_path=.burnoff-ci/pr-cost.md" >> "$GITHUB_OUTPUT"
43
+
44
+ - name: Upload PR attribution artifact
45
+ if: always()
46
+ uses: actions/upload-artifact@ea165f8d65b6e75b5fd2b08d0cbd28a89f188154
47
+ with:
48
+ name: burnoff-pr-cost
49
+ path: .burnoff-ci/
50
+ if-no-files-found: ignore
51
+
52
+ pr-comment:
53
+ needs: pr-cost-gate
54
+ if: always() && github.event.pull_request.head.repo.fork == false
55
+ runs-on: ubuntu-latest
56
+ permissions:
57
+ contents: read
58
+ pull-requests: write
59
+ steps:
60
+ - name: Download PR attribution artifact
61
+ uses: actions/download-artifact@d3f86a106a0bac45b975a62879b590290c2497ec
62
+ with:
63
+ name: burnoff-pr-cost
64
+ path: .burnoff-ci
65
+
66
+ - name: Post PR Cost Summary Comment
67
+ env:
68
+ GH_TOKEN: ${{ github.token }}
69
+ PR_NUMBER: ${{ github.event.pull_request.number }}
70
+ REPO: ${{ github.repository }}
71
+ run: |
72
+ if [ -s .burnoff-ci/pr-cost.md ]; then
73
+ { cat .burnoff-ci/pr-cost.md; echo ""; [ -s .burnoff-ci/ci-gate.md ] && cat .burnoff-ci/ci-gate.md; } > .burnoff-ci/comment.md
74
+ gh pr comment "$PR_NUMBER" --repo "$REPO" --body-file .burnoff-ci/comment.md
75
+ fi
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Burnoff 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,180 @@
1
- # Temporary Holding Version
1
+ # Burnoff
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
+ **Burnoff CI — Infracost-style AI spend gates, Turn-0 config linting, deterministic circuit breakers, and bounded file-read guards for Claude Code teams.**
4
+
5
+ Burnoff gives engineering teams deterministic local guardrails and enforceable pull-request cost governance for Claude Code — stopping runaway failure loops, blocking destructive shell commands and credential leaks, bounding oversized file reads, linting Turn-0 startup bloat, and gating PR AI spend in GitHub Actions.
6
+
7
+ ## Why Burnoff?
8
+
9
+ - **Infracost-Style PR Spend Gates:** Correlates branch commits to Claude Code session spend, optionally reconciles against provider billing exports (`--provider-usage`), and enforces `.burnoff.yaml` budgets in GitHub Actions without touching shared `.claude/settings.json`.
10
+ - **Turn-0 Startup Config Linter:** Audits `.mcp.json`, Claude Code settings, rule files, and tool bloat before a session starts, flagging reclaimable per-turn prompt overhead and misconfigurations.
11
+ - **Deterministic Runaway Loop Breaker:** Halts repeating tool or command failure loops after 3 consecutive identical failures using cross-process state locking, exempting read-only recovery steps and resetting cleanly on success or `git stash`.
12
+ - **Destructive Shell & Credential Guards:** Blocks high-risk shell/git commands (`git push --force`, `--no-verify`, `rm -rf`) and sensitive credential/env reads (allowing `.env.example` templates), while routing reversible resets through interactive confirmation.
13
+ - **Bounded File-Read & CLI Output Guards:** Clamps oversized non-code reads (`250 lines / 16 KB`), skips overlapping re-reads, leaves active source files unclamped, and archives verbose test/build stdout into local SQLite FTS5 (`burnoff search`) while preserving critical failure lines.
14
+
15
+ ## Requirements & Scope
16
+
17
+ - **Supported Agent:** Designed specifically for **Claude Code** (`v1.1.0` supports Claude Code only).
18
+ - **Runtime:** **Node.js `>=20.19.0`** (`Node.js >=22.13.0` recommended for built-in `node:sqlite` FTS5 indexing; older supported Node.js versions automatically run in atomic JSONL fallback mode).
19
+ - **Dependencies:** **Zero runtime npm dependencies.**
20
+
21
+ ## Quickstart
22
+
23
+ Install Burnoff in your project (or globally), preview changes, wire Claude Code hooks, and run your Turn-0 health & startup audit:
24
+
25
+ ```bash
26
+ npm i -D burnoff
27
+ npx burnoff init --dry-run
28
+ npx burnoff init
29
+ npx burnoff audit --startup
30
+ npx burnoff doctor
31
+ ```
32
+
33
+ Remove hooks cleanly at any time:
34
+
35
+ ```bash
36
+ npx burnoff uninstall
37
+ ```
38
+
39
+ ## Verified `v1.1.0` Output Samples
40
+
41
+ ### 1. Turn-0 Startup Config Audit (`burnoff audit --startup`)
42
+
43
+ ```text
44
+ Burnoff Claude Code Turn-0 Startup Audit | Findings: 2 | Reclaimable: ~14,500 tok/turn (est.) (~$1.01/wk)
45
+ - MCP startup tax: 0 tok/turn (deferred loading active)
46
+ - [pass] Chrome default disabled (or actively used)
47
+ - [warn] Artifact built-in tool active (cli, 0 calls in 7d, ~8500 tok/turn est.)
48
+ Note: Setting enableArtifact: false in settings.json is a one-way global lock and cannot be re-enabled per session with --settings.
49
+ Fix (never use): Set "enableArtifact": false in ~/.claude/settings.json (permanent one-way global lock).
50
+ Fix (occasional): Leave "enableArtifact" unset and run terminal coding with: claude --disallowedTools Artifact
51
+ - [warn] Bundled skills/workflows enabled (~6000 tok/turn est.)
52
+ Fix: Set "disableBundledSkills": true and "disableWorkflows": true in ~/.claude/settings.json (or pass per-session: claude --settings '{"disableBundledSkills":true,"disableWorkflows":true}').
53
+ - Rules [pass]: 1 file(s), 1 discrete rules, ~13 est. tokens
54
+ ```
55
+
56
+ ### 2. Deterministic Secret & Destructive Guard Block (`PreToolUse` exit `2`)
57
+
58
+ ```text
59
+ $ echo '{"session_id":"smoke-1","tool_name":"Bash","tool_input":{"command":"cat .env;echo ok"}}' | npx burnoff-pretool
60
+ [Burnoff DET-02 Secret & Credential Boundary] Access to sensitive credential path ".env" is blocked. (.env.example / .env.sample are permitted.)
61
+ # exits with code 2 before execution
62
+ ```
63
+
64
+ ### 3. PR Cost Attribution & CI Budget Gate (`pr-cost` + `ci-gate --strict`)
65
+
66
+ ```markdown
67
+ ### Burnoff PR Token & Cost Attribution (`HEAD~1..HEAD`)
68
+
69
+ | Metric | Value |
70
+ | :--- | :--- |
71
+ | **Commits / Files Changed** | `1` commits · `1` files (`+1 / -0`) |
72
+ | **Total Attributed Tokens** | `0.0k` |
73
+ | **Cache Hit Rate** | `0%` |
74
+ | **Estimated PR AI Cost** | `$0.0000` (`$0.0000 / 100 LOC`) |
75
+ | **Preventable Waste Ratio** | `0%` (`0.0k` tok) |
76
+ | **Estimated Saved USD** | `$0.0172` |
77
+ | **Ring-0 Violations** | `1` |
78
+
79
+ ### Burnoff CI / PR Token-Budget Gate: **FAIL** (`mode: enforce`)
80
+
81
+ | Check | Actual | Limit | Status |
82
+ | :--- | :---: | :---: | :---: |
83
+ | `MAX_PR_COST_USD` | `$0.0000` | `<=$15.00` | **PASS** |
84
+ | `MAX_PR_TOKENS` | `0` | `<=1,500,000` | **PASS** |
85
+ | `MIN_CACHE_HIT_PCT` | `0%` | `>=50%` | **PASS** |
86
+ | `MAX_WASTE_RATIO_PCT` | `0%` | `<=35%` | **PASS** |
87
+ | `MAX_RING0_VIOLATIONS` | `1` | `<=0` | **FAIL** |
88
+
89
+ #### Notices
90
+
91
+ - **MISSING_TRANSCRIPTS**: No Claude Code session transcripts matched this PR window (0 tokens attributed). Upload .burnoff-ci/provider-usage.json or session transcripts, or set failOnMissingTranscripts: true to enforce.
92
+ ```
93
+
94
+ ## Local-Only Trust & Privacy
95
+
96
+ Burnoff runs 100% locally via Claude Code hook subprocesses and local CLI commands:
97
+
98
+ - **Zero outbound network calls & zero proxy/MITM:** Your prompts, source code, and credentials never leave your machine.
99
+ - **Exact paths touched:**
100
+ - `~/.burnoff/` (or `$BURNOFF_HOME`): savings ledger, loop-breaker state, read-interval snapshots, FTS5/fallback CLI log archive, and optional local warm daemon socket/pipe.
101
+ - `.claude/settings.local.json`: repo-local hook wiring only (never modifies shared `.claude/settings.json`).
102
+ - `.git/info/exclude`: ignores `.claude/settings.local.json` privately so `git status` stays spotless without touching `.gitignore`.
103
+
104
+ ## CLI Commands
105
+
106
+ | Command | Purpose |
107
+ | :--- | :--- |
108
+ | `burnoff init [--dry-run]` | Wire `PreToolUse` and `PostToolUse` hooks in `.claude/settings.local.json` and update `.git/info/exclude`. |
109
+ | `burnoff uninstall [--dry-run]` | Remove Burnoff hooks and `.git/info/exclude` block. |
110
+ | `burnoff doctor [--gc] [--json]` | Inspect Node/SQLite FTS5, `.burnoff.yaml`, hook wiring, warm daemon, ledger, and prune >14d caches with `--gc`. |
111
+ | `burnoff audit --startup [--json]` | Run the Turn-0 startup config linter across `.mcp.json`, Claude Code settings, and rule files. |
112
+ | `burnoff audit [--session <file>] [--json]` | Parse Claude Code JSONL transcripts (`~/.claude/projects/`) and report per-session cost, cache hit %, and >200k-cliff turns. |
113
+ | `burnoff pr-cost [--base main] [--provider-usage file.json]` | Correlate `git log <base>..HEAD` commits with session spend and output Markdown or `burnoff-pr-attribution/v1` JSON. |
114
+ | `burnoff ci-gate --input pr-cost.json [--strict] [--github-annotations]` | Enforce `.burnoff.yaml` `ciBudgetGate` thresholds (`MAX_PR_COST_USD`, `MAX_PR_TOKENS`, `MIN_CACHE_HIT_PCT`, `MAX_WASTE_RATIO_PCT`, `MAX_RING0_VIOLATIONS`). |
115
+ | `burnoff team-digest [--days 7]` | Output a 5-line weekly Engineering Manager summary of spend, cache efficiency, top cost driver, and guard savings. |
116
+ | `burnoff search <turnId> [keyword]` | Search archived FTS5 CLI output without re-running expensive test or build commands. |
117
+ | `burnoff daemon <start\|stop\|status>` | Manage the workspace-scoped warm IPC daemon (`~/.burnoff/run/` or Windows named pipe). |
118
+
119
+ ## Team Policy (`.burnoff.yaml`)
120
+
121
+ Create an optional `.burnoff.yaml` in your repository root to customize guardrails and CI spend gates:
122
+
123
+ ```yaml
124
+ guards:
125
+ mode: guard
126
+ det04Threshold: 3
127
+ strictTestIntegrity: false
128
+ scopeLockEnabled: true
129
+
130
+ readClamp:
131
+ enabled: true
132
+ maxLines: 250
133
+ maxBytes: 16384
134
+ neverClampCodeOffCliff: true
135
+
136
+ postTool:
137
+ fts5Enabled: true
138
+ minBytesToCompress: 6144
139
+ retentionDays: 30
140
+
141
+ ciBudgetGate:
142
+ maxPrCostUsd: 15
143
+ maxPrTokens: 1500000
144
+ minCacheHitPct: 50
145
+ maxWasteRatioPct: 35
146
+ maxRing0Violations: 0
147
+ mode: enforce
148
+ failOnMissingTranscripts: false
149
+ ```
150
+
151
+ ## GitHub Actions PR Gate
152
+
153
+ See [`.github/workflows/burnoff-pr-gate.yml`](.github/workflows/burnoff-pr-gate.yml) for a SHA-pinned, least-privilege (`permissions: contents: read`) workflow built for `burnoff@1.1.0`:
154
+
155
+ - Runs `npx -y burnoff@1.1.0 pr-cost` (automatically passing `--provider-usage .burnoff-ci/provider-usage.json` when present) to produce `.burnoff-ci/pr-cost.json` and `.burnoff-ci/pr-cost.md`.
156
+ - Runs `npx -y burnoff@1.1.0 ci-gate --input .burnoff-ci/pr-cost.json --strict --github-annotations`.
157
+ - Appends the Markdown breakdown to `$GITHUB_STEP_SUMMARY` and posts non-fork PR summary comments.
158
+
159
+ ## Burnoff Team Cloud (Waitlist)
160
+
161
+ Need organization-wide AI spend governance across repositories without syncing local developer transcripts into CI artifacts?
162
+
163
+ - **Pricing:** `$19 / active AI-committing dev / mo` (10-seat minimum = `$190/mo` floor).
164
+ - **Org-Wide Governance:** Centralized `.burnoff.yaml` policy enforcement and branch-protection status checks across all repositories.
165
+ - **Provider Billing Reconciliation:** Automated Anthropic Admin API, AWS Bedrock, and Google Vertex AI invoice reconciliation against PR attribution.
166
+ - **Executive Reporting:** Scheduled Slack weekly Engineering Manager digests (`team-digest`) and cache-efficiency alerts.
167
+
168
+ Open an issue titled `[Waitlist] Burnoff Team Cloud` in the repository to request early access.
169
+
170
+ ## Environment Variables
171
+
172
+ - `BURNOFF_HOME`: Override `~/.burnoff/` state directory.
173
+ - `BURNOFF_IPC_PATH`: Override daemon named pipe / Unix domain socket path.
174
+ - `BURNOFF_PRETOOL_FAIL_MODE`: Set to `closed` to fail-closed on internal hook faults (guard `exitCode: 2` blocks always fail-closed).
175
+ - `BURNOFF_POST_OUTPUT_MODE`: Override `PostToolUse` output mode (`auto`, `updatedToolOutput`, `additionalContext`).
176
+ - `BURNOFF_TIER1_ACTIVE`: Set to `1` to enable Tier-1 `Grep`/`Glob` fast-path pass-through.
177
+
178
+ ## License
179
+
180
+ MIT — see [LICENSE](LICENSE).