patchwork-os 1.2.0-beta.2.canary.838 → 1.2.0-beta.2.canary.840
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/recipe.d.ts +5 -0
- package/dist/commands/recipe.js +11 -0
- package/dist/commands/recipe.js.map +1 -1
- package/dist/recipeOrchestration.js +17 -16
- package/dist/recipeOrchestration.js.map +1 -1
- package/dist/recipes/chainedRunner.js +2 -0
- package/dist/recipes/chainedRunner.js.map +1 -1
- package/dist/recipes/replayBoundary.d.ts +15 -0
- package/dist/recipes/replayBoundary.js +21 -0
- package/dist/recipes/replayBoundary.js.map +1 -1
- package/dist/recipes/yamlRunner.d.ts +12 -1
- package/dist/recipes/yamlRunner.js +48 -11
- package/dist/recipes/yamlRunner.js.map +1 -1
- package/dist/runLog.d.ts +23 -0
- package/dist/runLog.js +18 -0
- package/dist/runLog.js.map +1 -1
- package/dist/workers/runWorkerShadow.js +8 -2
- package/dist/workers/runWorkerShadow.js.map +1 -1
- package/package.json +1 -1
|
@@ -67,7 +67,7 @@ import { resolveLocalEndpoint, resolveLocalModel } from "./localSettings.js";
|
|
|
67
67
|
import { defaultDeprecationWarn, normalizeRecipeForRuntime, } from "./migrations/index.js";
|
|
68
68
|
import { costRouter } from "./pricing/costRouter.js";
|
|
69
69
|
import { loadPriceTable, costUsd as priceCostUsd, } from "./pricing/priceTable.js";
|
|
70
|
-
import { ReplayIncompleteError, } from "./replayBoundary.js";
|
|
70
|
+
import { ReplayIncompleteError, TestModeRefusalError, } from "./replayBoundary.js";
|
|
71
71
|
import { resolveRecipePath } from "./resolveRecipePath.js";
|
|
72
72
|
import { RunBudget } from "./runBudget.js";
|
|
73
73
|
import { recordAttemptRun } from "./runLedgers.js";
|
|
@@ -821,6 +821,8 @@ export async function runYamlRecipe(recipe, deps = {}, seedContext = {}) {
|
|
|
821
821
|
...(deps.manualRunId !== undefined && {
|
|
822
822
|
manualRunId: deps.manualRunId,
|
|
823
823
|
}),
|
|
824
|
+
// Marks the row so trust replay never folds it (runLog isReplayRun).
|
|
825
|
+
...(deps.replayOnly === true && { replay: true }),
|
|
824
826
|
});
|
|
825
827
|
}
|
|
826
828
|
catch {
|
|
@@ -2554,6 +2556,17 @@ export async function runYamlRecipe(recipe, deps = {}, seedContext = {}) {
|
|
|
2554
2556
|
})(),
|
|
2555
2557
|
};
|
|
2556
2558
|
}
|
|
2559
|
+
/**
|
|
2560
|
+
* Tools `recipe test` may run without a fixture: reads whose only effect goes
|
|
2561
|
+
* through a dep `runTest` stubs (`readFile`, `gitLogSince`,
|
|
2562
|
+
* `gitStaleBranches`, `getDiagnostics`). Everything else needs a mock.
|
|
2563
|
+
*/
|
|
2564
|
+
const TEST_STUBBED_TOOLS = new Set([
|
|
2565
|
+
"file.read",
|
|
2566
|
+
"git.log_since",
|
|
2567
|
+
"git.stale_branches",
|
|
2568
|
+
"diagnostics.get",
|
|
2569
|
+
]);
|
|
2557
2570
|
export async function executeStep(step, ctx, deps, approvalEvidence, approvalDispatch,
|
|
2558
2571
|
/** Rollbackability the authority decision was made on (INV-1). */
|
|
2559
2572
|
rollbackAtDecision) {
|
|
@@ -2570,6 +2583,14 @@ rollbackAtDecision) {
|
|
|
2570
2583
|
if (deps.replayOnly === true) {
|
|
2571
2584
|
throw new ReplayIncompleteError([step.into ?? toolId], `tool ${toolId}`);
|
|
2572
2585
|
}
|
|
2586
|
+
// `recipe test` boundary: only a mocked tool, or a read tool served wholly
|
|
2587
|
+
// by injected stub deps, may run. Checked before the registry lookup for the
|
|
2588
|
+
// same reason as replay: a missing fixture must never become a live call.
|
|
2589
|
+
if (deps.testOnly === true &&
|
|
2590
|
+
!deps.mockConnectors?.[toolId] &&
|
|
2591
|
+
!TEST_STUBBED_TOOLS.has(toolId)) {
|
|
2592
|
+
throw new TestModeRefusalError([step.into ?? toolId], `tool ${toolId}`);
|
|
2593
|
+
}
|
|
2573
2594
|
// Check if tool is registered in the new registry
|
|
2574
2595
|
if (hasTool(toolId)) {
|
|
2575
2596
|
const tool = getTool(toolId);
|
|
@@ -2966,6 +2987,12 @@ function refuseLiveModel(which) {
|
|
|
2966
2987
|
"(claudeFn / localFn / claudeCodeFn) in the runner deps. " +
|
|
2967
2988
|
"If the live call is the point, set PATCHWORK_TEST_ALLOW_LIVE=1 for that test.");
|
|
2968
2989
|
}
|
|
2990
|
+
/** An agent driver fn that refuses: `recipe test` never reaches a live model. */
|
|
2991
|
+
function refuseInTest(which) {
|
|
2992
|
+
return async () => {
|
|
2993
|
+
throw new TestModeRefusalError(["agent"], `agent driver ${which}`);
|
|
2994
|
+
};
|
|
2995
|
+
}
|
|
2969
2996
|
function resolveStepDeps(deps, scope) {
|
|
2970
2997
|
const workdir = deps.workdir ?? process.cwd();
|
|
2971
2998
|
// Defense-in-depth: even if a file.* tool somehow forgets to call
|
|
@@ -3007,18 +3034,27 @@ function resolveStepDeps(deps, scope) {
|
|
|
3007
3034
|
})),
|
|
3008
3035
|
fetchFn: deps.fetchFn ?? globalThis.fetch,
|
|
3009
3036
|
claudeFn: deps.claudeFn ??
|
|
3010
|
-
(
|
|
3011
|
-
? (
|
|
3012
|
-
:
|
|
3037
|
+
(deps.testOnly === true
|
|
3038
|
+
? refuseInTest("claude (Anthropic API)")
|
|
3039
|
+
: liveModelGuardActive() && process.env.ANTHROPIC_API_KEY
|
|
3040
|
+
? () => refuseLiveModel("defaultClaudeFn (Anthropic API)")
|
|
3041
|
+
: defaultClaudeFn),
|
|
3013
3042
|
claudeCodeFn: deps.claudeCodeFn ??
|
|
3014
|
-
(
|
|
3015
|
-
? (
|
|
3016
|
-
:
|
|
3043
|
+
(deps.testOnly === true
|
|
3044
|
+
? refuseInTest("claude-code (CLI subprocess)")
|
|
3045
|
+
: liveModelGuardActive()
|
|
3046
|
+
? () => refuseLiveModel("defaultClaudeCodeFn (claude CLI subprocess)")
|
|
3047
|
+
: defaultClaudeCodeFn),
|
|
3017
3048
|
localFn: deps.localFn ??
|
|
3018
|
-
(
|
|
3019
|
-
? (
|
|
3020
|
-
:
|
|
3021
|
-
|
|
3049
|
+
(deps.testOnly === true
|
|
3050
|
+
? refuseInTest("local (LOCAL_ENDPOINT)")
|
|
3051
|
+
: liveModelGuardActive()
|
|
3052
|
+
? () => refuseLiveModel("defaultLocalFn (LOCAL_ENDPOINT)")
|
|
3053
|
+
: defaultLocalFn),
|
|
3054
|
+
providerDriverFn: deps.providerDriverFn ??
|
|
3055
|
+
(deps.testOnly === true
|
|
3056
|
+
? refuseInTest("provider driver")
|
|
3057
|
+
: makeProviderDriverFn()),
|
|
3022
3058
|
mockConnectors: deps.mockConnectors ?? {},
|
|
3023
3059
|
recordFixturesDir: deps.recordFixturesDir,
|
|
3024
3060
|
allowWrites: deps.allowWrites ?? [],
|
|
@@ -3054,6 +3090,7 @@ function resolveStepDeps(deps, scope) {
|
|
|
3054
3090
|
// (`executeStep`, `buildAgentExecutorDeps`) can refuse without the run
|
|
3055
3091
|
// loop's help. Only ever set by the replay entrypoints.
|
|
3056
3092
|
...(deps.replayOnly === true && { replayOnly: true }),
|
|
3093
|
+
...(deps.testOnly === true && { testOnly: true }),
|
|
3057
3094
|
// Ephemeral rollback — same disk-availability gating as writeEffectLedger
|
|
3058
3095
|
// above (deliberately: both share the operator's --ledger-dir/--attempt
|
|
3059
3096
|
// inputs). No in-memory fallback: rollback only makes sense as a
|