execution-helpers.mjs
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d
docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge
Human
20 hours ago
| 1 | /** |
| 2 | * Shared helpers for Flow execution gate tiers (7A-L3b). |
| 3 | */ |
| 4 | import fs from 'node:fs'; |
| 5 | import path from 'node:path'; |
| 6 | |
| 7 | import { upsertFlowVersion } from '../../../lib/flow/flow-store.mjs'; |
| 8 | import { |
| 9 | FLOW_EXECUTION_POLICY_FILE, |
| 10 | makeAutomatableFlowBundle, |
| 11 | } from '../../../lib/flow/flow-execution.mjs'; |
| 12 | |
| 13 | /** |
| 14 | * @param {string} dataDir |
| 15 | * @param {{ runWrites?: boolean, automatable?: boolean, automatableForbidden?: boolean, lanes?: string[], costCap?: number }} [opts] |
| 16 | */ |
| 17 | export function writeExecutionPolicy(dataDir, opts = {}) { |
| 18 | const fp = path.join(dataDir, FLOW_EXECUTION_POLICY_FILE); |
| 19 | fs.writeFileSync( |
| 20 | fp, |
| 21 | JSON.stringify({ |
| 22 | flow_run_writes_enabled: opts.runWrites ?? true, |
| 23 | execution: { |
| 24 | automatable_enabled: opts.automatable ?? true, |
| 25 | allowed_lanes: opts.lanes ?? ['local_default'], |
| 26 | automatable_forbidden: opts.automatableForbidden ?? false, |
| 27 | default_cost_cap_units: opts.costCap ?? 100, |
| 28 | default_ttl_seconds: 3600, |
| 29 | max_ttl_seconds: 86400, |
| 30 | }, |
| 31 | }), |
| 32 | 'utf8', |
| 33 | ); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Seed an automatable test flow into the vault store. |
| 38 | * |
| 39 | * @param {string} dataDir |
| 40 | * @param {string} vaultId |
| 41 | * @param {string} [flowId] |
| 42 | */ |
| 43 | export function seedAutomatableFlow(dataDir, vaultId, flowId = 'flow_automatable_test') { |
| 44 | const bundle = makeAutomatableFlowBundle(undefined, flowId); |
| 45 | upsertFlowVersion(dataDir, vaultId, bundle.flow, bundle.steps); |
| 46 | return bundle; |
| 47 | } |
File History
1 commit
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d
docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge
Human
20 hours ago