@albinocrabs/feynman 0.2.1 → 0.2.4

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,77 @@
1
+ # Incident Response: API Latency Spike and 502s
2
+
3
+ ## Question
4
+
5
+ > My API started returning intermittent 502s and latency jumped from 120ms to
6
+ > 4s. I have Redis, API pods, and DB replicas. How should we triage and restore
7
+ > service in the next 20 minutes?
8
+
9
+ ## Without feynman
10
+
11
+ The API has a latency issue. First verify if the issue is traffic-related or a
12
+ deployment regression, then inspect pods, then check cache hit rates, and then
13
+ inspect database query times. If the pods are overloaded, scale horizontally and
14
+ enable degraded mode. If Redis errors increase, fail over to DB reads with a strict
15
+ timeout. If replicas are behind replication lag, move read traffic back to primary
16
+ only and notify users of elevated error rates.
17
+
18
+ ## With feynman
19
+
20
+ Triage and restore sequence:
21
+
22
+ ```
23
+ [Alert: 502 + latency spike] --> [1) Confirm incident scope]
24
+ |
25
+ +--> [Critical path only]
26
+ | |
27
+ | +--> [Disable non-core features]
28
+ | |
29
+ | +--> [Enable queue fallback]
30
+ |
31
+ +--> [2) Isolate root layer]
32
+ |
33
+ [Cache regression?]
34
+ |
35
+ yes -->| |--> no
36
+ v v
37
+ [Scale API / limit RPS] [Deployment rollback?]
38
+ | |
39
+ pass fail
40
+ | |
41
+ v v
42
+ [Service partially stable]
43
+ | |
44
+ v v
45
+ [Resolve] [Rollback last deploy]
46
+ |
47
+ v
48
+ [Restore response rate]
49
+ ```
50
+
51
+ Live status summary:
52
+
53
+ ```
54
+ ┌─ Incident Runbook ────────────────────┐
55
+ step-1 in-progress
56
+ step-2 pending
57
+ step-3 pending
58
+ external-comm on-call-channel
59
+ └───────────────────────────────────────┘
60
+ ```
61
+
62
+ Priority gates:
63
+
64
+ ```
65
+ ▲ high
66
+ API error budget burn
67
+ Security-sensitive write path (stop writes if needed)
68
+ ▼ low
69
+ Nice-to-have dashboards
70
+ Cosmetic alert updates
71
+ ```
72
+
73
+ ## Why this works
74
+
75
+ This example combines sequential flow (triage stages), branch isolation, status
76
+ frames, and priority scale. It turns ad-hoc firefighting into an explicit,
77
+ readable execution plan before any action is taken.
@@ -0,0 +1,73 @@
1
+ # Release Readiness: Monthly Deployment to Production
2
+
3
+ ## Question
4
+
5
+ > We have a monthly release with API, web, and mobile changes. What gates and
6
+ > rollback triggers do we need before and after deploy?
7
+
8
+ ## Without feynman
9
+
10
+ Coordinate release notes, run migration checks, execute smoke tests on staging, and
11
+ run targeted regression tests. If deployment passes, monitor key metrics for one hour
12
+ and then announce success. Rollback should be triggered on increased errors or
13
+ critical latency regressions.
14
+
15
+ ## With feynman
16
+
17
+ ```
18
+ [Pre-release plan] --> [Staging deploy]
19
+ |
20
+ v
21
+ [Smoke + regression]
22
+ |
23
+ pass ----+---- fail
24
+ | |
25
+ v v
26
+ [Production] [Stop + fix]
27
+ |
28
+ v
29
+ [Observe 60 min]
30
+ |
31
+ pass ----+---- fail
32
+ | |
33
+ v v
34
+ [Done + announce]
35
+ [Rollback + incident]
36
+ ```
37
+
38
+ Readiness gates:
39
+
40
+ ```
41
+ criterion | gate type | owner | must be true
42
+ --------------------|-----------|----------------|----------------------
43
+ migration safety | schema | platform | dry-run + backward-compatible
44
+ auth/checkout smoke | functional| product qa | 100% critical paths
45
+ error budget | reliability| sre | error rate <= baseline + 0.2%
46
+ security regression | security | infosec | zero new critical findings
47
+ ```
48
+
49
+ Readiness status:
50
+
51
+ - staging-deploy: done
52
+ - smoke-tests: in progress
53
+ - security-gate: pending
54
+ - rollback-drill: ready
55
+ - comms-draft: in progress
56
+
57
+ Priority ladder:
58
+
59
+ ```
60
+ ▲ high
61
+ no data loss
62
+ idempotent migrations
63
+ auth + checkout paths
64
+ ▼ low
65
+ branding tweaks
66
+ help-center wording
67
+ ```
68
+
69
+ ## Why this works
70
+
71
+ The flow diagram shows what blocks progression to production and where rollback
72
+ branches back. The gate table gives objective pass criteria. The status frame and
73
+ priority scale separate urgent reliability conditions from polish work.
@@ -0,0 +1,72 @@
1
+ # Service Migration: Move Billing to a New Provider
2
+
3
+ ## Question
4
+
5
+ > We need to migrate billing from Provider A to Provider B. What is the safest rollout
6
+ > sequence with fallback and acceptance gates?
7
+
8
+ ## Without feynman
9
+
10
+ Start in read mode to keep both providers enabled, compare charge outcomes for a
11
+ sample of users, run a pilot for low-risk plans, then run a staged migration to
12
+ full traffic with manual approval and rollback checkpoints.
13
+
14
+ ## With feynman
15
+
16
+ Migration ladder:
17
+
18
+ ```
19
+ [Dual-run mode]
20
+ |
21
+ v
22
+ [Replay 30 days of traffic] --> [Compare divergence < 1%] --> [Pilot 5% users]
23
+ |
24
+ v
25
+ [Auto-scaling smoke] --> [Pilot 30% users] --> [100% rollout]
26
+ |
27
+ +--> [Error rate > threshold] --> [Disable 30% wave]
28
+ |
29
+ +--> [Critical incidents] --> [Fallback to A]
30
+ ```
31
+
32
+ Vendor comparison:
33
+
34
+ ```
35
+ Option A (keep) | Option B (move) | Hybrid (dual)
36
+ ------------------|----------------------|------------------
37
+ steady risk | new integration risk | controlled transition
38
+ low complexity | higher validation | higher ops cost
39
+ higher cost risk | lower long-term cost | medium monitoring
40
+ fast execution | phased execution | slower initial step
41
+ ```
42
+
43
+ Go/no-go gates:
44
+
45
+ - divergence_rate <= 1%
46
+ - failed callbacks < 0.2%
47
+ - latency_p95 <= baseline + 20ms
48
+ - reconciliation queue no growth
49
+
50
+ Fallback playbook:
51
+
52
+ - trigger: payment failure spike
53
+ - action: switch traffic to A
54
+ - deadline: < 10 minutes
55
+ - owner: on-call + fintech lead
56
+
57
+ Execution priority:
58
+
59
+ ```
60
+ ▲ high
61
+ reconciliation accuracy
62
+ callback reliability
63
+ ▼ low
64
+ brand messaging tweaks
65
+ custom dashboard layout
66
+ ```
67
+
68
+ ## Why this works
69
+
70
+ В миграции ключевая ценность — показывать не просто шаги, а условия перехода между
71
+ ступенями. Поток делает это явно: переход к следующей стадии возможен только при
72
+ прохождении метрик и готовности fallback.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@albinocrabs/feynman",
3
- "version": "0.2.1",
3
+ "version": "0.2.4",
4
4
  "description": "Claude Code and Codex plugin that auto-injects ASCII diagram rules into every AI request via UserPromptSubmit hook",
5
5
  "license": "MIT",
6
6
  "author": "apolenkov",
@@ -52,14 +52,16 @@
52
52
  "test": "node --test tests/*.test.js",
53
53
  "coverage": "c8 --reporter=text --reporter=lcov node --test tests/*.test.js",
54
54
  "lint": "node bin/feynman-lint.js",
55
+ "audit": "npm audit --audit-level=moderate",
55
56
  "test:docs": "node scripts/check-docs.js",
56
57
  "test:release": "node scripts/release-smoke.js",
58
+ "test:published": "node scripts/verify-published-package.js",
57
59
  "build": "node scripts/build-package.js",
58
60
  "changelog": "node scripts/generate-changelog.js",
59
- "ci": "npm run coverage && npm run test:docs && npm run test:release && npm run build",
61
+ "ci": "npm run audit && npm run coverage && npm run test:docs && npm run test:release && npm run build",
60
62
  "prepublishOnly": "npm run ci"
61
63
  },
62
64
  "devDependencies": {
63
- "c8": "^10"
65
+ "c8": "^11.0.0"
64
66
  }
65
67
  }
@@ -1,8 +1,6 @@
1
1
  <!-- feynman diagram rules — feynman-activate.md -->
2
2
  <!-- Hook reads only the section matching the active intensity. -->
3
3
  <!-- Variants: lite (flow+trees), full (all types, default), ultra (force diagrams). -->
4
- <!-- Each section must stay under 8,000 chars. Measure with: -->
5
- <!-- node -e "const f=require('fs').readFileSync('rules/feynman-activate.md','utf8');['lite','full','ultra'].forEach(v=>{const s=f.indexOf('<!-- '+v+' -->');const e=f.indexOf('<!-- /'+v+' -->',s);console.log(v,f.slice(s,e+('<!-- /'+v+' -->').length).length,'chars');})" -->
6
4
 
7
5
  <!-- lite -->
8
6
  ## Feynman Diagram Rules — Lite
@@ -95,11 +93,11 @@ no persistence | full persistence | optional
95
93
 
96
94
  Syntax:
97
95
  ```
98
- ┌─ Status ─┐
99
- item-a done
100
- item-b in progress
101
- item-c blocked
102
- └─────────┘
96
+ +---- Status ----+
97
+ |item-a: done |
98
+ |item-b: in prog |
99
+ |item-c: blocked |
100
+ +----------------+
103
101
  ```
104
102
 
105
103
  **Priority orderings** — A response that orders three or more items by priority, importance, severity, or rank includes an ▲▼ priority scale.
@@ -3,7 +3,8 @@ name: feynman
3
3
  disable-model-invocation: true
4
4
  description: >
5
5
  Toggle ASCII diagram injection on/off or set intensity level (lite/full/ultra).
6
- Use when user says /feynman, /feynman on, /feynman off, /feynman lite/full/ultra, /feynman status.
6
+ Use when user says /feynman, /feynman on/start, /feynman off/stop,
7
+ /feynman lite/full/ultra, /feynman status.
7
8
  ---
8
9
 
9
10
  Manage feynman diagram injection. Read current state, apply requested change, report result.
@@ -11,8 +12,8 @@ Manage feynman diagram injection. Read current state, apply requested change, re
11
12
  ## When invoked
12
13
 
13
14
  Parse `$ARGUMENTS`:
14
- - `on` — enable feynman, keep current intensity
15
- - `off` — disable feynman
15
+ - `on`, `start` — enable feynman, keep current intensity
16
+ - `off`, `stop` — disable feynman
16
17
  - `lite` — enable at lite intensity (flows + trees only)
17
18
  - `full` — enable at full intensity (all diagram types)
18
19
  - `ultra` — enable at ultra intensity (force diagram always)
@@ -40,12 +41,13 @@ node -e "
40
41
  const fs = require('fs'), os = require('os'), path = require('path');
41
42
  const stateFile = path.join(os.homedir(), '.claude', '.feynman', 'state.json');
42
43
  const flagFile = path.join(os.homedir(), '.claude', '.feynman-active');
43
- const arg = process.argv[1] || '';
44
+ const arg = (process.argv[1] || '').trim().toLowerCase();
45
+ const normalized = arg === 'start' ? 'on' : arg === 'stop' ? 'off' : arg;
44
46
  let st = {enabled: true, intensity: 'full', injections: 0};
45
47
  try { st = JSON.parse(fs.readFileSync(stateFile, 'utf8')); } catch(e) {}
46
- if (arg === 'on') { st.enabled = true; fs.writeFileSync(flagFile, st.intensity); }
47
- if (arg === 'off') { st.enabled = false; try { fs.unlinkSync(flagFile); } catch(e) {} }
48
- if (['lite','full','ultra'].includes(arg)) { st.intensity = arg; st.enabled = true; fs.writeFileSync(flagFile, arg); }
48
+ if (normalized === 'on') { st.enabled = true; fs.writeFileSync(flagFile, st.intensity); }
49
+ if (normalized === 'off') { st.enabled = false; try { fs.unlinkSync(flagFile); } catch(e) {} }
50
+ if (['lite','full','ultra'].includes(normalized)) { st.intensity = normalized; st.enabled = true; fs.writeFileSync(flagFile, normalized); }
49
51
  fs.mkdirSync(path.dirname(stateFile), {recursive: true});
50
52
  fs.writeFileSync(stateFile, JSON.stringify(st, null, 2));
51
53
  console.log(JSON.stringify(st));