feat(cron): expose run receipts and modularize execution

Return committed trigger IDs and add CLI wait and trigger-specific logs while
preserving API, CLI, transaction, deduplication and unknown-result semantics.

Move scheduling, lifecycle, settlement, queries and legacy adapters into
back/cron; remove obsolete internal import paths and circular dependencies.

Apply project formatting across the repository, cover CJS/MJS in formatting
hooks, add prettier:check and require formatting checks in AGENTS.md.

Validation: backend build; 1398 backend/frontend tests passed (17 platform
skips); 327 CLI tests passed (6 platform skips); 670 files pass format checks.
This commit is contained in:
whyour committed 2026-11-22 12:24:29 +08:00
1 parent 77ece406ac
commit c5458596c8
346 files changed
+32133 -11556

No files matched your search

+27 -21
View File
@@ -183,7 +183,7 @@ test('success-shaped invalid documents retain the raw-response error fallback',
assert.equal(f.count(), cases.length * 2);
});
test('Shell retries the same identified receipt after a timeout and starts the next run with a fresh ID', t => {
test('Shell retries the same identified receipt after a timeout and starts the next run with a fresh ID', (t) => {
const f = fixture(t);
const result = f.run(`
ID=7; unset QL_TRIGGER_ID
@@ -203,29 +203,35 @@ test('Shell retries the same identified receipt after a timeout and starts the n
assert.equal(result.status, 0, result.stderr);
const lines = fs.readFileSync(f.response, 'utf8').trim().split('\n');
assert.equal(lines.length, 12);
for (let i = 0; i < lines.length; i += 2) assert.equal(lines[i], lines[i+1]);
const ids = lines.map(line => JSON.parse(line).execution_id);
for (let i = 0; i < lines.length; i += 2)
assert.equal(lines[i], lines[i + 1]);
const ids = lines.map((line) => JSON.parse(line).execution_id);
assert.match(ids[0], /^client-[0-9a-f-]{36}$/);
assert.ok(ids.slice(0, 6).every(id => id === ids[0]));
assert.ok(ids.slice(6).every(id => id === ids[6]));
assert.ok(ids.slice(0, 6).every((id) => id === ids[0]));
assert.ok(ids.slice(6).every((id) => id === ids[6]));
assert.notEqual(ids[0], ids[6]);
});
test('a standalone shell reuses the observed end for both receipts, including timeout retries', t => {
test('a standalone shell reuses the observed end for both receipts, including timeout retries', (t) => {
const f = fixture(t);
const result = f.run([
'ql_execution_id="client-123"; directory=$(dirname "$RESPONSE_FILE");',
'ql_api_request() {',
' local arg; for arg in "$@"; do case "$arg" in "X-QL-Finished-At:"*) printf "%s\\n" "$arg" >> "$directory/headers";; esac; done;',
' if [[ ! -e "$directory/retried" ]]; then touch "$directory/retried"; return 28; fi;',
' printf \'{"code":200}\';',
'}',
'update_cron 5 0 501 task.log 1700000000;',
'rm -f "$directory/retried";',
'update_cron 5 1 501 task.log 1700000000 60 17 1700000060;',
'record_cron_stat 5 17 60 1700000060;',
'cat "$directory/headers";',
].join('\n'));
assert.equal(result.status,0,result.stderr);
assert.deepEqual(result.stdout.trim().split('\n'),Array(3).fill('X-QL-Finished-At: 1700000060000'));
const result = f.run(
[
'ql_execution_id="client-123"; directory=$(dirname "$RESPONSE_FILE");',
'ql_api_request() {',
' local arg; for arg in "$@"; do case "$arg" in "X-QL-Finished-At:"*) printf "%s\\n" "$arg" >> "$directory/headers";; esac; done;',
' if [[ ! -e "$directory/retried" ]]; then touch "$directory/retried"; return 28; fi;',
' printf \'{"code":200}\';',
'}',
'update_cron 5 0 501 task.log 1700000000;',
'rm -f "$directory/retried";',
'update_cron 5 1 501 task.log 1700000000 60 17 1700000060;',
'record_cron_stat 5 17 60 1700000060;',
'cat "$directory/headers";',
].join('\n'),
);
assert.equal(result.status, 0, result.stderr);
assert.deepEqual(
result.stdout.trim().split('\n'),
Array(3).fill('X-QL-Finished-At: 1700000060000'),
);
});