GUI: ask for the longer wait only when all three of a Control's ceilings agree (#3459 #4191)

The app's ceiling probe read one file. The second symptom of this branch - `direct runtime intent has an invalid timeout`,
on a build whose CLI validator was already fixed - is the reason it now reads the operation record too: a start wait is
bounded by management, by the record written before the start runs, and by the runtime, and a Control can raise any of
the three on its own. The app asks for more than 600 s only when a Control's own sources hand both of the first two to
the runtime's ceiling, so a half-raised Control keeps the wait it will accept instead of failing the load. Anything the
app cannot read, or a line that still spells out 600, keeps today's 600 s.

Checked against the Control folders on this PC and against the released sources in git: v0.2.5 and v0.2.7 both carry
`MAX_START_WAIT = 1800` with both gates at 600, so the app asks them for 600 s - which is what they take; the patched
tree and the staged 0.1.52 component ask 1720 s for a 180 GB model; the installed 0.1.49.2 component asks 600 s. The
marker for the record is `"wait_s": (` rather than `wait_s`, because the record names that key in its field lists long
before its range table, and the first match there would have pinned the app to 600 s forever.

The packaged test drives the four Control shapes (nothing, runtime only, CLI only, all three) so each half-raised
combination is a case, not a guess.
This commit is contained in:
Mike authored and Niko1221 committed 2026-10-28 23:33:57 +01:00
1 parent 293044e561
commit 3e1141edf0
2 files changed
+33 -17

No files matched your search

+20 -11
View File
@@ -223,24 +223,33 @@ return {summary:result.summary??'Deleted',removed:result.plan?.gb??null};}
const DS_EXPERTS_MIN=[0,1,50];
function dsEngineVersion(config){const m=/engine-dsv41[\\/](\d+(?:\.\d+)+)-/.exec(String(config?.exe??''))||/engine-dsv41[\\/](\d+(?:\.\d+)+)-/.exec(String((config?.lib_dirs??[])[0]??''));return m?m[1].split('.').map(Number):null;}
function dsExpertsSupported(config){const v=dsEngineVersion(config);if(!v)return false;for(let i=0;i<DS_EXPERTS_MIN.length;i++){const a=v[i]??0,b=DS_EXPERTS_MIN[i];if(a!==b)return a>b;}return true;}
/* Control's ceiling for one start wait, read from the Control this app actually found rather than guessed from its version: the owner
runtime takes MAX_START_WAIT (#3949), but `strata runtime start --wait` - the command the app starts a model with - validates the
wait itself, and that validator was left at 600 s by the same change (the app says `start wait must be finite seconds in 0..600`).
A wait above what that file accepts is refused before anything loads, so the app asks for the ceiling of the Control it has and
keeps today's 600 s whenever it cannot read one. Reading the installed Control to learn what it supports is what the field list
and the /v1/responses capability already do; here it reads Control's own validator instead of the server. */
/* Control's ceiling for one start wait, read from the Control this app actually found rather than guessed from its version. The
app starts a model with `strata runtime start --wait`, and that wait is checked three times before the engine is reached: by
management.runtime_action, by the operation record written before the start (journal), and by runtime.start itself. 27cbbfe6
raised only the runtime's, so a longer wait died with `start wait must be finite seconds in 0..600` and then with
`direct runtime intent has an invalid timeout`. The app therefore asks for the longer wait only when a Control's own sources
say all three agree, and keeps today's 600 s whenever one of them still names a ceiling of its own. Reading the installed
Control to learn what it supports is what the field list and the /v1/responses capability already do. */
const START_WAIT_CEILING=600;
let ceilingCache={dir:'',time:0,value:START_WAIT_CEILING};
function followsRuntimeCeiling(text,marker){
/* The marker picks the one line that bounds the wait (`"wait_s": (` in the record's range table, `"start wait"` in the CLI
validator), because both files name those keys elsewhere. A line that still spells out 600 is a ceiling of its own. */
const line=(String(text).split(/\r?\n/).find(l=>l.includes(marker))??'');
return /runtime\.MAX_START_WAIT|start_wait_max/.test(line)&&!/\b600\b/.test(line);
}
function startWaitCeiling(){
const dir=control?.control?.dir??'';if(!dir)return START_WAIT_CEILING;
let time=0;const file=join(dir,'strata_control','management.py');
try{time=statSync(file).mtimeMs;}catch{return START_WAIT_CEILING;}
const files=['management.py','journal.py','runtime.py'].map(name=>join(dir,'strata_control',name));
let time=0;
try{time=Math.max(...files.map(f=>statSync(f).mtimeMs));}catch{return START_WAIT_CEILING;}
if(ceilingCache.dir===dir&&ceilingCache.time===time)return ceilingCache.value;
let value=START_WAIT_CEILING;
try{
const line=(readFileSync(file,'utf8').split(/\r?\n/).find(l=>l.includes('"start wait"'))??'');
if(/runtime\.MAX_START_WAIT/.test(line)){ // a Control whose CLI takes the runtime's own ceiling, whatever it is
const declared=Number(readFileSync(join(dir,'strata_control','runtime.py'),'utf8').match(/^MAX_START_WAIT\s*=\s*(\d+)/m)?.[1]);
const [management,journal]=files.slice(0,2).map(f=>readFileSync(f,'utf8'));
// both gates must hand the ceiling to the runtime, or the wait would be refused on the way to it
if(followsRuntimeCeiling(management,'"start wait"')&&followsRuntimeCeiling(journal,'"wait_s": (')){
const declared=Number(readFileSync(files[2],'utf8').match(/^MAX_START_WAIT\s*=\s*(\d+)/m)?.[1]);
if(Number.isFinite(declared)&&declared>value)value=declared;
}
}catch{value=START_WAIT_CEILING;}
+13 -6
View File
@@ -92,16 +92,22 @@ function packagedFixture({ engineUsable = true, updater = null, repair = false,
const root = mkdtempSync(join(tmpdir(), 'strata-packaged-test-'));
const install = join(root, 'install'), data = join(root, 'data');
mkdirSync(install, { recursive: true });
/* The Control this app found, as it is on disk: the app reads the start-wait ceiling out of these two files instead of
trusting the version, because the released Control validates the wait twice and the two numbers can disagree.
'old': no runtime ceiling at all, CLI takes 600. 'split': the runtime takes 1800 but the CLI still stops at 600
(what every Control up to 0.1.52 ships). 'runtime': the CLI follows the runtime's own ceiling. */
/* The Control this app found, as it is on disk. The app reads the start-wait ceiling out of these files instead of trusting
the version, because a start wait is checked three times before the engine is reached and a released Control has those
three ceilings disagreeing:
'old' no runtime ceiling at all, both gates 600 (Control before #3949)
'split' the runtime takes 1800, the CLI and the record still stop at 600 (every Control 0.1.50 to 0.1.52)
'cli-only' the CLI follows the runtime, the record still stops at 600 (`direct runtime intent has an invalid timeout`)
'runtime' all three hand the wait to the runtime's own ceiling */
const controlSource = join(root, 'control', 'strata_control');
mkdirSync(controlSource, { recursive: true });
writeFileSync(join(controlSource, 'runtime.py'), cliStartWait === 'old' ? '' : 'MAX_START_WAIT = 1800\n');
writeFileSync(join(controlSource, 'management.py'), cliStartWait === 'runtime'
writeFileSync(join(controlSource, 'management.py'), ['cli-only', 'runtime'].includes(cliStartWait)
? ' wait = _seconds(wait, 0, runtime.MAX_START_WAIT, "start wait")\n'
: ' wait = _seconds(wait, 0, 600, "start wait")\n');
writeFileSync(join(controlSource, 'journal.py'), cliStartWait === 'runtime'
? ' ranges = {"wait_s": (0, start_wait_max) if kind == "runtime.start" else\n'
: ' ranges = {"wait_s": (0, 600) if kind == "runtime.start" else\n');
const earlierInstallEnv = process.env.STRATA_INSTALL_DIR;
process.env.STRATA_INSTALL_DIR = install; // the app's own install folder (the host always tells Control which one; it never falls back to an older CLI folder)
const configs = ids.map(id => {
@@ -632,8 +638,9 @@ test('packaged: a big model is waited for by its size, inside the ceiling of the
return { wait: start[2], ready: saved.engine_ready_s };
} finally { f.cleanup(); }
};
assert.equal((await run('old', 180)).wait, 600, 'a Control whose CLI takes 600 s at most is asked for 600 s, as today');
assert.equal((await run('old', 180)).wait, 600, 'a Control with no long-wait ceiling at all is asked for 600 s, as today');
assert.equal((await run('split', 180)).wait, 600, 'a Control whose runtime takes 1800 s but whose CLI still stops at 600 is asked for 600 s: the CLI would refuse the start outright (#3949)');
assert.equal((await run('cli-only', 180)).wait, 600, 'a Control whose CLI takes it but whose operation record still stops at 600 is asked for 600 s too: the record is written before the start runs');
const long = await run('runtime', 180);
assert.equal(long.wait, 1720, '600 s + 8 s per GB above 40 GB, as in strata launch, once the CLI really takes it');
assert.equal(long.ready, 1780, 'the server readies after the start gave up, never before it');