fix: auto-approve phase 3 rewrite

This commit is contained in:
User
2026-07-14 13:51:39 +02:00
parent c7d586aaf7
commit 1b1554b353
5 changed files with 169 additions and 13 deletions
@@ -0,0 +1,44 @@
# F3 Rewrite Auto-Approval Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Remove the F3 reviewer confirmation while preserving the persisted rewrite and normal phase transition.
**Architecture:** `rewrite_question` owns the ordered document write, decision recording, and phase advance. The F3 skill calls it once, without a reviewer widget.
**Tech Stack:** JavaScript Pi extension, Python `tht` CLI, Node test runner, pytest.
## Global Constraints
- Preserve the eight phase numbers, `question.md`, and `question_rewritten` ledger type.
- Never write decisions or advance phases outside F3.
- Use `tht` commands with `--session` after the command group.
---
### Task 1: Test and implement automatic F3 completion
**Files:**
- Modify: `harness/.pi/extensions/tht-gate.js`
- Test: `harness/.pi/extensions/gate/__tests__/gate_rewrite_auto_approval.test.js`
- [ ] Add a fake Pi integration test that invokes the registered `rewrite_question` tool at F3 and asserts these calls in order: `session set-question`, `decision add question_rewritten`, `phase advance`.
- [ ] Run `cd harness && npm test -- --test-name-pattern="rewrite question"` and observe failure because the current tool only writes the document.
- [ ] Make `rewrite_question` reject non-F3 sessions, record the decision after a successful write, advance after a successful decision, and return a no-widget completion message.
- [ ] Re-run the focused test and then `cd harness && npm test`.
### Task 2: Remove the F3 reviewer instruction
**Files:**
- Modify: `harness/.pi/skills/tht-sessione/SKILL.md`
- [ ] Replace the F3 `reviewer_decide` and `reviewer_confirm` procedure with one direct `rewrite_question` call and an explicit prohibition on reviewer widgets.
### Task 3: Verify workflow compatibility
**Files:**
- Test: `harness/tests/test_workflow.py`
- Test: `harness/tests/test_phase_effective.py`
- [ ] Run `cd harness && .venv/bin/pytest -q tests/test_workflow.py tests/test_phase_effective.py`.
- [ ] Run `cd harness && .venv/bin/pytest -q`.
@@ -0,0 +1,15 @@
# F3 Rewrite Auto-Approval Design
## Goal
Remove the redundant human confirmation titled "Conferma riscrittura della domanda" while retaining Phase 3, its deterministic `question.md` artifact, and its audit trail.
## Design
The existing privileged `rewrite_question` tool becomes the owner of F3 completion. It writes `question.md`, records `question_rewritten` with the full rewritten question, then advances F3. It refuses calls outside F3. The orchestration skill calls this tool directly and must not emit `reviewer_decide` or `reviewer_confirm` in F3.
If the write fails, it records nothing. If decision recording fails, it does not advance. If the advance fails, the persisted artifact and decision remain for a safe retry. Phase numbers, workflow YAML, artifact paths, decision type, and old sessions remain compatible.
## Tests
Gate coverage will verify ordered CLI calls and F3-only protection. The existing Python phase tests will verify the unchanged workflow invariant.