Skip to content

feat(data-analyst) csv-analyst agent for UP Police (Phase 1 spec)#23

Open
madhyamakist wants to merge 21 commits into
mainfrom
feature/up-datanalyst-20260720-1848-v0.1
Open

feat(data-analyst) csv-analyst agent for UP Police (Phase 1 spec)#23
madhyamakist wants to merge 21 commits into
mainfrom
feature/up-datanalyst-20260720-1848-v0.1

Conversation

@madhyamakist

Copy link
Copy Markdown
Member

What

Natural-language data analyst for UP Police. Multi-CSV upload + NL questions → plan + query (DuckDB SQL) + table + charts + KPIs. Phase 2 extends to live MsSQL via DuckDB cache layer with zero additional load.

Spec files added/changed

  • spec/roadmap.md — phased plan (Phase 1 CSV, Phase 2 MsSQL, Phase 3 auth)
  • spec/architecture.md — system overview + stack (DuckDB + pyodbc + OpenRouter)
  • spec/agent.md — plan → query → execute → explain LangGraph graph
  • spec/data.md — session / run / query_log / db_connection / cache_snapshot entities
  • spec/api.md — sessions / csv upload / runs / db-connect endpoints
  • spec/ui.md — upload, ask, answer panel with KPIs / table / chart / audit block
  • spec/capabilities/csv-analyst.md — capability spec
  • spec/capabilities/index.md — capability registry

Assumptions captured

  • OpenRouter LLM provider (user preference)
  • Data stays on-prem; only LLM call leaves the network
  • Production reliability bar; auth and rate-limiter deferred to Phase 3 but spec'd now
  • pyodbc + MS ODBC 18 assumed installable on target server

madhyamakist and others added 2 commits July 21, 2026 00:18
…tes over prose)

Forensic mining of all Jul-20 runs (5 lenses, 44 findings) showed step-3.7's
output is clean and its question content the best of any model — it fails only
where the SKILL relies on prose it under-executes, and on the nvidia serving
route (240s dead-streams = 43% of agent-active time, zero prompt cache). hy3's
wins trace to endpoint reliability (0 429s / 2,613 calls) + clean turn economy.

Changes (all: convert prose to numbered gates / verbatim blocks):
- Stage 1: five numbered intake mechanics rules — batch each round as parallel
  clarify calls in ONE turn (18m10s -> ~10m measured), flat string choices (3/20
  calls silently dropped options), no SKILL-text leak, round-exit question-count
  check (Round 3 dropped 2/4), recap habit.
- API key: promoted from prose to a numbered HARD GATE — Stage 2 is invalid
  until the transcript contains the validation script's OK (live run skipped it
  entirely and built Phase 1 on an unvalidated key).
- Stage 2 scaffold: verbatim script block (base captured BEFORE branching; live
  run invented `rev-parse HEAD~2` and PR'd against main), mandatory git.md read,
  NOTES.md in the first commit, and a fresh-clone guard: when base == default
  branch, open the PR as DRAFT titled [build — DO NOT MERGE].
- Stage 2->3 seam: after `gh pr create`, IMMEDIATELY start Phase 1 — no
  permission stop (un-asked pause idled a live run 72 minutes).
- Stage 3: numbered slice loop (ONE slice -> tests -> implement -> gate), never
  "all surfaces in one pass" (live run shipped 11 type errors, zero tests).
- Router (.hermes.md + AGENTS.md): a build-shaped message IS $ARGUMENTS — start
  intake same turn, never bounce the idea back (live run wasted a round-trip).
- Pitfall #21: serving route matters as much as the model (nvidia vs OpenRouter
  step-3.7: 0% vs 83.6% cache); reliability beats latency; gates over prose;
  sessions.model lies (attribute via per-call log lines).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
madhyamakist and others added 19 commits July 21, 2026 01:00
…minutes

User constraint update: OpenRouter step-3.7 is not free — nvidia route is forced,
so the route-switch item is replaced by CONTEXT DIET as the primary transport
mitigation. New live evidence (session 66c652, 00:30-00:55):

- 3rd dead-stream (300s at ~118k ctx); zero cache confirmed on all 132 calls;
  11.6M input tokens re-prefilled. Stalls correlate with large-context requests.
- Phase 1 ran 35+ min with 10 source files on disk but ZERO commits — invisible
  in git/PR and one crash from loss. Slice loop now has step 5: commit+push the
  slice AND post a one-line progress note (the user sent four "are you done?"
  nudges; each answer cost a full ~135k re-prefill).
- Refined delegation rule: parallel fan-out stays forbidden on shared keys, but
  sequential DELEGATION beats inline once root context exceeds ~60k on a
  no-cache route (fresh ~20k worker context ≈ 7x cheaper per call, below the
  stall zone).
- Pitfall #21 extended: context-diet playbook + discovery that Hermes's
  background skill-review runs in-session on the MAIN model with full context
  (own call counter at 135-150k on the same endpoint, amplifying 429s).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ermes config edits assumed

Clone-and-go philosophy: users never edit ~/.hermes config, so 429/stall
resilience lives in the SKILL: set the 'just type continue' expectation at
build start, resume-don't-replan on continue, and structural defenses
(batched turns, per-slice commit+push, state on disk).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…on' into feature/up-datanalyst-20260720-1848-v0.1
…ories

Strip run anecdotes/measurements from SKILL.md (they live in commit messages,
PR #24, and the pitfalls reference). Net: leaner injected context. Also fold
the provider-hiccup guidance into one rule and add turn-pacing: do a slice's
related writes as parallel tool calls in one turn — fewer, fuller turns =
fewer per-minute rate-limit hits at the same throughput.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…on' into feature/up-datanalyst-20260720-1848-v0.1
…any rate-limit mention

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…on' into feature/up-datanalyst-20260720-1848-v0.1
…ed parallelism

Three surgical, instruction-only changes to the build SKILL (main otherwise
untouched), designed for providers that cap REQUESTS per minute:
- Intake: batch each round's questions as parallel clarify calls in ONE turn.
- Slice rhythm: one slice ≈ 3 requests (parallel writes turn; single chained
  pytest+add+commit+push command; progress note). Never two terminal calls
  where one && chain works. 429 mention → sleep 30 prefix + batch harder.
- Delegation: replace the blanket free-key inline preference with a request
  BUDGET — 2-3 parallel workers on disjoint slices while total request rate
  stays under ~half the provider cap; drop to one worker after any rate limit.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… on free tiers

Main harness's resilience was accidental: fat context made calls slow (~2 rpm),
so the loop rarely rolled the dice during a rate-limited pool's empty windows.
The trim's lean-fast calls rolled 4x more often and died 4x more often. This
makes the armor deliberate: keep the trim's batching (fewer requests per unit
of work) but hold the cadence at main's pace via a sleep-15 floor on terminal
commands, escalating to 45s after any rate-limit mention. Steady beats fast.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…oral guards

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant