LEVEL 3 · ENGINEER

Self-Correcting Workflow Hooks

Turn repeated, sourced corrections into scoped rules, persist them atomically, and enforce only explicitly approved rules.

4 stages~8 hoursTypeScriptcore
Capture corrections with provenanceCount independent sessionsApprove and select scoped rulesPersist rules across sessions
YOU END UP WITH

A correction ledger showing why a rule exists, what it changed and how to undo it.

USEFUL FOR
  • A correction ledger showing why a rule exists, what it changed and how to undo it.
  • capture, inspect, approve, retire and emit are file-based commands.
PROJECT OUTLINE

Self-Correcting Workflow Hooks in 4 stages

Turn repeated, sourced corrections into scoped rules, persist them atomically, and enforce only explicitly approved rules.

  1. Capture corrections with provenance

    Preserve case-sensitive rule text and source excerpts with stable locators.

    starter · ~2 hours · TypeScript

    normalizeingest
  2. Count independent sessions

    Group by scope and rule text with whitespace collapsed and case preserved. Deduplicate event ids and reject a reused id with different content. Count unique sessions rather than event count, so repeated hook delivery cannot promote a rule. Keep every source id attached to the candidate and sort the final output for reproducible files.

    core · ~2 hours · TypeScript

    consolidate
  3. Approve and select scoped rules

    Require independent-session support before an explicit approval transition. Retired rules cannot be silently resurrected. At hook time, include only approved rules matching the current scope or global scope. Return source ids with injected rule text so the user can trace where persistent guidance came from.

    core · ~2 hours · TypeScript

    transitionhook
  4. Persist rules across sessions

    Write a versioned JSON snapshot to a unique sibling temporary file with owner-only permissions, then rename it into place. Readers see the old or new complete file. Missing storage means an empty collection, while malformed storage is an error. This snapshot store supports one writer process; cross-process merge and locking are a separate extension.

    core · ~2 hours · TypeScript

    saveload

Lessons this project uses

All projects · Course catalog · Source on GitHub