Skip to content

feat(redirect): arc→rule promotion pipeline — failures graduate into deny-mode redirect gates - #107

Merged
mahmoudimus merged 2 commits into
mainfrom
feat/arc-rule-promotion
Jul 20, 2026
Merged

mahmoudimus merged 2 commits into
mainfrom
feat/arc-rule-promotion

Conversation

@mahmoudimus

Copy link
Copy Markdown
Owner

Completes the loop designed with the user 2026-07-20: the distiller's failure→fix arcs (#104) graduate into redirect rules through a deterministic, LLM-free promotion pipeline with a human approval valve.

  • Classifiers (redirect/arc_promotion.py): flag-drop (incl. combined-short-flag subsequence, -rn→-n), token-replace (--summarize→-summary), prefix-insert (python3 …→uv run python …). Rejects operand changes, multi-token diffs, shlex failures, contradicted signatures (two different fixes for one failure = context-dependent).
  • Evidence gates: hooks.arc_promotion_min_evidence (default 3) summed repeat_count OR ≥2 distinct sessions per signature.
  • Pending-candidates table (rule_candidate peewee sidecar): idempotent rescans, rejected-stays-rejected.
  • simba rule promote review CLI: diff-style before→after, evidence (×7 across 3 sessions), derived rule + scope; approve writes a deny-mode rule to the redirect DB store and prints the graduation command; --reject; --json. simba rule scan-arcs + fail-soft auto-scan after simba transcript distill. SessionStart inbox line when candidates are pending.
  • Safety verified end-to-end: an approved rule's own mode="deny" wins over any global rewrite mode — auto-created rules structurally cannot silently rewrite. Never touches .simba/redirects.toml (human-owned).
  • Store gains additive pattern/rewrite/mode columns (guarded migration) + simba rule redirect add --mode.

TDD red-first: 51 new tests (29 classifier/pipeline, 17 CLI, 3 inbox, 2 distill-integration). Full suite green on the branch merged with current main (#105-#106), ruff + format clean. Merge commit resolves the projection-lint allowlist conflict empirically (site at 4069 in the combined tree; verified by running the lint).

Mines the transcript distiller's failure->fix arcs (failure_arc table) for
purely mechanical, token-level shell-command fixes -- flag-drop, token-replace,
prefix-insert -- and turns eligible ones into candidate redirect rules for
human review, never auto-applied.

- redirect/arc_promotion.py: deterministic, LLM-free classifier + evidence/
  contradiction aggregation + `simba rule scan-arcs` DB orchestration.
- redirect/candidates.py: rule_candidate sidecar table (pending/approved/
  rejected), idempotent upsert-by-signature.
- redirect/store.py: additive pattern/rewrite/mode columns on redirect_rules
  (migrated for pre-existing DBs), add_pattern(), mode-aware add().
- __main__.py: `simba rule scan-arcs`, `simba rule promote [<id> [--reject]]
  [--json]`, `simba rule redirect add --mode`; distill CLI triggers a
  fail-soft scan after arc upserts.
- hooks/session_start.py: pending-rule-candidate inbox line (local-only,
  survives daemon being down).
- Approval always writes DENY mode; no bulk-approve path.
Conflict: the projection lint's line-number allowlist — both sides had
shifted the same __main__.py entry. Resolved empirically: the merged
tree's call site is at 4069 (#105's +17 on top of this branch's own
insertions); verified by running the lint.
@mahmoudimus
mahmoudimus merged commit aa42959 into main Jul 20, 2026
1 check passed
@mahmoudimus
mahmoudimus deleted the feat/arc-rule-promotion branch July 20, 2026 21:16
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