midah commited on
Commit
6d4754b
·
verified ·
1 Parent(s): 4582bc5

feat: side-by-side comparator (agent/eval axes) + trail-as-thread

Browse files
Files changed (5) hide show
  1. __pycache__/app.cpython-313.pyc +0 -0
  2. app.py +156 -3
  3. static/app.js +142 -1
  4. static/index.html +22 -0
  5. static/style.css +41 -0
__pycache__/app.cpython-313.pyc CHANGED
Binary files a/__pycache__/app.cpython-313.pyc and b/__pycache__/app.cpython-313.pyc differ
 
app.py CHANGED
@@ -32,6 +32,13 @@ Design decisions (benefit / price):
32
  canonicalization, and coverage can grow on CI rather than at request time.
33
  Price: store-backed datasets are only as fresh as the last refresh build;
34
  the weekly action keeps them current.
 
 
 
 
 
 
 
35
  """
36
 
37
  from __future__ import annotations
@@ -49,7 +56,15 @@ from fastapi.responses import FileResponse, JSONResponse
49
  from fastapi.staticfiles import StaticFiles
50
  from pydantic import BaseModel
51
 
 
 
 
 
 
 
 
52
  from procgrep.ingest import ingest
 
53
 
54
  # ── configuration ────────────────────────────────────────────────────────────
55
  MAX_TRACES = 20000 # per-dataset ingest cap (design decision 3); raise as memory allows
@@ -59,6 +74,10 @@ HIT_SAMPLE = 50 # matched traces returned to the client
59
  STATIC = Path(__file__).parent / "static"
60
  SPINE_REPO = "midah/procgrep-spines" # precomputed store (design decision 5)
61
  SPINE_FILE = "procgrep_spines.parquet"
 
 
 
 
62
 
63
  # A short, curated starting set; the client may query any dataset id.
64
  SUGGESTED = (
@@ -231,9 +250,7 @@ def datasets() -> JSONResponse:
231
  """
232
  store_ids = list(_load_store().keys())
233
  suggested = list(dict.fromkeys([*store_ids, *SUGGESTED]))
234
- return JSONResponse(
235
- {"suggested": suggested, "cached": list(_CACHE.keys()), "meta": _META}
236
- )
237
 
238
 
239
  @app.post("/query")
@@ -305,6 +322,142 @@ def query(req: QueryRequest) -> JSONResponse:
305
  )
306
 
307
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  @app.get("/")
309
  def index() -> FileResponse:
310
  return FileResponse(STATIC / "index.html")
 
32
  canonicalization, and coverage can grow on CI rather than at request time.
33
  Price: store-backed datasets are only as fresh as the last refresh build;
34
  the weekly action keeps them current.
35
+ 6. The comparator (/compare) reuses the library's lineage primitives
36
+ (fit_bpe, encode, discriminative_procedures, jsd) rather than reinventing
37
+ them, and bounds each side to CMP_SAMPLE traces for the BPE/diff pass.
38
+ Benefit: the side-by-side diff means exactly what the paper's lineage_diff
39
+ means, and the heavy step stays bounded for interactive latency.
40
+ Price: the discriminative-procedure ranking sees a sample, not all traces,
41
+ on very large groups; the rendered trail stack is a further CMP_STACK cap.
42
  """
43
 
44
  from __future__ import annotations
 
56
  from fastapi.staticfiles import StaticFiles
57
  from pydantic import BaseModel
58
 
59
+ from procgrep import (
60
+ Trace,
61
+ discriminative_procedures,
62
+ encode,
63
+ fit_bpe,
64
+ jsd,
65
+ )
66
  from procgrep.ingest import ingest
67
+ from procgrep.types import PROCEDURE_SEPARATOR
68
 
69
  # ── configuration ────────────────────────────────────────────────────────────
70
  MAX_TRACES = 20000 # per-dataset ingest cap (design decision 3); raise as memory allows
 
74
  STATIC = Path(__file__).parent / "static"
75
  SPINE_REPO = "midah/procgrep-spines" # precomputed store (design decision 5)
76
  SPINE_FILE = "procgrep_spines.parquet"
77
+ CMP_SAMPLE = 1500 # traces per side fed to BPE + discriminative_procedures (design decision 6)
78
+ CMP_STACK = 30 # trails rendered per side in the comparator
79
+ CMP_VOCAB = 200 # BPE procedure-vocabulary size for the diff
80
+ CMP_TRAIL_CAP = 140 # atoms per rendered trail (fits the column at 3px/cell)
81
 
82
  # A short, curated starting set; the client may query any dataset id.
83
  SUGGESTED = (
 
250
  """
251
  store_ids = list(_load_store().keys())
252
  suggested = list(dict.fromkeys([*store_ids, *SUGGESTED]))
253
+ return JSONResponse({"suggested": suggested, "cached": list(_CACHE.keys()), "meta": _META})
 
 
254
 
255
 
256
  @app.post("/query")
 
322
  )
323
 
324
 
325
+ class CompareRequest(BaseModel):
326
+ """A side-by-side comparison along one axis.
327
+
328
+ axis="agent": ``dataset`` is one store dataset; ``left``/``right`` are agent
329
+ names within it. axis="eval": ``left``/``right`` are dataset ids (``dataset``
330
+ is ignored). axis="outcome" is reserved for the outcome-column build.
331
+ """
332
+
333
+ axis: str = "agent"
334
+ dataset: str = SUGGESTED[0]
335
+ left: str
336
+ right: str
337
+
338
+
339
+ def _side_traces(axis: str, dataset: str, value: str) -> tuple[list[CachedTrace], str]:
340
+ """Resolve one side of a comparison to its traces and a display label."""
341
+ if axis == "eval":
342
+ return _load(value), value.split("/")[-1]
343
+ if axis == "agent":
344
+ return [t for t in _load(dataset) if t.agent == value], value
345
+ raise ValueError(f"unsupported axis: {axis}")
346
+
347
+
348
+ def _mix_vector(mix_a: dict[str, float], mix_b: dict[str, float]) -> tuple[list[float], list[float]]:
349
+ """Align two action-mix dicts onto a shared atom alphabet for JSD."""
350
+ keys = sorted(set(mix_a) | set(mix_b))
351
+ return [mix_a.get(k, 0.0) for k in keys], [mix_b.get(k, 0.0) for k in keys]
352
+
353
+
354
+ def _side_summary(traces: list[CachedTrace], label: str) -> dict:
355
+ """Trail stack plus the same quick stats the query view reports.
356
+
357
+ The stack is an even spread across the length distribution (short to long),
358
+ not the longest N, so it reads as a fingerprint of the whole group rather
359
+ than its tail.
360
+ """
361
+ ordered = sorted((t for t in traces if t.atoms), key=lambda t: len(t.atoms))
362
+ if len(ordered) > CMP_STACK:
363
+ stride = len(ordered) / CMP_STACK
364
+ picked = [ordered[int(i * stride)] for i in range(CMP_STACK)]
365
+ else:
366
+ picked = ordered
367
+ return {
368
+ "label": label,
369
+ "n": len(traces),
370
+ "stats": _stats(traces),
371
+ "mix": _action_mix(traces),
372
+ "trails": [
373
+ {
374
+ "trace_id": t.trace_id,
375
+ "model": t.agent,
376
+ "task": t.task,
377
+ "steps": len(t.atoms), # true length; atoms below are capped for rendering
378
+ "atoms": list(t.atoms[:CMP_TRAIL_CAP]),
379
+ }
380
+ for t in picked
381
+ ],
382
+ }
383
+
384
+
385
+ @app.post("/compare")
386
+ def compare(req: CompareRequest) -> JSONResponse:
387
+ """Side-by-side procedural diff of two trace groups.
388
+
389
+ Returns a trail stack and quick stats for each side, plus a diff strip: the
390
+ top procedures that distinguish them (signed log-odds, positive favors the
391
+ left side), the action-mix JSD, and median length/CoT deltas. Reuses the
392
+ library's BPE + discriminative_procedures (design decision 6).
393
+ """
394
+ try:
395
+ left, left_label = _side_traces(req.axis, req.dataset, req.left)
396
+ right, right_label = _side_traces(req.axis, req.dataset, req.right)
397
+ except Exception as exc:
398
+ return JSONResponse({"error": f"{type(exc).__name__}: {exc}"}, status_code=200)
399
+ if left_label == right_label:
400
+ return JSONResponse({"error": "pick two different groups"}, status_code=200)
401
+ if not left or not right:
402
+ empty = left_label if not left else right_label
403
+ return JSONResponse({"error": f"no traces for {empty!r}"}, status_code=200)
404
+
405
+ t0 = time.perf_counter()
406
+ # Build labeled Traces (group = side) for a sampled BPE + discriminative pass.
407
+ sample = [
408
+ *(Trace(t.trace_id, t.agent, t.atoms, group=left_label) for t in left[:CMP_SAMPLE]),
409
+ *(Trace(t.trace_id, t.agent, t.atoms, group=right_label) for t in right[:CMP_SAMPLE]),
410
+ ]
411
+ procedures: list[dict] = []
412
+ try:
413
+ vocab = fit_bpe((t.atoms for t in sample), vocab_size=CMP_VOCAB)
414
+ fingerprints = encode(sample, vocab=vocab)
415
+ for d in discriminative_procedures(
416
+ fingerprints, vocab, group_a=left_label, group_b=right_label, k=10
417
+ ):
418
+ procedures.append(
419
+ {
420
+ "atoms": d.procedure.split(PROCEDURE_SEPARATOR),
421
+ "log_odds": round(d.log_odds, 3),
422
+ "p_left": round(d.p_a, 4),
423
+ "p_right": round(d.p_b, 4),
424
+ }
425
+ )
426
+ except Exception: # diff is best-effort; the stacks still render without it
427
+ procedures = []
428
+
429
+ lsum, rsum = _side_summary(left, left_label), _side_summary(right, right_label)
430
+ pl, pr = _mix_vector(lsum["mix"], rsum["mix"])
431
+ elapsed_ms = (time.perf_counter() - t0) * 1e3
432
+ return JSONResponse(
433
+ {
434
+ "axis": req.axis,
435
+ "left": lsum,
436
+ "right": rsum,
437
+ "diff": {
438
+ "procedures": procedures,
439
+ "jsd": round(jsd(pl, pr), 4) if pl else None,
440
+ "len_delta": lsum["stats"].get("median_len", 0) - rsum["stats"].get("median_len", 0),
441
+ "cot_delta": lsum["stats"].get("median_cot", 0) - rsum["stats"].get("median_cot", 0),
442
+ },
443
+ "atom_color": ATOM_COLOR,
444
+ "elapsed_ms": round(elapsed_ms, 2),
445
+ }
446
+ )
447
+
448
+
449
+ @app.get("/groups")
450
+ def groups(dataset: str = SUGGESTED[0]) -> JSONResponse:
451
+ """Agents present in a dataset (for the comparator's agent picker)."""
452
+ try:
453
+ traces = _load(dataset)
454
+ except Exception as exc:
455
+ return JSONResponse({"error": f"{type(exc).__name__}: {exc}"}, status_code=200)
456
+ counts = Counter(t.agent for t in traces)
457
+ agents = [{"agent": a, "n": n} for a, n in counts.most_common()]
458
+ return JSONResponse({"dataset": dataset, "agents": agents})
459
+
460
+
461
  @app.get("/")
462
  def index() -> FileResponse:
463
  return FileResponse(STATIC / "index.html")
static/app.js CHANGED
@@ -16,9 +16,13 @@ function prettyModel(a){let m=String(a).replace(/^(swe-agent|agentless|moatless|
16
  return (m.replace(/-/g,' ').trim())||String(a);}
17
  function prettyTask(t){if(!t)return '';const m=String(t).match(/^(.+?)__(.+?)-(\d+)$/);return m?`${m[1]}/${m[2]} #${m[3]}`:String(t);}
18
  let HIDE_NOISE = false;
 
 
19
 
20
  async function loadDatasets() {
21
  const d = await (await fetch("datasets")).json();
 
 
22
  $("ds").innerHTML = d.suggested.map((s) => `<option>${s}</option>`).join("");
23
  $("trychips").innerHTML = SAMPLES.map((s, i) => `<span class="chip" data-i="${i}">${s.label}</span>`).join("");
24
  }
@@ -92,4 +96,141 @@ document.addEventListener("click", (e) => {
92
  $("q").addEventListener("keydown", (e) => { if (e.key === "Enter") run($("q").value); });
93
  $("ds").addEventListener("change", () => run($("q").value || SAMPLES[0].pat));
94
 
95
- loadDatasets().then(() => run(SAMPLES[0].pat));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  return (m.replace(/-/g,' ').trim())||String(a);}
17
  function prettyTask(t){if(!t)return '';const m=String(t).match(/^(.+?)__(.+?)-(\d+)$/);return m?`${m[1]}/${m[2]} #${m[3]}`:String(t);}
18
  let HIDE_NOISE = false;
19
+ let DSETS = []; // store-backed dataset ids (shared by query + compare)
20
+ const CMP = { axis: "agent", ds: null, left: null, right: null, data: null };
21
 
22
  async function loadDatasets() {
23
  const d = await (await fetch("datasets")).json();
24
+ DSETS = d.suggested;
25
+ CMP.ds = DSETS[0];
26
  $("ds").innerHTML = d.suggested.map((s) => `<option>${s}</option>`).join("");
27
  $("trychips").innerHTML = SAMPLES.map((s, i) => `<span class="chip" data-i="${i}">${s.label}</span>`).join("");
28
  }
 
96
  $("q").addEventListener("keydown", (e) => { if (e.key === "Enter") run($("q").value); });
97
  $("ds").addEventListener("change", () => run($("q").value || SAMPLES[0].pat));
98
 
99
+ // ── comparator ────────────────────────────────────────────────────────────
100
+ // A trail-as-thread: collapse think/other runs into fold lines, render signal
101
+ // atoms as labeled colored steps. The same skeleton the spine() bars draw,
102
+ // expanded into a readable column. This is how we show a "conversation":
103
+ // procgrep keeps the action structure, not the raw text.
104
+ function threadHTML(atoms, color) {
105
+ const out = [];
106
+ let i = 0;
107
+ while (i < atoms.length) {
108
+ const a = atoms[i];
109
+ if (a === "think" || a === "other") {
110
+ let n = 0;
111
+ while (i < atoms.length && (atoms[i] === "think" || atoms[i] === "other")) { n++; i++; }
112
+ out.push(`<div class="tstep fold">⋯ ${n} reasoning ${n > 1 ? "steps" : "step"}</div>`);
113
+ } else {
114
+ let n = 1;
115
+ while (i + n < atoms.length && atoms[i + n] === a) n++;
116
+ out.push(`<div class="tstep"><span class="ti">${i + 1}</span><span class="dot" style="background:${color[a] || "#ccc"}"></span>${a}${n > 1 ? " ×" + n : ""}</div>`);
117
+ i += n;
118
+ }
119
+ }
120
+ return out.join("");
121
+ }
122
+
123
+ // A contiguous trajectory barcode: one cell per atom, reasoning pale and
124
+ // actions vivid, so trail length is proportional and behavior reads as color
125
+ // density. Used by the comparator (vs the collapsing spine() the query uses).
126
+ function barcode(atoms, color) {
127
+ return '<span class="bc">' + atoms.map((a) => {
128
+ const noise = a === "think" || a === "other";
129
+ return `<i title="${a}" style="background:${noise ? "#e6e1d8" : (color[a] || "#ccc")}"></i>`;
130
+ }).join("") + "</span>";
131
+ }
132
+
133
+ function openTrace(side, i) {
134
+ const r = CMP.data; if (!r) return;
135
+ const t = r[side].trails[i];
136
+ const ds = CMP.axis === "eval" ? (side === "left" ? CMP.left : CMP.right) : CMP.ds;
137
+ const src = `https://huggingface.co/datasets/${ds}`;
138
+ const sheet = document.createElement("div");
139
+ sheet.className = "sheet";
140
+ sheet.onclick = (e) => { if (e.target === sheet) sheet.remove(); };
141
+ sheet.innerHTML =
142
+ `<div class="card"><span class="x" onclick="this.closest('.sheet').remove()">close ✕</span>
143
+ <div style="font-size:15px"><b>${prettyModel(t.model)}</b>${t.task ? ` · ${prettyTask(t.task)}` : ""}</div>
144
+ <div class="dim" style="margin:2px 0 4px">${t.steps} steps · structural trail, no raw text stored</div>
145
+ <div style="margin:6px 0 12px">${barcode(t.atoms, r.atom_color)}</div>
146
+ <div class="thread">${threadHTML(t.atoms, r.atom_color)}</div>
147
+ <div class="note" style="margin-top:12px"><a href="${src}" target="_blank" rel="noopener">view full trace at source ↗</a> · ${ds}</div>
148
+ </div>`;
149
+ document.body.appendChild(sheet);
150
+ }
151
+
152
+ function trailStack(side) {
153
+ const r = CMP.data, col = r[side], c = r.atom_color;
154
+ const s = col.stats;
155
+ return `<div class="cmpcol">
156
+ <div class="cmphead">${prettyModel(col.label)}</div>
157
+ <div class="cmpstat">${col.n.toLocaleString()} traces · median ${s.median_len} steps · ${s.median_cot} reasoning · diversity ${s.diversity_bits} bits</div>
158
+ ${col.trails.map((t, i) => `<div class="trow" onclick="openTrace('${side}',${i})"><span class="tlen">${t.steps} st</span>${barcode(t.atoms, c)}</div>`).join("")}</div>`;
159
+ }
160
+
161
+ function diffStrip() {
162
+ const r = CMP.data, c = r.atom_color, d = r.diff;
163
+ const L = prettyModel(r.left.label), R = prettyModel(r.right.label);
164
+ const procs = (d.procedures || []).slice(0, 7).map((p) => {
165
+ const lean = p.log_odds >= 0 ? `<span class="lean l">${L} ◂</span>` : `<span class="lean r">▸ ${R}</span>`;
166
+ return `<div class="proc">${lean}${barcode(p.atoms, c)}</div>`;
167
+ }).join("");
168
+ return `<div class="diffstrip">
169
+ <div class="dnums">
170
+ <div class="dnum"><div class="big">${d.jsd == null ? "—" : d.jsd}</div><div class="lab">action-mix JSD, 0 same to 1 disjoint</div></div>
171
+ <div class="dnum"><div class="big">${d.len_delta > 0 ? "+" : ""}${d.len_delta}</div><div class="lab">median length, <span class="lead-l">${L}</span> minus <span class="lead-r">${R}</span></div></div>
172
+ <div class="dnum"><div class="big">${d.cot_delta > 0 ? "+" : ""}${d.cot_delta}</div><div class="lab">reasoning steps, same direction</div></div>
173
+ </div>
174
+ <div class="eyebrow" style="margin:0 0 6px">procedures that most separate them</div>
175
+ ${procs || '<span class="dim">no distinguishing procedures found</span>'}
176
+ <div class="note">◂ leans <span class="lead-l">${L}</span> · leans <span class="lead-r">${R}</span> ▸ · think/other runs collapse to gaps</div>
177
+ </div>`;
178
+ }
179
+
180
+ async function runCompare() {
181
+ if (!CMP.left || !CMP.right) return;
182
+ $("cmp-res").innerHTML = '<span class="dim">diffing the two groups on the server…</span>';
183
+ let r;
184
+ try {
185
+ r = await (await fetch("compare", {
186
+ method: "POST", headers: { "Content-Type": "application/json" },
187
+ body: JSON.stringify({ axis: CMP.axis, dataset: CMP.ds, left: CMP.left, right: CMP.right }),
188
+ })).json();
189
+ } catch (e) { $("cmp-res").innerHTML = `<span class="err">request failed: ${e}</span>`; return; }
190
+ if (r.error) { $("cmp-res").innerHTML = `<span class="err">${r.error}</span>`; return; }
191
+ CMP.data = r;
192
+ $("cmp-res").innerHTML = `${diffStrip()}<div class="cmp">${trailStack("left")}${trailStack("right")}</div>`;
193
+ }
194
+
195
+ function opt(sel, list, val) {
196
+ return `<select onchange="${sel}">${list.map((x) => `<option ${x === val ? "selected" : ""}>${x}</option>`).join("")}</select>`;
197
+ }
198
+
199
+ async function renderCmpControls() {
200
+ const box = $("cmp-controls");
201
+ if (CMP.axis === "eval") {
202
+ if (!DSETS.includes(CMP.left) || CMP.left === CMP.right) { CMP.left = DSETS[0]; CMP.right = DSETS[1]; }
203
+ box.innerHTML = `${opt("CMP.left=this.value;runCompare()", DSETS, CMP.left)}
204
+ <span class="dim">vs</span>${opt("CMP.right=this.value;runCompare()", DSETS, CMP.right)}`;
205
+ } else {
206
+ box.innerHTML = `${opt("CMP.ds=this.value;renderCmpControls()", DSETS, CMP.ds)} <span class="dim">·</span> <span id="agentpick" class="dim">loading agents…</span>`;
207
+ const g = await (await fetch(`groups?dataset=${encodeURIComponent(CMP.ds)}`)).json();
208
+ const agents = (g.agents || []).map((a) => a.agent);
209
+ if (agents.length < 2) { $("agentpick").innerHTML = '<span class="err">only one agent in this dataset; pick another or use by eval</span>'; return; }
210
+ CMP.left = agents[0]; CMP.right = agents[1];
211
+ $("agentpick").innerHTML = `${opt("CMP.left=this.value;runCompare()", agents, CMP.left)}
212
+ <span class="dim">vs</span>${opt("CMP.right=this.value;runCompare()", agents, CMP.right)}`;
213
+ }
214
+ runCompare();
215
+ }
216
+
217
+ function setAxis(axis) {
218
+ CMP.axis = axis;
219
+ $("seg-agent").classList.toggle("act", axis === "agent");
220
+ $("seg-eval").classList.toggle("act", axis === "eval");
221
+ renderCmpControls();
222
+ }
223
+
224
+ let CMP_INIT = false;
225
+ function showView(name) {
226
+ $("view-query").classList.toggle("hidden", name !== "query");
227
+ $("view-compare").classList.toggle("hidden", name !== "compare");
228
+ $("tab-query").classList.toggle("act", name === "query");
229
+ $("tab-compare").classList.toggle("act", name === "compare");
230
+ if (name === "compare" && !CMP_INIT) { CMP_INIT = true; setAxis("agent"); }
231
+ }
232
+
233
+ loadDatasets().then(() => {
234
+ run(SAMPLES[0].pat);
235
+ if ((location.hash || "").replace("#", "") === "compare") showView("compare");
236
+ });
static/index.html CHANGED
@@ -4,6 +4,13 @@
4
  <title>procgrep · query agent traces, live</title>
5
  <link rel="stylesheet" href="static/style.css">
6
  </head><body><div class="wrap">
 
 
 
 
 
 
 
7
  <h1>Grep agent traces, live.</h1>
8
  <p class="sub">Ask a structural question about how an agent worked and get an exact answer over the whole
9
  trajectory dataset, not a sample. ProcGrep runs server-side: it ingests the dataset, canonicalizes it
@@ -17,6 +24,21 @@ into an action vocabulary, and scans every trace. No model call.</p>
17
  <input id="q" placeholder="atom pattern, e.g. (edit ){5,} or pick one below" autocomplete="off"></div>
18
  <div class="tryline">try: <span id="trychips"></span> <span class="chip" id="noisetog">hide think/other</span></div>
19
  <div id="res"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  </div>
22
  <script src="static/app.js"></script>
 
4
  <title>procgrep · query agent traces, live</title>
5
  <link rel="stylesheet" href="static/style.css">
6
  </head><body><div class="wrap">
7
+ <nav class="tabs">
8
+ <span class="tab act" id="tab-query" onclick="showView('query')">query</span>
9
+ <span class="tab" id="tab-compare" onclick="showView('compare')">compare</span>
10
+ <a class="tab plain" href="https://github.com/hamidahoderinwale/procgrep" target="_blank" rel="noopener">github ↗</a>
11
+ </nav>
12
+
13
+ <section id="view-query">
14
  <h1>Grep agent traces, live.</h1>
15
  <p class="sub">Ask a structural question about how an agent worked and get an exact answer over the whole
16
  trajectory dataset, not a sample. ProcGrep runs server-side: it ingests the dataset, canonicalizes it
 
24
  <input id="q" placeholder="atom pattern, e.g. (edit ){5,} or pick one below" autocomplete="off"></div>
25
  <div class="tryline">try: <span id="trychips"></span> <span class="chip" id="noisetog">hide think/other</span></div>
26
  <div id="res"></div>
27
+ </section>
28
+
29
+ <section id="view-compare" class="hidden">
30
+ <h1>Two agents, side by side.</h1>
31
+ <p class="sub">Different agents leave different procedural fingerprints. Put two of them next to each other,
32
+ read the trails top to bottom, and the diff strip names what the eye is seeing: the procedures that most
33
+ separate them, how far apart their action mixes are, and the length and reasoning gaps. No model call.</p>
34
+
35
+ <div class="cmpbar">
36
+ <span class="seg" id="seg-agent" onclick="setAxis('agent')">by agent</span>
37
+ <span class="seg" id="seg-eval" onclick="setAxis('eval')">by eval</span>
38
+ <span id="cmp-controls"></span>
39
+ </div>
40
+ <div id="cmp-res"></div>
41
+ </section>
42
 
43
  </div>
44
  <script src="static/app.js"></script>
static/style.css CHANGED
@@ -37,3 +37,44 @@ body.hide-noise .spine i.nz{display:none}
37
  .err{color:var(--copper)}
38
  .note{color:var(--olive);font-size:11px;margin-top:6px}
39
  a{color:var(--copper)}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  .err{color:var(--copper)}
38
  .note{color:var(--olive);font-size:11px;margin-top:6px}
39
  a{color:var(--copper)}
40
+
41
+ /* tabs + view switching */
42
+ .tabs{display:flex;gap:18px;align-items:baseline;border-bottom:1px solid var(--rule);margin:0 0 26px;padding-bottom:8px}
43
+ .tab{cursor:pointer;color:var(--olive);font-size:12px;text-transform:uppercase;letter-spacing:.1em}
44
+ .tab:hover{color:var(--ink)}
45
+ .tab.act{color:var(--ink);border-bottom:2px solid var(--copper);padding-bottom:8px;margin-bottom:-9px}
46
+ .tab.plain{margin-left:auto;text-decoration:none}
47
+ .hidden{display:none}
48
+
49
+ /* comparator */
50
+ .cmpbar{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin:2px 0 18px}
51
+ .seg{cursor:pointer;border:1px solid var(--rule);border-radius:2px;padding:4px 10px;font-size:11px;color:var(--olive)}
52
+ .seg:hover{border-color:var(--ink)}
53
+ .seg.act{border-color:var(--ink);color:var(--ink);background:#fff}
54
+ .cmp{display:grid;grid-template-columns:1fr 1fr;gap:22px;margin-top:14px}
55
+ .cmpcol .cmphead{font-size:15px;margin:0 0 2px}
56
+ .cmpcol .cmpstat{color:var(--olive);font-size:11px;margin-bottom:10px}
57
+ .trow{display:flex;align-items:center;gap:6px;padding:2px 0;cursor:pointer;border-bottom:1px solid #efeae2}
58
+ .trow:hover{background:#fff}
59
+ .trow .tlen{width:54px;color:var(--olive);font-size:10px;text-align:right;flex:none}
60
+ .bc{display:inline-flex;gap:0;flex-wrap:nowrap;overflow:hidden}
61
+ .bc i{width:3px;height:13px;flex:none}
62
+ .diffstrip{border:1px solid var(--rule);background:#fff;padding:14px 16px;margin-bottom:18px}
63
+ .diffstrip .dnums{display:flex;gap:26px;flex-wrap:wrap;margin-bottom:12px}
64
+ .diffstrip .dnum .big{font-size:21px}
65
+ .diffstrip .dnum .lab{color:var(--olive);font-size:11px}
66
+ .proc{display:flex;align-items:center;gap:8px;padding:3px 0}
67
+ .proc .lean{width:64px;font-size:10px;flex:none;text-align:right}
68
+ .proc .lean.l{color:var(--copper)}
69
+ .proc .lean.r{color:var(--teal)}
70
+ .lead-l{color:var(--copper)} .lead-r{color:var(--teal)}
71
+
72
+ /* trail-as-thread detail sheet */
73
+ .sheet{position:fixed;inset:0;background:rgba(20,17,14,.34);display:flex;justify-content:center;align-items:flex-start;padding:48px 16px;z-index:9;overflow:auto}
74
+ .sheet .card{background:var(--paper);max-width:760px;width:100%;padding:24px 28px;border:1px solid var(--rule)}
75
+ .sheet .x{float:right;cursor:pointer;color:var(--olive)}
76
+ .thread{display:flex;flex-direction:column;gap:3px;margin-top:10px}
77
+ .tstep{display:flex;gap:8px;align-items:baseline;font-size:12px}
78
+ .tstep .ti{width:14px;color:var(--gray);text-align:right;flex:none}
79
+ .tstep .dot{width:8px;height:8px;border-radius:2px;flex:none;align-self:center}
80
+ .tstep.fold{color:var(--olive);font-style:italic}