> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nika.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# CEO Monday brief

> T4 epic · founders: market signal, engineering pulse and KPIs gathered in parallel behind one human decision, one dated brief.

> **T4 epic · founders / executives**: the flagship. Three branches
> gather in parallel (web signal, repo pulse, the KPI sheet), jq does
> the revenue arithmetic, a local model writes the brief, and one human
> decision at the root authorizes the whole run. It is also the smallest
> complete example of the lethal trifecta: private numbers, untrusted
> news and an outbound ping, held by that one gate.

## The job

Monday needs one page: market, product, numbers, risks, the ONE
decision. Assembling it eats an hour of founder time. This file
assembles it in one run: a dated filename, revenue summed by jq rather
than guessed by a model, and an optional founders ping that says whether
the brief landed.

> [!WARNING]
>
> **Limit on macOS in 0.124.3.** The sandbox confines `exec: git` to the
> workflow's declared filesystem boundary, which grants no read of `.git`
> or of git's global configuration. The confined `git` exits with status
> 128, even inside a real repository, so `pulse` takes its
> `recover:` value and the brief is told the engineering pulse is missing.
> See
> [Known limits](https://docs.nika.sh/changelog/known-limits.md#git-inside-a-workflow-is-refused-on-macos).

## The shape

```mermaid theme={"system"}
flowchart TD
  approve["approve · nika:prompt"]:::invoke
  news["news · nika:fetch"]:::invoke
  pulse["pulse · git"]:::exec
  sheet["sheet · nika:read"]:::invoke
  rows["rows · nika:convert"]:::invoke
  revenue["revenue · nika:jq"]:::invoke
  brief["brief"]:::infer
  stamp["stamp · nika:date"]:::invoke
  save["save · nika:write"]:::invoke
  alert["alert · nika:notify"]:::invoke
  approve --> news
  approve --> pulse
  approve --> sheet
  sheet --> rows
  rows --> revenue
  approve --> brief
  news --> brief
  pulse --> brief
  rows --> brief
  revenue --> brief
  approve --> stamp
  approve --> save
  stamp --> save
  brief --> save
  save --> alert
  stamp --> alert
  save -.->|terminal| alert
  classDef infer fill:#5b8cff22,stroke:#5b8cff,color:#5b8cff
  classDef exec fill:#ff7a3c22,stroke:#ff7a3c,color:#ff7a3c
  classDef invoke fill:#22d3ee22,stroke:#22d3ee,color:#22d3ee
```

## The file

```yaml ceo-monday-brief.nika theme={"system"}
nika: ceo-monday-brief

model: ollama/qwen3.5:4b   # local · zero key · `--model mock/echo` rehearses the whole file

inputs:
  alert:
    type: bool
    default: false
    description: "Send the founders ping. OFF by default so a rehearsal touches no webhook."
  kpi_sheet:
    type: string
    default: "./examples/fixtures/ceo-kpis.csv"
    description: "The weekly numbers · columns incl. weekly_revenue"

const:
  watch_query: "AI workflow engines"

secrets:
  founders_webhook:
    source: env
    key: FOUNDERS_WEBHOOK_URL
    egress:                       # sanction the one send · the secret IS the URL
      - to: "nika:notify"
        host_from_self: true
permits:
  exec: ["git"]
  tools: ["nika:convert", "nika:date", "nika:fetch", "nika:jq", "nika:notify", "nika:prompt", "nika:read", "nika:write"]
  net:
    http:
      - "hn.algolia.com"          # the market-signal search · the only host this brief READS
      # `host_from_self:` above sanctions the FLOW (the secret may be the URL) —
      # it does not grant the capability. The host stays unknown at check, so it
      # is judged at RUN against this bound: name the escalation host here or the
      # send is refused mid-run, after the tokens are already spent.
      - "hooks.slack.com"         # swap for wherever FOUNDERS_WEBHOOK_URL points
  fs:
    # The sheet arrives as an INPUT, so `check` reads past it — and the wall does
    # not move when the input does: point --var kpi_sheet at anything else and the
    # run refuses it NIKA-SEC-004. That asymmetry is the point of a permits block.
    read: ["./examples/fixtures/ceo-kpis.csv"]
    # One dated brief per run, written DIRECTLY in ./briefs/. `*` matches a single
    # segment and never crosses `/`, so nothing here can steer the write into a
    # subtree — which is why this is not `./briefs/**`.
    write: ["./briefs/*-monday.md"]

tasks:
  # ── the human gate · FIRST, before anything untrusted enters ──
  #
  # This run holds all three legs of the lethal trifecta: a private read (the
  # numbers), untrusted ingress (a public news API), and external egress (a
  # write and a webhook). NEP-0002 asks for one blocking human decision that
  # DOMINATES every path to every egress-capable task — which forces it here,
  # at the root, not in front of the save.
  #
  # A gate placed after the fetch could never dominate: the brief still reaches
  # `save` along its own data edge, a path the human is not standing on. And a
  # human skimming a model's summary of an attacker's page is a weak check
  # anyway — by then the payload is already inside the run. So the decision
  # taken here is the honest one: authorize the CAPABILITY ENVELOPE up front.
  approve:
    invoke:
      # blocking · no `default:` · a gate with a default is not a gate, and the
      # checker enforces both directions: add `default: false` here and this
      # file turns RED with NIKA-SEC-009, because a defaulted prompt dominates
      # nothing. Leaving it blocking costs one [headless-prompt] hint instead —
      # that hint is the price of a real gate, not a defect to paper over.
      # The run pauses (exit 4, not a failure) — answer and resume with
      #   nika run <file> --resume <trace> --answer approve=true
      tool: "nika:prompt"
      args:
        message: |
          This Monday brief will:
            · fetch public news from hn.algolia.com
            · run git in this repo
            · read ${{ inputs.kpi_sheet }}
            · write ./briefs/<date>-monday.md
            · ping the founders webhook (armed: ${{ inputs.alert }})

          Proceed? [yes/no]

  # ── branch 1 · market signal · the untrusted leg ──
  news:
    with:
      go: ${{ tasks.approve.output }}
    when: ${{ with.go == true }}
    invoke:
      tool: "nika:fetch"
      args:
        url: "https://hn.algolia.com/api/v1/search?query=${{ const.watch_query }}"
        mode: jq
        jq: ".hits[:10] | map(.title)"
    on_error:
      # The honest stand-in · when the fetch fails (no network, a failing
      # search) this literal takes over, so the join below is exercised on
      # both paths with the same binding. It is labelled in the brief so
      # nobody mistakes it for signal.
      recover: ["(stand-in · no market signal was fetched)"]

  # ── branch 2 · engineering pulse ──
  pulse:
    with:
      go: ${{ tasks.approve.output }}
    when: ${{ with.go == true }}
    exec:
      # Default capture (stdout), so a non-zero exit FAILS the task and the
      # recovery below is what handles it. The tempting alternative — `capture:
      # structured` — turns the exit code into data and the task reports success
      # whatever happened; that is only honest when something downstream reads
      # `exit_code`, and the checker flags the case where nothing does
      # ([swallowed-exit]). Here the failure is visible in the run (« 1
      # recovered ») and labelled in the brief, which is the same information
      # with none of the silence.
      command: ["git", "--no-pager", "shortlog", "-sn", "--since=1 week ago", "HEAD"]
    on_error:
      recover: "(no engineering pulse · git could not be read here)"

  # ── branch 3 · the numbers · the private leg ──
  sheet:
    with:
      go: ${{ tasks.approve.output }}
    when: ${{ with.go == true }}
    invoke:
      tool: "nika:read"
      args: { path: "${{ inputs.kpi_sheet }}" }

  rows:
    with:
      csv: ${{ tasks.sheet.output }}
    # A SKIPPED producer hands its consumer `null`, and the consumer runs anyway.
    # Measured: without this line a « no » at the gate reaches nika:convert with
    # nothing and the run FAILS (NIKA-BUILTIN-CONVERT-002) instead of landing
    # nothing — a refusal must be a quiet no-op, never an error. Every task
    # downstream of a gated one carries its own admission test.
    when: ${{ with.csv != null && size(with.csv) > 0 }}   # skipped read (null) or an empty sheet · nothing to parse
    invoke:
      tool: "nika:convert"
      args:
        input: "${{ with.csv }}"
        from: csv
        to: json
        has_header: true

  revenue:
    with:
      rows: ${{ tasks.rows.output }}
    when: ${{ with.rows != null && size(with.rows) > 0 }}   # zero parsed rows · nothing to summarize
    invoke:
      tool: "nika:jq"
      args:
        # CSV cells arrive as STRINGS whatever they look like, so `tonumber`
        # before `add`. Money is arithmetic, never a model's opinion of it.
        input: "${{ with.rows }}"
        expression: "map(.weekly_revenue | tonumber) | add"

  # ── the join · three branches land here, one call ──
  brief:
    with:
      go: ${{ tasks.approve.output }}
      # Every binding is SHALLOW (`.output`, never `.output.field`). Measured:
      # a skipped producer's `.output` reads as `null` and the join survives it,
      # while a deep field of the same skipped producer is NIKA-VAR-001 ·
      # unresolved template reference — bindings resolve before `when:` decides,
      # so a deep read into a « no » path kills the run the gate was meant to
      # spare. Reach one level, gate, then reach deeper downstream.
      news: ${{ tasks.news.output }}
      pulse: ${{ tasks.pulse.output }}
      rows: ${{ tasks.rows.output }}
      revenue: ${{ tasks.revenue.output }}
    when: ${{ with.go == true }}
    infer:
      # a reasoning model needs 16384 here, or a documented run.reasoning.effort: low
      max_tokens: 1200               # the cost report becomes a ceiling, not UNBOUNDED
      prompt: |
        Market signal · ${{ with.news }}
        Engineering pulse · ${{ with.pulse }}
        Weekly rows · ${{ with.rows }}
        Revenue, summed by the engine · ${{ with.revenue }}

        Write my Monday brief · 5 sections · market · product · numbers ·
        risks · the ONE decision this week needs.
      # No `thinking:` block on purpose: the seat law REFUSES a thinking
      # declaration on a model the catalog knows cannot reason (a dead
      # declaration — the wire drops the budget), and a budget ≥ the cap
      # is refused on ANY seat (the reasoning share lives inside
      # `max_tokens`). Seat `brief` on a reasoning-capable model via its
      # own `model:` and keep the budget under the cap — THAT is what
      # licenses `thinking: { enabled: true, budget_tokens: … }`.

  stamp:
    with:
      go: ${{ tasks.approve.output }}
    when: ${{ with.go == true }}
    invoke:
      tool: "nika:date"
      args: { op: now }
    extract:
      day: ".[:10]"                  # nika:date returns the ISO string itself · slice YYYY-MM-DD

  save:
    with:
      go: ${{ tasks.approve.output }}   # every effect re-reads the decision · a « no » lands nothing
      day: ${{ tasks.stamp.day }}
      brief: ${{ tasks.brief.output }}
    when: ${{ with.go == true }}
    invoke:
      tool: "nika:write"
      args:
        path: "./briefs/${{ with.day }}-monday.md"
        content: "${{ with.brief }}"
        create_dirs: true

  # ── the ping · a TASK, not a cleanup hook ──
  #
  # `after: {save: terminal}` admits all four settled states, so this fires
  # whether the brief landed, failed, or was skipped by a « no » at the gate.
  # It deliberately does not ride an `unwind` edge: cleanup errors are LOGGED
  # and DO NOT PROPAGATE (03 §unwind · best-effort lane), so a webhook that
  # dies there dies in silence — measured: an unresolved secret in a cleanup
  # task leaves the run green with nothing sent. An alert you cannot trust to
  # fail loudly is not an alert.
  alert:
    after:
      save: terminal
    with:
      armed: ${{ inputs.alert }}
      outcome: ${{ tasks.save.status }}   # observe WHAT happened · same pass-set as the after edge
      day: ${{ tasks.stamp.day }}
    when: ${{ with.armed == true }}       # OFF by default · a rehearsal touches no webhook
    invoke:
      tool: "nika:notify"
      args:
        channel: webhook
        target: "${{ secrets.founders_webhook }}"
        message: "Monday brief · ${{ with.outcome }} · briefs/${{ with.day }}-monday.md"
        severity: info

outputs:
  brief: ${{ tasks.brief.output }}
  revenue:
    value: ${{ tasks.revenue.output }}
    description: "Total weekly revenue, summed by jq — the number nobody guessed"
```

## How it works

**1. Three branches, zero coordination code**

News (HN API through `mode: jq`), engineering pulse (`git shortlog`)
and the KPI sheet (read → convert → jq `add`) run concurrently. The
revenue sum is jq arithmetic: deterministic, not model-guessed.

**2. Dates come from a builtin**

`nika:date` + an `extract:` slice (`day: ".[:10]"`) stamp the filename
`briefs/2026-06-15-monday.md`. Never let a model guess the date.

**3. One decision at the root**

`approve` is a `nika:prompt` with no `default:`, and every effect
re-reads its answer (`when: ${{ with.go == true }}`): a « no » fetches,
reads and writes nothing. The boundary permits all three legs of the
lethal trifecta, so the human decision sits where it governs every one
of them ([Security](https://docs.nika.sh/concepts/security.md)).

**4. The ping fires on every outcome**

`alert` rides `after: { save: terminal }` and reads
`${{ tasks.save.status }}`, so an armed ping reports a brief that
landed, failed or was declined. It uses `terminal` and not `unwind`:
a cleanup failure is only logged, and an alert that cannot fail loudly
is not an alert.

## Constructs you just used

| Construct | Where | Reference |
| - | - | - |
| 3-branch parallel gather | `news` · `pulse` · `sheet` | [Workflows](https://docs.nika.sh/concepts/workflows.md) |
| jq arithmetic (`add`) | `revenue` | [Builtins](https://docs.nika.sh/reference/builtins.md) |
| root human gate (`nika:prompt`) | `approve` | [Builtins](https://docs.nika.sh/reference/builtins.md) |
| `extract:` binding on a builtin | `stamp` | [Bindings](https://docs.nika.sh/concepts/bindings.md) |
| `after: { save: terminal }` | `alert` | [Workflows](https://docs.nika.sh/concepts/workflows.md) |

## Run it

> [!NOTE]
>
> **What it needs:** A local model ([Ollama](https://ollama.com) serving `qwen3.5:4b`), network access to `hn.algolia.com` for the market signal (offline, it recovers to a labelled stand-in), and the sample KPI sheet. The engineering pulse reads Git, which is refused on macOS in 0.124.3 ([Known limits](https://docs.nika.sh/changelog/known-limits.md#git-inside-a-workflow-is-refused-on-macos)).

**1. Rehearse it**

```bash theme={"system"}
nika try ceo-monday-brief
```

A mock model answers, the sample files come with it, and nothing is written in your folder. Its network fetches still go out: a rehearsal replaces the model, not the tools. Before it runs, `nika try` names those hosts: `may reach: hn.algolia.com · hooks.slack.com — the mock replaces the model, not the network`. It stops at the `approve` gate, as a real run does.

**2. Get your own copy**

Save the file above as `ceo-monday-brief.nika` in a new folder, then download the sample it reads:

```bash theme={"system"}
FIXTURES=https://raw.githubusercontent.com/supernovae-st/nika/v0.124.3/crates/nika-pack/pack/examples/fixtures
mkdir -p examples/fixtures
curl -fsSLo examples/fixtures/ceo-kpis.csv "$FIXTURES/ceo-kpis.csv"
```

**3. Check it, then run it**

```bash theme={"system"}
nika check ceo-monday-brief.nika
nika run ceo-monday-brief.nika --model mock/echo   # a mock model, no key
ollama pull qwen3.5:4b   # once, for the real run
nika run ceo-monday-brief.nika
```

The run writes `briefs/<date>-monday.md`.

It asks at the `approve` gate before anything else runs. On a terminal you answer; in a script it pauses (exit 4) and prints the `--resume` line that continues it, or you answer up front with `--answer approve=true`.

Any other model works: pass `--model <provider>/<name>` with its key, and cap a cloud model with `--max-cost-usd`.

The founders ping stays off unless you add `--var alert=true` with `FOUNDERS_WEBHOOK_URL` set; armed without it, the run fails at `alert` (`NIKA-VAR-001`).

## Make it yours

* Add a fourth branch: support sentiment from [Support triage](https://docs.nika.sh/examples/support-triage.md)'s board file.
* Keep a budget when you move the brief to a cloud model: run it with `--max-cost-usd`, and a run whose cost floor exceeds the cap refuses to start (`NIKA-1709`).
* Archive the history: the dated files under `briefs/` are already your decision journal.

> [card] [Back to all examples](https://docs.nika.sh/examples/overview.md)
>
> You've climbed the whole ladder, starter to epic. Time to write
> yours.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.