Skip to content

feat(narrative): extract analyst prompt skeleton (B3) - #19

Merged
nyashkn merged 1 commit into
mainfrom
feat/narrative-analyst-prompt
Jun 9, 2026
Merged

nyashkn merged 1 commit into
mainfrom
feat/narrative-analyst-prompt

Conversation

@nyashkn

@nyashkn nyashkn commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Summary

B3 of eval-harness extraction. The recurring analyst prompt scaffold (claim schema, query_path rules, output file list, headings) moves into insight-kit so any consumer reuses without forking. Project-specific bits (founder context, data scope description) become runtime kwargs.

New module

insight_kit.narrative.analyst_prompt:

  • ANALYST_PROMPT_TEMPLATE — literal template with {goal_slug} {question} {run_dir} {data_scope} {founder_context_block} placeholders.
  • render_analyst_prompt(...) — formats template. Founder block fully omitted when empty.

Includes hardened query_path rules from growth_insights PR #8 (single path, no concat, upstream refs go in cites).

Version

0.1.5 → 0.1.6

Test plan

  • pytest tests/narrative/ — 11/11
  • Full suite — 835/835 (no regression)

Companion

growth_insights side: update src/growth_insights/analyst/runner.py to call render_analyst_prompt instead of carrying its own _ANALYST_HEADER.

B3 of the eval-harness extraction. The recurring scaffold of the analyst
run prompt (claim schema, query_path rules, output file list, headings)
moves into insight-kit so any consumer can reuse it without forking. Project-
specific bits — founder context, data scope description — are runtime
parameters.

## New module

`insight_kit.narrative.analyst_prompt`:

- `ANALYST_PROMPT_TEMPLATE` — the literal template string with named
  placeholders {goal_slug}, {question}, {run_dir}, {data_scope},
  {founder_context_block}.
- `render_analyst_prompt(goal_slug, question, run_dir, data_scope='',
  founder_context='')` — formats the template. Founder-context block is
  completely omitted (no empty heading left over) when the string is empty.

Includes the strict `query_path` rules block hardened in growth_insights
PR #8 (no concatenation, single .sql path per claim, upstream refs in
`cites`).

## Tests

11 new tests in `tests/narrative/test_analyst_prompt.py` cover:
- goal_slug + question + run_dir interpolation
- run_dir accepts str + Path
- founder_context block included when set, omitted when empty
- data_scope default placeholder vs custom markdown
- JSON claim-schema block renders with literal { } (not unescaped {{ }})
- strict query_path rules block is present (omp-drift hardening)
- output files list + persona instructions hook
- ANALYST_PROMPT_TEMPLATE constant exposes all named placeholders

## Version

0.1.5 → 0.1.6

## Next (B3 cont. on growth_insights side)

Update growth_insights/src/growth_insights/analyst/runner.py to import
`render_analyst_prompt` instead of carrying its own `_ANALYST_HEADER`
constant. nairomarket founder context becomes the `founder_context`
kwarg. Meta JSON + Shopify parquet + prior claim paths become the
`data_scope` markdown.
@nyashkn
nyashkn merged commit 6f0ade3 into main Jun 9, 2026
@nyashkn
nyashkn deleted the feat/narrative-analyst-prompt branch June 9, 2026 00:32
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