refactor(workflow): contract shared core (#33)

This commit is contained in:
2026-08-24 03:12:00 +02:00
parent f375515dc0
commit 36a7a0ab33
19 changed files with 173 additions and 29 deletions
+17 -10
View File
@@ -6,7 +6,7 @@
// the reference implementation PHASE_NAMES array (truncated to 7) is gone; F8/datamart can no
// longer drift out of sync.
// (2) D2/D4 widget-descriptor: the reviewer interaction is emitted as a
// widget-descriptor JSON (built by ./gate/builders.js) and awaited by id, instead
// widget-descriptor JSON (built by ./gate/core/builders.js) and awaited by id, instead
// of rendered by blocking native TUI primitives (ctx.ui.select/custom).
//
// PRESERVED VERBATIM from the source (load-bearing runtime glue, spec D4):
@@ -30,12 +30,12 @@ import {
buildArtifactGate,
buildSchemaLinkingRequest,
buildJoinReviewRequest,
} from "./gate/builders.js";
} from "./gate/core/builders.js";
import {
validateCtePlanV2,
validateCteResultThin,
validatePhaseSummaryV2,
} from "./gate/artifact-contracts.js";
} from "./gate/core/artifact-contracts.js";
import {
memoizeGetColumns,
enrichCtePlanV2,
@@ -43,10 +43,14 @@ import {
enrichCteResultColumns,
enrichPhaseSummaryV2,
appendLedgerSection,
} from "./gate/enrich.js";
} from "./gate/core/enrich.js";
import { createMemoryGate } from "./gate/memory/index.js";
import { createDisambiguationGate } from "./gate/disambiguation/index.js";
import { isReserved } from "./reserved-labels.mjs";
import {
createDisambiguationGate,
EMPTY_SESSION_CLARIFICATION_KICKOFF,
NEW_SESSION_CLARIFICATION_KICKOFF,
} from "./gate/disambiguation/index.js";
import { isReserved } from "./gate/core/reserved-labels.mjs";
// Load the workflow contract once when Pi loads the extension. Asking the model to
// discover/read the skill as its first action proved unreliable with remote models:
@@ -204,9 +208,7 @@ const NUOVA_DOMANDA_KICKOFF_PROVIDED = (sessionId, hasRetrievalPack = false) =>
: "1. Il retrieval pack non era ancora disponibile: come PRIMA chiamata tool esegui " +
"subito `tht search pack \"<domanda originale nel messaggio utente>\" --session " +
sessionId + "` e usa il risultato.\n") +
"2. Nel primo turno identifica la SOLA ambiguità con maggiore impatto sulla query e " +
"chiama subito `reviewer_select` con opzioni concrete. Niente lunga narrazione, elenco " +
"di tutte le ambiguità o ricapitolazione preliminare.\n" +
NEW_SESSION_CLARIFICATION_KICKOFF +
"Regole non negoziabili: una domanda al reviewer per volta; mai promuovere/escludere/" +
"correggere senza conferma; le interazioni passano dai tool reviewer_*; testo libero col prefisso '!'. " +
"MAI `tht phase advance|reopen` né `tht decision add` da shell.";
@@ -225,7 +227,8 @@ const RIPRENDI_KICKOFF = (hasRetrievalPack = false) =>
"cio' che non e' registrato non e' avvenuto) e riprendi da li'.\n" +
"Esegui il passo 1 ORA, in QUESTO stesso turno, chiamando subito il tool `bash` per " +
"`tht session show`: NON limitarti a dichiarare l'intenzione e NON " +
"terminare il turno prima di aver chiamato i tool. Se la sessione e' in fase 1 e non ha decisioni, dopo `session show` chiama `reviewer_select` subito: non produrre testo libero.\n" +
"terminare il turno prima di aver chiamato i tool. " +
EMPTY_SESSION_CLARIFICATION_KICKOFF +
"Valgono le stesse regole non negoziabili: una domanda per volta, conferma esplicita, tool " +
"reviewer_*, niente phase advance/reopen o decision add da shell, una fase alla volta.";
@@ -617,6 +620,10 @@ export default function (pi) {
ctx, decisionAddArgs(session, decision), recovery,
),
},
reviewer: {
buildMultiselect: buildMultiselectRequest,
isReserved,
},
waitForReviewer: emitAndWait,
toTextResult: textResult,
});