Files
ThothII/harness/.pi/extensions/gate/__tests__/gate_entry.test.js
T
marcopanandClaude Sonnet 4.6 c55df2ad0f fix(harness): gate kickoff/lock entry works in RPC mode (not only interactive)
- Removed event.source === "interactive" guard from entry detection so
  /nuova-domanda and /riprendi-sessione activate lockActive+pendingKickoff
  regardless of source (TUI or RPC prompt).
- Removed event.source !== "interactive" from free-input filter; lock now
  blocks/steers all user input when active, not only interactive keystrokes.
- Added typebox@1.1.38 devDep + fake_pi_runtime.registerCommand (gap from Task 2).
- New test: gate_entry.test.js (2 tests: lock activates on RPC; !-steer passes).
- Full suite: 19/19 pass, zero regressions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-27 19:57:38 +02:00

28 lines
1.3 KiB
JavaScript

const test = require("node:test");
const assert = require("node:assert");
const { createFakePi } = require("./fake_pi_runtime.js");
// The gate is ESM; resolve it once via dynamic import (Global Constraints: use await import()
// if require() of ESM misbehaves on this Node version).
const installGatePromise = import("../../tht-gate.js").then((m) => m.default);
test("avvio workflow via input non-interattivo attiva il lock (free text bloccato)", async () => {
const installGate = await installGatePromise;
const { pi } = createFakePi();
installGate(pi);
// entry del workflow con source 'rpc' (come un comando prompt RPC)
await pi.emit("input", { source: "rpc", text: '/nuova-domanda "x"' });
// dopo l'entry, un testo libero senza '!' deve essere bloccato (lock attivo)
const res = await pi.emit("input", { source: "rpc", text: "promuovi la tabella pazienti" });
assert.equal(res.action, "handled");
});
test("testo con '!' passa al modello (steer) anche con lock attivo", async () => {
const installGate = await installGatePromise;
const { pi } = createFakePi();
installGate(pi);
await pi.emit("input", { source: "rpc", text: '/nuova-domanda "x"' });
const res = await pi.emit("input", { source: "rpc", text: "!considera solo il 2024" });
assert.deepEqual(res, { action: "transform", text: "considera solo il 2024" });
});