fix(sf): guard auto-loop against missing DB and missing basePath
Two small defensive fixes in the auto-loop that surfaced when running sf in degraded environments (no .sf/sf.db yet, or unset basePath): - phases.ts: gate planning-flow gate behind isDbAvailable() so a missing or not-yet-initialized DB does not throw inside the gate runner. - run-unit.ts: skip process.chdir when s.basePath is falsy. The original guard compared cwd to an empty string, which always failed on the first unit of a fresh runtime root. Both are conservative — preserve existing behaviour when DB and basePath are present.
This commit is contained in:
parent
082526c0e4
commit
e6a2ec0a8f
2 changed files with 2 additions and 2 deletions
|
|
@ -596,7 +596,7 @@ export async function runPreDispatch(
|
|||
|
||||
// Derive state
|
||||
let state = await deps.deriveState(s.basePath);
|
||||
if (uokFlags.planningFlow && shouldRunPlanningFlowGate(state.phase)) {
|
||||
if (uokFlags.planningFlow && isDbAvailable() && shouldRunPlanningFlowGate(state.phase)) {
|
||||
let compiled = ensurePlanningFlowGraph(s.basePath, state);
|
||||
// Empty-graph recovery: stale DB caches can yield 0 nodes right after a
|
||||
// task-complete write. Invalidate caches, re-derive state, and retry once.
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ export async function runUnit(
|
|||
// wrong directory. Must be synchronous — no awaits between chdir and
|
||||
// newSession (#1389, #4762 follow-up).
|
||||
try {
|
||||
if (process.cwd() !== s.basePath) {
|
||||
if (s.basePath && process.cwd() !== s.basePath) {
|
||||
process.chdir(s.basePath);
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue