codecartographer-pi 0.22.3 → 0.24.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.
@@ -26,7 +26,21 @@ not replace any phase; it tells phases where to look.
26
26
 
27
27
  ## Reading a Broad-Side run
28
28
 
29
- 1. Read `synthesis.md` first. It carries the executive summary, severity counts,
29
+ 0. If `verified.md` exists, read it first. A verification pass
30
+ (`codecarto_broadside {action: "verify"}`, `/codecarto-broadside verify`)
31
+ has read the top defect and security findings against the real source with
32
+ read-only tools and given each a verdict: **confirmed** (a reachable
33
+ failure, with the input or call site that triggers it), **not-a-defect**
34
+ (the claim is literally true of the code but nothing can reach the failure
35
+ it describes), **discarded** (the claim is wrong about the code, with the
36
+ guard or line that shows it), or **unclear**. Start from the confirmed
37
+ ones; treat a discarded one as answered unless the reasoning is thin.
38
+ Measured on this repository, the top twelve findings by severity were two
39
+ real defects and ten that a look at the guard, the caller, or the tsconfig
40
+ dismissed — the pass agreed with a reviewer on all twelve for about a cent
41
+ a finding. A confirmed verdict is still a model's reading: a strong lead for
42
+ a human's next look, not a validated claim.
43
+ 1. Read `synthesis.md`. It carries the executive summary, severity counts,
30
44
  the top cross-lens findings, and per-module risk levels.
31
45
  2. Read `triage.md` for the work order: each lead scored by impact ×
32
46
  difficulty with a P0–P3 priority and an effort estimate. It is a starting
@@ -66,6 +80,7 @@ Broad-Side is an executable-surface feature. On the Pi extension:
66
80
  /codecarto-broadside collect # poll, save, synthesize
67
81
  /codecarto-broadside status # show recorded runs
68
82
  /codecarto-broadside models # compare batch models
83
+ /codecarto-broadside verify --top=10 # read the top findings against the source
69
84
  ```
70
85
 
71
86
  On the MCP server:
@@ -75,6 +90,7 @@ codecarto_broadside {cwd, action: "submit", lenses: [...]} # fire the batches
75
90
  codecarto_broadside {cwd, action: "collect"} # poll, save, synthesize
76
91
  codecarto_broadside {cwd, action: "status"} # show recorded runs
77
92
  codecarto_broadside {cwd, action: "models"} # compare batch models
93
+ codecarto_broadside {cwd, action: "verify", top: 10} # read the top findings against the source
78
94
  ```
79
95
 
80
96
  The `models` action lists every `:batch` variant on OpenRouter — pricing per
@@ -86,10 +102,37 @@ Submits pre-flight the chosen model: pricing comes from the live catalog
86
102
  model that does not advertise structured-output support is refused outright,
87
103
  because every lens depends on `json_schema` response_format.
88
104
 
105
+ Each lens reads a scope of the repository. Architecture reads the manifest,
106
+ entry point, README, and file tree; defect, conventions, and porting read
107
+ every source file; the **security** and **API** lenses target where the
108
+ trust boundary usually lives — `server/**`, `**/auth*`, `**/middleware/**`,
109
+ `SECURITY.md` (security) and `server/**`, `api/**`, `src/server/**`,
110
+ `src/api/**`, `**/*routes*`, `**/*router*`, `**/*handler*`, `**/*endpoint*`
111
+ (API). A repository whose server is `src/server.js` matches none of those, so
112
+ when the targeted patterns find nothing those two lenses **fall back to every
113
+ source file** — priced as such, chunked at the lens's slice size rather than
114
+ truncated, and said so on the lens line of the estimate, the submit report,
115
+ `status`, and the prompt the model receives. A lens whose targeted patterns
116
+ and fallback both find nothing (only test files, say) is skipped with a line
117
+ naming both. `max_cost` is the guard against a fallback scan on a large
118
+ repository being more than you meant to spend.
119
+
89
120
  Collect runs two cross-lens post-passes by default: **synthesis** (the
90
121
  executive report) and **triage** (the prioritized work order). Pass
91
122
  `include_synthesis: false` or `include_triage: false` on collect to skip one.
92
123
 
124
+ `verify` is the third pass, run separately after collect because it is
125
+ sync-priced rather than batch-priced: for each of the top `top` findings
126
+ (default 10, most severe first) of the defect and security lenses, one chat
127
+ completion on the run's model without its `:batch` suffix (`model` overrides),
128
+ with three read-only tools confined to the repository's source files —
129
+ `read_file` by line range, `grep`, `list_dir` — at most eight tool calls, low
130
+ reasoning effort, then a verdict. It writes `verified.md` and `verified.json`
131
+ beside `triage.md` and records the pass on the run. `max_cost` is a running
132
+ cap here, since a sync call's cost is known only when it returns: the pass
133
+ stops before the next finding once the calls so far have reached it and
134
+ reports `partial`. About a cent a finding on the default model.
135
+
93
136
  Two caveats apply to any model you pick. The `models` action lists every id
94
137
  OpenRouter advertises a `:batch` variant for, and many of those variants do not
95
138
  exist — submitting one returns `does not have a :batch endpoint`, with nothing in
@@ -3,4 +3,4 @@
3
3
  # workspace's framework-owned files (GUIDE.md, templates/, workflow/ pipelines
4
4
  # and VALIDATE.md) predate the running release. Written at release time and
5
5
  # copied verbatim by init — never edit by hand.
6
- scaffold_version: 0.22.3
6
+ scaffold_version: 0.24.0
package/README.md CHANGED
@@ -383,7 +383,7 @@ Each workflow tool accepts an absolute `cwd` for the target repository. `codecar
383
383
 
384
384
  ## Broad-Side (batch reconnaissance)
385
385
 
386
- Broad-Side is the cheap sweep you run *before* the expensive interactive run. It fires six analysis lenses — architecture, API surface, security, mechanical defect scan, convention extraction, porting — at a repository as single-turn prompts over the [OpenRouter Batch API](https://openrouter.ai/docs), then cross-references them into one executive report (`synthesis.md`) and a prioritized P0–P3 work order (`triage.md`).
386
+ Broad-Side is the cheap sweep you run *before* the expensive interactive run. It fires six analysis lenses — architecture, API surface, security, mechanical defect scan, convention extraction, porting — at a repository as single-turn prompts over the [OpenRouter Batch API](https://openrouter.ai/docs), then cross-references them into one executive report (`synthesis.md`) and a prioritized P0–P3 work order (`triage.md`). The security and API lenses target the paths where a trust boundary usually lives (`server/`, `auth*`, `middleware/`, routers and handlers) and fall back to every source file when a repository has none of them — priced as such, and said so on the estimate — so a service whose server is `src/server.js` still gets its security review.
387
387
 
388
388
  **Broad-Side findings are unverified scouting leads, not evidence.** Each lens is one shot: no cross-file traversal, no runtime verification, no builds, no tests. Every finding is a `file:line` pointer that the interactive pipeline — or you — must confirm before it is a fact. That division of labor is the point: a sub-dollar unattended sweep that tells the expensive run where to look. Nothing downstream may cite a Broad-Side report as a source.
389
389
 
@@ -394,13 +394,16 @@ codecarto_broadside {cwd, action: "models"} # compare batch mo
394
394
  codecarto_broadside {cwd, action: "submit", lenses: [...]} # fire the batches, priced first
395
395
  codecarto_broadside {cwd, action: "status"} # what is in flight
396
396
  codecarto_broadside {cwd, action: "collect"} # poll, save, synthesize, triage
397
+ codecarto_broadside {cwd, action: "verify", top: 10} # read the top findings against the source
397
398
  ```
398
399
 
400
+ A third action, `verify`, reads the top defect and security findings of a collected run against the real source — one sync-priced call each with read-only tools (`read_file`, `grep`, `list_dir`) confined to the repository — and writes `verified.md` with a verdict per finding: **confirmed** (a reachable failure, with the trigger), **not-a-defect**, **discarded**, or **unclear**. Measured on this repository, the top twelve findings by severity were two real defects and ten claims a look at the guard or the caller dismissed; the pass agreed with a reviewer on all twelve for a cent a finding. Read `verified.md` before `triage.md`.
401
+
399
402
  Submit and collect are separate because batch jobs routinely take tens of minutes; collect is resumable and picks up whatever is still in flight (`wait_seconds: 0`, the default, polls once and returns), and two collects on one run — a retried tool call, a second session — never pay for the synthesis, triage, or truncation retry twice: each is claimed in the run's state before it is submitted, and a collect whose client has gone away stops polling and submits nothing further. Submit prices the run from the collected file sizes against the model's live per-token pricing (cached 24h) and refuses when the estimate exceeds `max_cost` — $1.00 unless the config or the call sets another value, `0` for no limit — unless `force: true` is passed — a pre-flight estimate, not a runtime stop. Actual spend lands in each run's `run-meta.json`.
400
403
 
401
404
  Repository defaults live in `.codecarto/broadside/config.yaml` (`model`, `api_key`, `default_lenses`, `max_cost`, `pricing` overrides, `lens_models`, `incremental`, `retry_truncated`, `include_synthesis`, `include_triage`, `wait_seconds`); an explicit tool parameter always wins. `lens_models` routes individual lenses to their own batch model — a stronger model changes security and defect findings far more than it changes an architecture map — and each override is priced, capability-checked, and clamped exactly like the default, with the estimate broken out per lens so a mixed-model run cannot be approved without seeing which lens costs what. CodeCartographer ships no stronger default: which model earns its price depends on your repository and budget, so compare candidates with the `models` action and choose — for one run with the `model` and `lens_models` parameters (Pi: `--model=ID`, `--lens-model=LENS:ID`), or for the repository in `config.yaml`. The `models` listing is advisory: OpenRouter's catalog returns a `:batch` id for some models its Batch API then refuses (`does not have a :batch endpoint`), at no cost, and nothing in the catalog tells them apart — so the listing tags the ids this repository's own submits have seen accepted or refused, and a refused lens says why in the submit report. `codecarto_skill {cwd, name: "broadside"}` returns the reading guide for a completed run, and unlike post-pipeline skills it is not gated on a finished pipeline.
402
405
 
403
- On the Pi extension the same run is `/codecarto-broadside [submit|collect|status|models] [lenses…] [--model=ID] [--lens-model=LENS:ID]`, with tab-completion for actions, lens names, and flags and live per-lens progress while batches poll. The two surfaces differ in one deliberate place: MCP cannot ask a human, so it refuses a run over `max_cost` until you pass `force`; Pi shows the per-lens breakdown and asks, and your approval *is* the force flag. Neither surface takes an API key as a command argument — a key typed into a slash command lands in the session transcript.
406
+ On the Pi extension the same run is `/codecarto-broadside [submit|collect|status|models|verify] [lenses…] [--model=ID] [--lens-model=LENS:ID] [--top=N]`, with tab-completion for actions, lens names, and flags and live per-lens progress while batches poll. The two surfaces differ in one deliberate place: MCP cannot ask a human, so it refuses a run over `max_cost` until you pass `force`; Pi shows the per-lens breakdown and asks, and your approval *is* the force flag. Neither surface takes an API key as a command argument — a key typed into a slash command lands in the session transcript.
404
407
 
405
408
  Broad-Side needs runtime code, so firing a run is an executable-surface feature: Pi and MCP have it, the pure drop-in template does not (it carries only the reading guide).
406
409
 
@@ -95,7 +95,11 @@ Two more economies worth knowing:
95
95
 
96
96
  ## Reading a run
97
97
 
98
- Results land in `.codecarto/broadside/<run>/`. Read them in this order:
98
+ Results land in `.codecarto/broadside/<run>/`. If `verified.md` is there, read
99
+ it before anything else: `action: "verify"` has read the top defect and
100
+ security findings against the source with read-only tools and given each a
101
+ verdict (confirmed with its trigger, not-a-defect, discarded with the guard
102
+ that shows it, unclear). Then, in this order:
99
103
 
100
104
  1. `synthesis.md` — executive summary, severity counts, top cross-lens
101
105
  findings, per-module risk.
@@ -0,0 +1,95 @@
1
+ import { type BroadsideLensId, type BroadsideVerifyEntry, type FetchLike, type StoredLensResult } from "./broadside.ts";
2
+ export declare const BROADSIDE_CHAT_URL = "https://openrouter.ai/api/v1/chat/completions";
3
+ /** How many findings `verify` reads by default, most severe first. */
4
+ export declare const BROADSIDE_VERIFY_DEFAULT_TOP = 10;
5
+ /** Tool calls one finding may spend before it must answer. */
6
+ export declare const BROADSIDE_VERIFY_MAX_TOOL_CALLS = 8;
7
+ /** The lenses whose findings carry a file:line and a claim to check. */
8
+ export declare const BROADSIDE_VERIFIABLE_LENSES: readonly BroadsideLensId[];
9
+ export type VerifyVerdict = "confirmed" | "not-a-defect" | "discarded" | "unclear";
10
+ export type VerifiedFinding = {
11
+ index: number;
12
+ lensId: BroadsideLensId;
13
+ customId: string;
14
+ severity: string;
15
+ title: string;
16
+ location: string;
17
+ verdict: VerifyVerdict | "error";
18
+ confidence: string;
19
+ evidence: Array<{
20
+ file: string;
21
+ lines: string;
22
+ note: string;
23
+ }>;
24
+ reasoning: string;
25
+ toolCalls: number;
26
+ cost: number;
27
+ };
28
+ export type BroadsideVerifyResult = {
29
+ runId: string;
30
+ outputDir: string;
31
+ model: string;
32
+ status: BroadsideVerifyEntry["status"];
33
+ /** How many findings the run had in the verifiable lenses. */
34
+ candidates: number;
35
+ findings: VerifiedFinding[];
36
+ totalCost: number;
37
+ /** Set when the cost cap stopped the pass before every selected finding was read. */
38
+ stoppedByCost?: boolean;
39
+ };
40
+ type CandidateFinding = {
41
+ lensId: BroadsideLensId;
42
+ customId: string;
43
+ severity: string;
44
+ title: string;
45
+ location: string;
46
+ description: string;
47
+ pattern: string;
48
+ };
49
+ /** The sync-priced id behind a `:batch` model id (`vendor/name:batch` → `vendor/name`). */
50
+ export declare function syncModelFor(batchModel: string): string;
51
+ /** The findings a run's saved lens results carry, most severe first. */
52
+ export declare function rankVerifiableFindings(stored: StoredLensResult[]): CandidateFinding[];
53
+ export type RepoReader = {
54
+ readFile(path: string, startLine?: number, endLine?: number): Promise<string>;
55
+ grep(pattern: string, pathPrefix?: string): Promise<string>;
56
+ listDir(path: string): Promise<string>;
57
+ };
58
+ /**
59
+ * Three read-only tools over the repository's own file list — the same
60
+ * listing the lenses scan (tracked and untracked, ignore rules applied) minus
61
+ * everything {@link isSlurpable} keeps out of a lens: credential stores, build
62
+ * output, binaries. A path outside the repository, or one the listing does
63
+ * not contain, is an error the model sees, not a read.
64
+ */
65
+ export declare function createRepoReader(cwd: string): Promise<RepoReader>;
66
+ /**
67
+ * The rubric. The order is deliberate — it is the order a reviewer settles a
68
+ * claim in — and `not-a-defect` is the verdict that separates "the code does
69
+ * what the claim says" from "and that is a bug": without it, a cast every
70
+ * caller satisfies gets confirmed because it is literally there.
71
+ */
72
+ export declare const BROADSIDE_VERIFY_SYSTEM_PROMPT: string;
73
+ /** Verify one finding: up to the tool budget, then a verdict. */
74
+ export declare function verifyFinding(finding: CandidateFinding, index: number, reader: RepoReader, apiKey: string, model: string, fetcher: FetchLike): Promise<Omit<VerifiedFinding, "index" | "lensId" | "customId" | "severity" | "title" | "location">>;
75
+ /**
76
+ * Verify the top findings of a collected run against the repository.
77
+ *
78
+ * `maxCost` is a running cap, not a pre-flight estimate: a sync call's cost
79
+ * is only known when it returns, so the pass stops *before* starting the next
80
+ * finding once the cap is reached and reports `partial`. On the default
81
+ * model a finding costs about a cent.
82
+ */
83
+ export declare function runBroadsideVerify(cwd: string, apiKey: string, opts?: {
84
+ runId?: string;
85
+ top?: number;
86
+ model?: string;
87
+ /** USD; 0 means no limit. */
88
+ maxCost?: number;
89
+ fetcher?: FetchLike;
90
+ signal?: AbortSignal;
91
+ onProgress?: (finding: VerifiedFinding) => void;
92
+ }): Promise<BroadsideVerifyResult>;
93
+ export declare function renderVerifiedMarkdown(result: BroadsideVerifyResult): string;
94
+ export declare function verifyResultText(result: BroadsideVerifyResult): string;
95
+ export {};