Skip to content

Journal: durable run-journal + stall detector so the loop switches strategy instead of oscillating #66

Description

@wesleysimplicio

Parent epic: #64

Goal

Port simplicio-loop's run journal (scripts/loop_journal.py) to the piece pipeline: durable attempt memory per piece/campaign plus a stall detector, so when a piece keeps failing the same gate the loop changes strategy (new hook/angle, different provider via the routing matrix, different format, or escalate to human) instead of regenerating the same failing output forever.

Scope

  • Append-only journal per piece (e.g. outputs/<client>/<date>/<piece-id>/journal.jsonl): attempt number, stage (copy/creative/critic/compliance/watcher-gate/tech-specs), gate result, failure signature, strategy used, provider resolved, cost estimate.
  • Stall detection: N consecutive failures on the same gate with the same failure signature → the loop must not retry the same strategy; it must pick an untried one from a strategy ladder or route the piece to review with the journal attached.
  • Strategy ladder is declarative (e.g. rewrite-hook → change-format → change-provider → human-review) and provider-agnostic — switches go through lib/router.ts, never name a vendor.
  • Journal feeds data/runs.jsonl aggregation and the learnings lane (Analytics: score organic performance across social, Reddit, forums, and dev portals #54 replay, lib/promotion/learnings.ts).

Acceptance criteria

  • E2E test: a mocked piece failing compliance 3× with the same violation triggers a strategy switch (visible in the journal) instead of a 4th identical retry.
  • E2E test: exhausted ladder routes the piece to human review with blocked status — never silently drops it or fake-passes.
  • Journal survives process restart (durable on disk, resume picks up attempt count).
  • selftest covers signature hashing and stall threshold logic.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions