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

+37 -12
View File
@@ -50,7 +50,11 @@ test('environment API rejects execution controls and legacy rows stay out of tas
const legacy = [
{ id: 1, name: 'task_before', value: 'touch /tmp/untrusted' },
{ id: 2, name: 'NODE_OPTIONS', value: '--require /tmp/untrusted.js' },
{ id: 3, name: 'PREV_NODE_OPTIONS', value: '--import=data:text/javascript,bad' },
{
id: 3,
name: 'PREV_NODE_OPTIONS',
value: '--import=data:text/javascript,bad',
},
{ id: 4, name: 'GIT_SSH_COMMAND', value: 'sh -c bad' },
{ id: 5, name: 'PATH', value: '/tmp/untrusted' },
{ id: 6, name: 'file_task_before', value: '/tmp/untrusted.sh' },
@@ -72,7 +76,11 @@ test('environment API rejects execution controls and legacy rows stay out of tas
typedi: decorators,
'../config': { envFile: 'sh', jsEnvFile: 'js', pyEnvFile: 'py' },
'../data/env': {
Env: class { constructor(value) { Object.assign(this, value); } },
Env: class {
constructor(value) {
Object.assign(this, value);
}
},
EnvModel: {
update: async (value, query) => {
writes++;
@@ -83,7 +91,9 @@ test('environment API rejects execution controls and legacy rows stay out of tas
},
'../data': { sequelize: { literal: (value) => value } },
'../shared/utils': {
writeFileWithLock: async (file, value) => { output[file] = value; },
writeFileWithLock: async (file, value) => {
output[file] = value;
},
},
}).default;
const service = new Env({
@@ -91,15 +101,30 @@ test('environment API rejects execution controls and legacy rows stay out of tas
warn: (...args) => warnings.push(args),
});
service.envs = async () => legacy;
service.insert = async () => { writes++; return []; };
service.insert = async () => {
writes++;
return [];
};
service.getDb = async () => ({ id: 1, name: 'SAFE_VALUE', value: 'kept' });
service.updateDb = async () => { writes++; return {}; };
service.updateDb = async () => {
writes++;
return {};
};
for (const name of [
'task_before', 'PREV_NODE_OPTIONS', 'GIT_SSH_COMMAND', 'work_dir',
'task_shell_params', 'which_program', 'script_params', 'LOG_DIR',
'task_before',
'PREV_NODE_OPTIONS',
'GIT_SSH_COMMAND',
'work_dir',
'task_shell_params',
'which_program',
'script_params',
'LOG_DIR',
'EXPORTED_VARIABLES',
'begin_timestamp', 'is_macos', 'RandomDelayIgnoredMinutes', 'ID',
'begin_timestamp',
'is_macos',
'RandomDelayIgnoredMinutes',
'ID',
'BASH_XTRACEFD',
]) {
await assert.rejects(
@@ -252,11 +277,11 @@ function cronService(config, updates = []) {
'../config/util': { fileExist: async (p) => fs.existsSync(p) },
'../config/const': {},
'../schedule/client': {},
'../shared/pLimit': {},
'../shared/utils': {},
'../cron/execution/cronLimit': {},
'../shared/utils': { fileExist: async (p) => fs.existsSync(p) },
'../shared/i18n': translate,
'../shared/logStreamManager': {},
'../shared/cronSchedule': {},
'../cron/scheduling/cronSchedule': {},
}).default;
return new Cron(logger);
}
@@ -364,7 +389,7 @@ function systemService(config, overrides = {}) {
DependenceStatus: {},
},
'../data/system': {},
'../shared/pLimit': {},
'../cron/execution/cronLimit': {},
'../schedule/client': {},
'../shared/i18n': { ...translate, setLang() {} },
'./notify': {},