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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 68 additions & 79 deletions .github/prompts/00-base-contract.md

Large diffs are not rendered by default.

156 changes: 101 additions & 55 deletions .github/prompts/01-bash-and-shell-safety.md

Large diffs are not rendered by default.

89 changes: 43 additions & 46 deletions .github/prompts/02-mcp-access.md

Large diffs are not rendered by default.

112 changes: 51 additions & 61 deletions .github/prompts/03-data-download.md

Large diffs are not rendered by default.

22 changes: 13 additions & 9 deletions .github/prompts/04-analysis-pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,29 @@ Produced in `analysis/daily/$ARTICLE_DATE/$SUBFOLDER/`. The output set is **stab

> **Filename variants** — canonical `stakeholder-perspectives.md` ← template `stakeholder-impact.md`; canonical `classification-results.md` ← template `political-classification.md`; `comparative-international.md` ↔ `international-comparative.md`; `historical-parallels.md` ↔ `historical-baseline.md`; `election-2026-analysis.md` ↔ `election-cycle-analysis.md` ↔ `election-2026-implications.md` (all three map to the same cycle-parameterised template); `cycle-trajectory.md` and `parliamentary-season.md` are separate Family-D supplementary long-horizon tracking artifacts; `horizon-pir-rollforward.md` (supplementary — PIR carry-forward across horizon bands). For the general filename-variant rules, see [`ai-driven-analysis-guide.md` §Filename variants](../../analysis/methodologies/ai-driven-analysis-guide.md#-filename-variants-all-map-to-one-template--one-methodology-section); this prompt additionally accepts `election-cycle-analysis.md` as a local alias for the same election-cycle artifact.

## File-write contract (point-of-use reminder)

> 🛠 **All 23 artifacts on this page use the `edit` tool** — Pass 1 creates, Pass 2 read-back-and-improves, improvement-mode extensions, `pass1/` snapshot copies (`cp` is fine), `documents/{dok_id}-analysis.md`, and `## Re-run delta` appends in `methodology-reflection.md`. Tier-2 fallback (`cat <<'EOF_RAW' > file`) is acceptable only when `edit` has failed for non-content-shape reasons and the content is pure ASCII without code fences / Mermaid / `$` / backticks / `EOF` markers. Mermaid blocks, `ö ä å`, RTL/CJK characters, and non-trivial YAML/JSON sidecars ⇒ `edit` only. Banned for file writes: `python3`, `node -e`, `sed -i`, `echo … > file`, `tee file`, unquoted heredocs (`<<EOF`). See [`01-bash-and-shell-safety.md` §File creation & overwrite strategy](01-bash-and-shell-safety.md) for the full hierarchy.

## Execution order

> **Improvement-mode path** (when `IMPROVEMENT_MODE=true` from `03-data-download.md §Pre-flight`): **do not skip**, **do not no-op**. The 23 artifacts already exist on disk — your job is to **extend and improve** them, not regenerate them from scratch. Replace step 3 (Pass 1 — Create) with step 3′ below; steps 1, 2, 4, 5 still run normally. The aggregate+render step in module 06 is **always executed** — `article.md` and `news/*.html` are regenerated on every run.
> **Improvement-mode path** (when `IMPROVEMENT_MODE=true` from `03-data-download.md §Pre-flight`): extend the existing 23 artifacts; do not regenerate from scratch and do not no-op. Replace step 3 (Pass 1 — Create) with step 3′ below; steps 1, 2, 4, 5 run normally. Module 06 aggregate+render is **always executed** — `article.md` and `news/*.html` are regenerated every run.
>
> **3′ — Improvement Pass (replaces Pass 1 — Create)**:
>
> 1. **Read every existing artifact in full** (one tool call per file, including `documents/*-analysis.md`).
> 2. **Re-run the download/discovery only** to identify new `dok_id`s, fresher `get_voteringar` results, new committee schedule entries, or updated regering.se / SCB / IMF / Statskontoret context. At this stage, do **not** append to artifacts, do **not** update `data-download-manifest.md`, and do **not** create any new `documents/{dok_id}-analysis.md` files yet — just capture what must be updated after the baseline snapshot in step 4 below.
> 3. **Prepare the extension plan only** (no writes yet): determine which artifacts need changes, which new evidence rows must be added, which time-sensitive sections must be refreshed (forward indicators, scenario probabilities, coalition mathematics, election-2026 deltas), which `[unconfirmed]` flags can now be closed with ≥ 3 sources, which Key Judgments must be sharpened, and what `## Re-run delta` notes will be appended to `methodology-reflection.md` after the baseline snapshot.
> 4. **Never delete** prior analysis content unless it is factually wrong; correct in place and note the correction.
> 5. **Apply the planned extensions only after step 4 below** has snapshotted the pre-improvement baseline into `pass1/`. Concretely: after the snapshot, append new entries to `data-download-manifest.md` under a new `## Re-run YYYY-MM-DD HH:MM UTC` heading, create `documents/{dok_id}-analysis.md` for each new document, extend each existing artifact, and append a `## Re-run delta` subsection to `methodology-reflection.md` documenting what changed and why.
> 6. **Floor**: at least 8 minutes of real read/review-and-extend work across the artifact set on a `standard` improvement re-run, 12 minutes on `deep`, 15 minutes on `comprehensive`. Improvement-mode runs that produce zero artifact changes are a quality failure — there is **always** something to extend after the baseline snapshot (newer voting outcomes, new dok_ids, sharper uncertainty disclosure, fresher economic vintage, new media frames).
> 1. Read every existing artifact in full (one tool call per file, including `documents/*-analysis.md`).
> 2. Re-run download/discovery to identify new `dok_id`s, fresher `get_voteringar` results, new committee schedule entries, updated regering.se / SCB / IMF / Statskontoret context. Capture only — at this stage no artifact writes, no `data-download-manifest.md` updates, no new `documents/{dok_id}-analysis.md` files.
> 3. Prepare the extension plan (no writes yet): which artifacts need changes, which new evidence rows, which time-sensitive sections to refresh (forward indicators, scenario probabilities, coalition mathematics, election-2026 deltas), which `[unconfirmed]` flags can close with ≥ 3 sources, which Key Judgments to sharpen, what `## Re-run delta` notes to append.
> 4. Correct prior content in place when factually wrong; preserve and note the correction. Deletion is reserved for factual errors only.
> 5. After step 4 below snapshots the baseline into `pass1/`, apply the plan: append new entries to `data-download-manifest.md` under a `## Re-run YYYY-MM-DD HH:MM UTC` heading, create `documents/{dok_id}-analysis.md` for each new document, extend each existing artifact, append a `## Re-run delta` subsection to `methodology-reflection.md` documenting what changed and why.
> 6. **Floor**: ≥ 8 min real extend work on `standard`, 12 min on `deep`, 15 min on `comprehensive`. Zero-change improvement runs are a quality failure — newer voting outcomes, new dok_ids, sharper uncertainty disclosure, fresher economic vintage, new media frames are always available.
>
> Pass 2 (step 5 below) is still mandatory in improvement-mode and applies to every artifact, including the unchanged ones (read them, decide whether last run's improvement still holds).
> Pass 2 (step 5 below) runs in improvement-mode too — read every artifact including unchanged ones and decide whether last run's improvement still holds.

1. **Read all relevant methodologies first** (the primary methodology guide plus every supporting framework listed above, including `osint-tradecraft-standards.md`; one tool call per file; skipping fails the gate via `methodology-reflection.md §evidence` audit).
2. **Read all 23 templates first** — at minimum open each Family A/B/C/D template before writing its artifact.
3. **Pass 1 — Create** all 23 always-on artifacts + every per-document file. Minimum 20 minutes of real work. *(Improvement-mode replaces this with step 3′ above.)*
4. **Snapshot Pass-1** — copy every Pass-1 file into `$ANALYSIS_DIR/pass1/` before starting Pass 2: `mkdir -p "$ANALYSIS_DIR/pass1" && cp "$ANALYSIS_DIR"/*.md "$ANALYSIS_DIR/pass1/"`. The `pass1/` directory is the fallback evidence the gate uses when mtime windows are too tight. Do **not** stage `pass1/` in the PR (see `07-commit-and-pr.md`). *(Improvement-mode: take this snapshot **before** making any write/extend changes from step 3′ — until this snapshot exists, treat step 3′ as read/download/planning only and apply extensions only after step 4. Do not assume `pass1/` or its `.md` files are already present from the prior run; the broadened router (`03-data-download.md §Pre-flight`) may enter improvement-mode from a minimal carry-forward such as only `synthesis-summary.md`. The `mkdir -p` keeps the command valid in both cases. The snapshot overwrites any earlier baseline; the gate only needs the most recent pre-improvement copy for Pass-2 delta checks.)*
4. **Snapshot Pass-1** — copy every Pass-1 file into `$ANALYSIS_DIR/pass1/` before starting Pass 2: `mkdir -p "$ANALYSIS_DIR/pass1" && cp "$ANALYSIS_DIR"/*.md "$ANALYSIS_DIR/pass1/"`. The `pass1/` directory is the fallback evidence the gate uses when mtime windows are too tight. Exclude `pass1/` from the PR (see `07-commit-and-pr.md`). *(Improvement-mode: take this snapshot **before** any write/extend changes from step 3′. Until the snapshot exists, step 3′ stays read/download/planning-only. The broadened router (`03-data-download.md §Pre-flight`) may enter improvement-mode from a minimal carry-forward such as only `synthesis-summary.md`, so `mkdir -p` keeps the command valid in both cases. The snapshot overwrites earlier baselines — the gate only needs the most recent pre-improvement copy for Pass-2 delta checks.)*
5. **Pass 2 — Improve**: read every Pass-1 file back in full and strengthen evidence, diagrams, cross-references, stakeholder coverage, uncertainty disclosure, Admiralty annotations, WEP language, PIR/EEI tags. Minimum 10 minutes.
6. **Pass-2 declaration (mandatory, fail-loud contract)** — append/update `methodology-reflection.md` with a single canonical status line before running the gate: `Pass-2 status: executed in full`. If Pass 2 cannot be completed in full by the minute-42 PR window, do **not** proceed as a normal success path; treat it as an explicit gate failure and document the failure in the same file (no silent "not executed in full" acceptance).

Expand Down
6 changes: 3 additions & 3 deletions .github/prompts/05-analysis-gate.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,11 @@ Exit code 0 = pass, non-zero = fail with per-check report. Precondition for chec

## Re-run / deduplication note

Same-day re-runs are **improvement runs** (not skip runs) when `03-data-download.md §Pre-flight` detects a reusable baseline (all 23 artifacts present **or** at least `synthesis-summary.md` on disk) and sets `IMPROVEMENT_MODE=true`. Existing rendered HTML under `news/` does **not** establish improvement mode — the router keys off analysis baselines, not HTML. On improvement runs, the pipeline runs in extend-and-improve mode (`04-analysis-pipeline.md §Execution order`), the gate runs normally, and `06-article-generation.md` **always** regenerates `article.md` + `news/$ARTICLE_DATE-$SUBFOLDER-{en,sv,da,no,fi,de,fr,es,nl,ar,he,ja,ko,zh}.html` (all 14 languages via the localized executive-brief cascade — see `TRANSLATION_GUIDE.md §News articles are translated out-of-band`). **Per-language Markdown `article.<lang>.md` files MUST NOT be produced** on improvement runs — they are rejected by `scripts/validate-file-ownership.ts` (forbidden artefact, see `06-article-generation.md §Step 2`). There is still exactly one PR call. **Never** call `safeoutputs___noop` because today's HTML "already exists" — existing HTML is a reason to regenerate, not to exit early.
Same-day re-runs are **improvement runs** when `03-data-download.md §Pre-flight` detects a reusable baseline (all 23 artifacts present **or** at least `synthesis-summary.md` on disk) and sets `IMPROVEMENT_MODE=true`. The router keys off analysis baselines, not rendered HTML. On improvement runs the pipeline runs in extend-and-improve mode (`04-analysis-pipeline.md §Execution order`), the gate runs normally, and `06-article-generation.md` always regenerates `article.md` + `news/$ARTICLE_DATE-$SUBFOLDER-{en,sv,da,no,fi,de,fr,es,nl,ar,he,ja,ko,zh}.html` (all 14 languages via the localized executive-brief cascade). Per-language `article.<lang>.md` files are forbidden artefacts — `scripts/validate-file-ownership.ts` rejects them (see `06-article-generation.md §Step 2`). One PR call per run. Existing HTML is a reason to regenerate, never to call `safeoutputs___noop`.

### Check 12 ordering note

Check 12 (`scripts/validate-article.ts`) is the **editorial QA gate** on aggregated `article.md`. The blocking branch in §Implementation only fires when `article.md` is on disk; the inline gate runs before aggregation, so on first pass the validator is **informational** (logs `ℹ️ Check 12 (editorial QA): … skipped (run after aggregator)`). Workflows MUST re-invoke the gate (or call `npx tsx scripts/validate-article.ts $ANALYSIS_DIR/article.md` directly) **after** `scripts/aggregate-analysis.ts` writes `article.md`. See `06-article-generation.md §Step 1b — Editorial QA re-check (post-aggregation)`.
Check 12 (`scripts/validate-article.ts`) is the editorial QA gate on aggregated `article.md`. The blocking branch in §Implementation only fires when `article.md` is on disk; on first pass the validator logs `ℹ️ Check 12 (editorial QA): … skipped (run after aggregator)`. Re-invoke the gate (or `npx tsx scripts/validate-article.ts $ANALYSIS_DIR/article.md`) **after** `scripts/aggregate-analysis.ts` writes `article.md`. See `06-article-generation.md §Step 1b — Editorial QA re-check (post-aggregation)`.

## Supplementary checks

Expand All @@ -441,7 +441,7 @@ Non-blocking for `standard` / `deep` runs; **blocking for `comprehensive` / Tier

Methodology §links: [`per-artifact-methodologies.md`](../../analysis/methodologies/per-artifact-methodologies.md) (anchors: `#analysis-index`, `#reference-analysis-quality`, `#mcp-reliability-audit`, `#workflow-audit`, `#cross-run-diff`, `#cross-session-intelligence`, `#session-baseline`).

Inline bash probe — append after `FAIL=0` bookkeeping. Three independent blocking triggers: **aggregation article types** (`weekly-review`/`monthly-review`) require aggregation artifacts; **`comprehensive` tier** requires the Tier-C supplementary set; **`cross-run-diff.md`** is blocking whenever `ANALYSIS_RUN_COUNT ≥ 2` (any tier). `ARTICLE_TYPE` encodes the workflow family; `ANALYSIS_TIER` encodes the depth tier (`standard` | `deep` | `comprehensive`); `ANALYSIS_RUN_COUNT` is the numeric count of runs for the same cycle (unset/non-numeric → `1`).
Inline bash probe — append after `FAIL=0` bookkeeping. Three blocking triggers: aggregation types (`weekly-review`/`monthly-review`), `comprehensive` tier, and `cross-run-diff.md` whenever `ANALYSIS_RUN_COUNT ≥ 2`. `ARTICLE_TYPE` encodes the workflow family; `ANALYSIS_TIER` encodes the depth tier (`standard` | `deep` | `comprehensive`); `ANALYSIS_RUN_COUNT` is the numeric run count for the same cycle (unset/non-numeric → `1`).

```bash
# Check 11 — supplementary artifacts (blocking for aggregation types, Tier-C, and S5 when run-count >= 2)
Expand Down
Loading
Loading