Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
16 changes: 8 additions & 8 deletions .claude/rules/backend_contract_migration.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
paths:
- "convex/**/*.ts"
- "server/**/*.ts"
- "backend/convex/**/*.ts"
- "workers/node/**/*.ts"
- "public/proto/*.html"
- "src/**/*.{ts,tsx}"
- "apps/web/src/**/*.{ts,tsx}"
related_: [live_dom_verification, agentic_reliability, owner_mode_end_to_end, completion_traceability]
---

Expand Down Expand Up @@ -41,7 +41,7 @@ contract, ship in **three PRs**, not one:
- Old callers keep working; new callers can opt in.
- For a rename: export both names, both pointing at the same handler.
```ts
// convex/events.ts
// backend/convex/events.ts
const composeAnswerHandler = mutation({ /* ... */ });
export const composeAnswer = composeAnswerHandler;
export const askAgent = composeAnswerHandler; // legacy alias
Expand Down Expand Up @@ -101,9 +101,9 @@ If verification fails at any step, do not proceed to the next step.

## Contract path discipline (added 2026-05-27)

**Every Convex contract MUST specify the deployed path as `<filename>:<exportName>`, not just the export name.** Convex resolves paths by filename — putting `requestSignInLink` in `convex/users.ts` deploys it at `users:requestSignInLink`, not `events:requestSignInLink`, regardless of what the contract doc says.
**Every Convex contract MUST specify the deployed path as `<filename>:<exportName>`, not just the export name.** Convex resolves paths by filename — putting `requestSignInLink` in `backend/convex/users.ts` deploys it at `users:requestSignInLink`, not `events:requestSignInLink`, regardless of what the contract doc says.

Case study — PR #407/#409 hotfix (2026-05-27): the Step 8 contract specified mutations as `events:requestSignInLink` / `events:verifySignInToken` / `events:listMyEvents` to match the existing scratchnode namespace. The implementing agent put them in `convex/users.ts` (sensible — `events.ts` was overloaded). Deployed paths became `users:*`. Frontend and dogfood script kept calling `events:*` — silent function-not-found at runtime. Convex's HTTP API masks this as a generic "Server Error" message, hiding the mismatch from CI.
Case study — PR #407/#409 hotfix (2026-05-27): the Step 8 contract specified mutations as `events:requestSignInLink` / `events:verifySignInToken` / `events:listMyEvents` to match the existing scratchnode namespace. The implementing agent put them in `backend/convex/users.ts` (sensible — `events.ts` was overloaded). Deployed paths became `users:*`. Frontend and dogfood script kept calling `events:*` — silent function-not-found at runtime. Convex's HTTP API masks this as a generic "Server Error" message, hiding the mismatch from CI.

### Required contract format

Expand All @@ -113,13 +113,13 @@ events:requestSignInLink({ email }) → { ok }

// ✅ GOOD — deployed path is explicit
users:requestSignInLink({ email }) → { ok }
// implemented in convex/users.ts as `export const requestSignInLink = mutation({...})`
// implemented in backend/convex/users.ts as `export const requestSignInLink = mutation({...})`
```

If the contract author wants the path to be `events:*` despite the implementation living in another file, the implementing PR must add an explicit re-export:

```ts
// convex/events.ts
// backend/convex/events.ts
export { requestSignInLink, verifySignInToken, listMyEvents } from "./users";
```

Expand Down
6 changes: 3 additions & 3 deletions .claude/rules/dogfood_verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ Runs a full Scribe-like dogfood session locally and makes it UI-verifiable at `/

| Layer | Changes to | Deployed via | Visible when |
|-------|-----------|-------------|--------------|
| React components | `.tsx` in `src/` | `vite build` | Preview server restarted |
| Convex functions | `.ts` in `convex/` | `npx convex deploy` | Backend redeployed |
| Convex schema | `convex/schema.ts` | `npx convex deploy` | Backend redeployed |
| React components | `.tsx` in `apps/web/src/` | `vite build` | Preview server restarted |
| Convex functions | `.ts` in `backend/convex/` | `npx convex deploy` | Backend redeployed |
| Convex schema | `backend/convex/schema.ts` | `npx convex deploy` | Backend redeployed |
| MCP tools | `packages/mcp-local/` | `npx tsc` in package | MCP server restarted |
| Stored data | DB records | Data migration or mutation | After migration runs |
| Dashboard HTML | `briefHtml.ts` / `html.ts` | Inline — restart server | Server restarted |
Expand Down
6 changes: 3 additions & 3 deletions .claude/rules/eval_flywheel.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Continuous self-improving eval loop for the NodeBench search pipeline. The system judges itself, diagnoses failures, fixes them, and loops until 100%.

## When to activate
- After any change to `server/routes/search.ts` or search-related tools
- After any change to `workers/node/routes/search.ts` or search-related tools
- User says "run eval", "flywheel", "judge loop", "reach 100%"
- After completing any implementation sprint touching search, entity enrichment, or result rendering
- Automatically after deploying search changes
Expand Down Expand Up @@ -109,10 +109,10 @@ Always do deep research before declaring a blocker permanent. The system should
## Key files
- `packages/mcp-local/src/benchmarks/searchQualityEval.ts` — Eval harness (100+ queries, Gemini judge)
- `packages/mcp-local/src/benchmarks/llmJudgeEval.ts` — Chained pipeline eval (tool A → tool B)
- `server/routes/search.ts` — Search route with 4-layer grounding pipeline
- `workers/node/routes/search.ts` — Search route with 4-layer grounding pipeline
- `packages/mcp-local/src/tools/entityEnrichmentTools.ts` — Entity enrichment MCP tools
- `packages/mcp-local/src/tools/webTools.ts` — web_search implementation
- `convex/tools/media/linkupSearch.ts` — Linkup search (Convex-side)
- `backend/convex/tools/media/linkupSearch.ts` — Linkup search (Convex-side)

## Anti-patterns
- Declaring done at 80% because "the remaining 20% is hard"
Expand Down
28 changes: 14 additions & 14 deletions .claude/rules/forecasting_os.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
paths:
- "convex/domains/forecasting/**"
- "convex/workflows/dailyLinkedInPost.ts"
- "src/features/research/components/Forecast*"
- "src/features/research/components/CalibrationPlot*"
- "src/features/research/components/BrierTrendChart*"
- "src/features/research/components/EvidenceTimeline*"
- "src/features/research/components/TraceBreadcrumb*"
- "backend/convex/domains/forecasting/**"
- "backend/convex/workflows/dailyLinkedInPost.ts"
- "apps/web/src/features/research/components/Forecast*"
- "apps/web/src/features/research/components/CalibrationPlot*"
- "apps/web/src/features/research/components/BrierTrendChart*"
- "apps/web/src/features/research/components/EvidenceTimeline*"
- "apps/web/src/features/research/components/TraceBreadcrumb*"
- "packages/mcp-local/src/tools/forecastingTools.ts"
related_: [reexamine_process, analyst_diagnostic, completion_traceability, reexamine_resilience]
---
Expand All @@ -32,13 +32,13 @@ related_: [reexamine_process, analyst_diagnostic, completion_traceability, reexa
## Key files
| File | Purpose |
|------|---------|
| `convex/domains/forecasting/forecastManager.ts` | CRUD + 6 public dashboard queries |
| `convex/domains/forecasting/signalMatcher.ts` | Deterministic signal↔forecast cross-reference |
| `convex/domains/forecasting/traceWrapper.ts` | TRACE-wrapped forecast refresh (6 audit steps) |
| `convex/domains/forecasting/scoringEngine.ts` | Brier + log scoring, proper scoring rules |
| `convex/domains/forecasting/schema.ts` | 5 tables: forecasts, forecastEvidence, forecastResolutions, forecastUpdateHistory, forecastCalibrationLog |
| `convex/workflows/dailyLinkedInPost.ts` | LinkedIn pipeline with Δ badges, evidence links, TRACE |
| `src/features/research/components/ForecastCockpit.tsx` | Dashboard assembler (CalibrationPlot, BrierTrendChart, ForecastCard) |
| `backend/convex/domains/forecasting/forecastManager.ts` | CRUD + 6 public dashboard queries |
| `backend/convex/domains/forecasting/signalMatcher.ts` | Deterministic signal↔forecast cross-reference |
| `backend/convex/domains/forecasting/traceWrapper.ts` | TRACE-wrapped forecast refresh (6 audit steps) |
| `backend/convex/domains/forecasting/scoringEngine.ts` | Brier + log scoring, proper scoring rules |
| `backend/convex/domains/forecasting/schema.ts` | 5 tables: forecasts, forecastEvidence, forecastResolutions, forecastUpdateHistory, forecastCalibrationLog |
| `backend/convex/workflows/dailyLinkedInPost.ts` | LinkedIn pipeline with Δ badges, evidence links, TRACE |
| `apps/web/src/features/research/components/ForecastCockpit.tsx` | Dashboard assembler (CalibrationPlot, BrierTrendChart, ForecastCard) |
| `packages/mcp-local/src/tools/forecastingTools.ts` | 9 MCP tools |

## Conventions
Expand Down
14 changes: 7 additions & 7 deletions .claude/rules/gemini_qa_loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ npx vite build
npx vite preview --host 127.0.0.1 --port 4173 &

# 3. Capture screenshots via e2e test
BASE_URL=http://127.0.0.1:4173 npx playwright test tests/e2e/full-ui-dogfood.spec.ts --project=chromium --workers=1
BASE_URL=http://127.0.0.1:4173 npx playwright test evals/e2e/full-ui-dogfood.spec.ts --project=chromium --workers=1

# 4. Publish screenshots to public/dogfood/
npm run dogfood:publish
Expand Down Expand Up @@ -92,9 +92,9 @@ Pattern: **Pro → Flash → Flash → Flash → Pro → Flash → Flash → Fla
- 60% cost reduction while maintaining Pro-quality baseline analysis

### Config files
- `convex/domains/dogfood/screenshotQa.ts` — Screenshot QA action
- `convex/domains/dogfood/videoQa.ts` — Video QA action
- `convex/domains/dogfood/videoQaQueries.ts` — `getLatestProAnalysis` query for reference injection
- `backend/convex/domains/dogfood/screenshotQa.ts` — Screenshot QA action
- `backend/convex/domains/dogfood/videoQa.ts` — Video QA action
- `backend/convex/domains/dogfood/videoQaQueries.ts` — `getLatestProAnalysis` query for reference injection

## Multi-Variant Coverage

Expand Down Expand Up @@ -125,12 +125,12 @@ This returns the step-by-step workflow chain with tool references and shell comm

| File | Purpose |
|------|---------|
| `convex/domains/dogfood/screenshotQa.ts` | Screenshot QA action (Gemini Flash + Jony Ive prompts) |
| `convex/domains/dogfood/videoQa.ts` | Video QA action (Gemini Flash + Jony Ive prompts) |
| `backend/convex/domains/dogfood/screenshotQa.ts` | Screenshot QA action (Gemini Flash + Jony Ive prompts) |
| `backend/convex/domains/dogfood/videoQa.ts` | Video QA action (Gemini Flash + Jony Ive prompts) |
| `scripts/ui/runDogfoodGeminiQa.mjs` | CLI orchestrator for QA pipeline |
| `scripts/ui/recordDogfoodWalkthrough.mjs` | Playwright video recorder |
| `scripts/ui/publishDogfoodGallery.mjs` | Screenshot publisher (variant-aware manifest) |
| `tests/e2e/full-ui-dogfood.spec.ts` | E2e 4-variant screenshot capture test |
| `evals/e2e/full-ui-dogfood.spec.ts` | E2e 4-variant screenshot capture test |
| `public/dogfood/qa-results.json` | QA score history |
| `.tmp/dogfood-gemini-qa/*.json` | Latest QA results (screens + video) |
| `shared/llm/modelCatalog.ts` | Model catalog with Gemini defaults |
4 changes: 2 additions & 2 deletions .claude/rules/grounded_eval.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Before extraction, check source quality:
- **medium**: 1-2 snippets — extract conservatively, flag as limited
- **low**: 0 snippets — return "insufficient data" template, do NOT generate

Implementation: `retrievalConfidence` in `server/routes/search.ts`
Implementation: `retrievalConfidence` in `workers/node/routes/search.ts`

### Layer 2: Claim-Level Grounding Filter
After Gemini extraction, verify each claim against source text:
Expand Down Expand Up @@ -57,7 +57,7 @@ Implementation: `sourceIdx` field on signals, changes, risks in response
- If judge variance exceeds 10% across runs, use majority vote (3x calls)

## Key files
- `server/routes/search.ts` — Layers 1-2 and 4 (retrieval, filter, citations)
- `workers/node/routes/search.ts` — Layers 1-2 and 4 (retrieval, filter, citations)
- `packages/mcp-local/src/benchmarks/searchQualityEval.ts` — Layer 3 (grounded judge)
- `packages/mcp-local/src/benchmarks/llmJudgeEval.ts` — Chain coherence criterion

Expand Down
2 changes: 1 addition & 1 deletion .claude/rules/live_dom_verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ hydrates + Convex queries resolve. That means:
return 200 not 404. Catches landmines (a) and (c).
Does NOT prove: routes actually render the right component.

- **Tier B (tests/e2e/live-smoke.spec.ts via `npm run live-smoke`)** —
- **Tier B (evals/e2e/live-smoke.spec.ts via `npm run live-smoke`)** —
Playwright loads each URL in a real browser, waits for hydration,
asserts DOM nodes exist (e.g. "Link not found" on `/share/dummy`,
`<h1>` on landing, recovery CTAs visible).
Expand Down
4 changes: 2 additions & 2 deletions .claude/rules/pipeline_operational_standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ instrument → judge → persist → surface → measure → regress.
`reportsTokenCounts`, `capturedSources`, `emitStatusIsTerminal`.

Order is stable — dashboards rely on it. Add a gate by extending `GATE_ORDER`
in `server/pipeline/diligenceJudge.ts`.
in `workers/node/pipeline/diligenceJudge.ts`.

## Verdict tiers (bounded enum)
- `verified` — 0 failures, ≤ 2 skipped
Expand All @@ -45,7 +45,7 @@ in `server/pipeline/diligenceJudge.ts`.
## Verification floor
1. `npx convex codegen`
2. `npx tsc --noEmit`
3. `npx vitest run server/pipeline/diligenceJudge.test.ts server/pipeline/diligenceProjectionWriter.test.ts`
3. `npx vitest run workers/node/pipeline/diligenceJudge.test.ts workers/node/pipeline/diligenceProjectionWriter.test.ts`
4. `npm run build`
5. `npm run dogfood:verify:smoke` when the UI changed

Expand Down
6 changes: 3 additions & 3 deletions .claude/rules/pre_release_review.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ If Convex is NOT deployed:
- [ ] "Sign in" messages appear where expected

### Layer 10: WebSocket Gateway (< 3 min)
If gateway is running (`npx tsx server/index.ts`):
If gateway is running (`npx tsx workers/node/index.ts`):
- [ ] `GET /health` returns 200
- [ ] `GET /mcp/health` returns session count
- [ ] WebSocket connects with valid API key
Expand All @@ -133,8 +133,8 @@ Test in at least one non-Chrome browser (Safari, Firefox, or Edge):

### Layer 13: Regression Risks (< 2 min)
Check these known fragile areas:
- [ ] Voice server: if `server/index.ts` was modified, verify voice WebSocket still works
- [ ] Schema changes: if `convex/schema.ts` was modified, verify migration compatibility
- [ ] Voice server: if `workers/node/index.ts` was modified, verify voice WebSocket still works
- [ ] Schema changes: if `backend/convex/schema.ts` was modified, verify migration compatibility
- [ ] Tool count: grep for hardcoded "289", "297", "304" — must all match current reality
- [ ] Print: if Decision Memo or Postmortem was modified, verify print stylesheet (if exists)
- [ ] OG tags: if `index.html` was modified, verify meta tags are correct
Expand Down
6 changes: 3 additions & 3 deletions .claude/rules/product_design_dogfood.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
paths:
- "src/**/*.tsx"
- "src/**/*.css"
- "tests/e2e/**/*.ts"
- "apps/web/src/**/*.tsx"
- "apps/web/src/**/*.css"
- "evals/e2e/**/*.ts"
- "scripts/ui/**/*.mjs"
related_: [analyst_diagnostic, dogfood_verification, reexamine_design_reduction, completion_traceability]
---
Expand Down
2 changes: 1 addition & 1 deletion .claude/rules/reference_attribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ from topic files rather than persisting it directly." Honest > embellished.
## What this rule enforces

- New architecture docs have a "Prior art" section or the PR is rejected
- New server/pipeline/ or convex/domains/ modules have a file header comment linking their doc
- New workers/node/pipeline/ or backend/convex/domains/ modules have a file header comment linking their doc
- When copying a Claude Code skill, cite `.claude/skills/<origin>` in the new skill's frontmatter

## Anti-patterns
Expand Down
12 changes: 6 additions & 6 deletions .claude/rules/self_improvement_loop.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Self-Improvement Loop — Operating Manual

The agent brain for NodeBench's continuous improvement flywheel. Read this on every loop cycle
(manual or scheduled). The deterministic substrate is `scripts/improvement-loop/`; this rule is
(manual or scheduled). The deterministic substrate is `adw/improvement-loop/`; this rule is
how the agent drives it. Canonical design: `docs/architecture/SELF_IMPROVEMENT_LOOP.md`.

## Operating model: bounded + goal-driven (NOT "never stop")

This loop is governed by the Self-Directed Development OS in [`goals/README.md`](../../goals/README.md)
and the hard gates in [`goals/HARD_GATES.md`](../../goals/HARD_GATES.md). The lesson is **not**
This loop is governed by the Self-Directed Development OS in [`adw/goals/README.md`](../../goals/README.md)
and the hard gates in [`adw/goals/HARD_GATES.md`](../../goals/HARD_GATES.md). The lesson is **not**
"let the agent run forever" — it is: closed goal, reviewable definition of done, focused subagents,
hard gates, batch feedback.

Expand All @@ -18,7 +18,7 @@ hard gates, batch feedback.

- **Cadence:** daily small-loop (propose ONE bounded next step; only tiny CI-gated detector fixes
auto-ship, ≤3/day) + weekly self-review (propose issues/cuts/goals, never auto-add features).
Substantive work becomes a Goal Card (`goals/<surface>/NNN-slug.md`) the founder approves.
Substantive work becomes a Goal Card (`adw/goals/<surface>/NNN-slug.md`) the founder approves.
- **Operating rule:** Human sets the *why* + boundary; agent explores the *how*; tests decide; docs preserve.
- **Hard gates:** prod deploy, destructive migrations, auth, billing, public/private permission
rules, data deletion, legal/privacy copy, wiki publish, host/mod privileges, secrets → propose only.
Expand All @@ -32,7 +32,7 @@ hard gates, batch feedback.

### 1. OBSERVE + SCORE
```bash
node scripts/improvement-loop/run-cycle.mjs --effort-budget 3
node adw/improvement-loop/run-cycle.mjs --effort-budget 3
```
This runs `scan.mjs`, writes `backlog.latest.json`, selects the top auto-safe opportunity, and
appends a cycle to `ledger.json`.
Expand Down Expand Up @@ -84,7 +84,7 @@ If the change would touch any of these, it is **human-gated** — queue it, do N
- Shipping a fix for a false-positive scanner hit (validate first).
- Auto-shipping a human-gated change.
- Claiming "live" on a green build (live-DOM verify first — `live_dom_verification.md`).
- Building a parallel loop instead of extending `scripts/improvement-loop/` + the existing dogfood/eval scripts.
- Building a parallel loop instead of extending `adw/improvement-loop/` + the existing dogfood/eval scripts.

## Related rules
- `flywheel_continuous` · `self_building_loop` · `eval_flywheel` · `analyst_diagnostic`
Expand Down
16 changes: 8 additions & 8 deletions .claude/rules/telemetry_trajectory.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Make telemetry and agent step trajectories measurable, debuggable, and beautiful

## Dev-side telemetry (internal)

### Search trace (server/routes/search.ts)
### Search trace (workers/node/routes/search.ts)
Every search request emits a `trace` array with structured steps:
```typescript
interface TraceStep {
Expand Down Expand Up @@ -83,13 +83,13 @@ Every search result should be traceable back to:
5. What the user should verify independently

## Key files
- `src/features/controlPlane/components/SearchTrace.tsx` — User-facing trace UI
- `src/features/agents/components/FastAgentPanel/StepTimeline.tsx` — Agent step timeline
- `src/features/agents/components/FastAgentPanel/FastAgentPanel.ParallelTaskTimeline.tsx` — Parallel execution
- `src/features/monitoring/views/AgentTelemetryDashboard.tsx` — Telemetry dashboard
- `src/features/trajectory/types.ts` — Trajectory score types
- `convex/domains/agents/traceTypes.ts` — TRACE framework types
- `server/routes/search.ts` — Search trace emission
- `apps/web/src/features/controlPlane/components/SearchTrace.tsx` — User-facing trace UI
- `apps/web/src/features/agents/components/FastAgentPanel/StepTimeline.tsx` — Agent step timeline
- `apps/web/src/features/agents/components/FastAgentPanel/FastAgentPanel.ParallelTaskTimeline.tsx` — Parallel execution
- `apps/web/src/features/monitoring/views/AgentTelemetryDashboard.tsx` — Telemetry dashboard
- `apps/web/src/features/trajectory/types.ts` — Trajectory score types
- `backend/convex/domains/agents/traceTypes.ts` — TRACE framework types
- `workers/node/routes/search.ts` — Search trace emission
- `packages/mcp-local/src/benchmarks/searchQualityEval.ts` — Eval harness

## Related rules
Expand Down
Loading
Loading