diff --git a/package.json b/package.json index e7625ab..13272ae 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "skills/", "dashboard/", "assets/", + "eslint.config.mjs", "torch-config.example.json", "README.md", "TORCH.md", diff --git a/scripts/validate-scheduler-flow-parity.mjs b/scripts/validate-scheduler-flow-parity.mjs index 6b05a1d..af120c8 100644 --- a/scripts/validate-scheduler-flow-parity.mjs +++ b/scripts/validate-scheduler-flow-parity.mjs @@ -61,7 +61,7 @@ const invariants = [ ], flow: [ 'Roster source: `src/prompts/roster.json`', - 'Read `scheduler.firstPromptByCadence.` from `torch-config.json` if present.', + 'Read `scheduler.firstPromptByCadence.` from repository-root `torch-config.json` if present.', 'All roster tasks currently claimed by other agents', ], }, @@ -119,7 +119,7 @@ const invariants = [ meta: [ 'If any validation command exits non-zero, do not call `lock:complete`', 'Publish completion before writing `_completed.md`', - 'Only after step 10 succeeds, write final task log (`_completed.md`', + 'Only after step 11 succeeds, write final task log (`_completed.md`', ], flow: [ 'step 12 MUST NOT be executed (`lock:complete` is forbidden until validation passes)', diff --git a/src/ops.mjs b/src/ops.mjs index 5090091..99587c5 100644 --- a/src/ops.mjs +++ b/src/ops.mjs @@ -53,7 +53,7 @@ const EVOLVING_DIRS = ['daily', 'weekly']; const APP_DIRS = ['src', 'bin', 'dashboard', 'landing', 'assets', 'scripts']; /** Individual files to sync from package root to install directory. */ -const APP_FILES = ['package.json', 'build.mjs', 'README.md', 'torch-config.example.json', 'TORCH.md']; +const APP_FILES = ['package.json', 'build.mjs', 'README.md', 'torch-config.example.json', 'TORCH.md', 'eslint.config.mjs']; /** * Resolves the absolute paths for the installation. diff --git a/src/prompts/META_PROMPTS.md b/src/prompts/META_PROMPTS.md index 3dddae7..fc7b23a 100644 --- a/src/prompts/META_PROMPTS.md +++ b/src/prompts/META_PROMPTS.md @@ -21,7 +21,10 @@ MUST 0: Normalize execution context before any other step: - `script_prefix = npm run --prefix torch` - `path_prefix = torch/` - Else stop and report: `Unable to locate TORCH scheduler files (checked src/prompts and torch/src/prompts).` +- Ensure dependencies are installed before continuing: + - If `node_modules` does not exist, run `npm install` (host-repo mode example: `npm install --prefix torch`). - Apply `script_prefix` to every `lock:*` command below and apply `path_prefix` to every repository path below. +- `torch-config.json` is always resolved at repository root (do not apply `path_prefix` to it). MUST 1: Set cadence config to: - cadence = daily @@ -48,7 +51,7 @@ MUST 3: Run these commands in this order: a) YAML frontmatter key `agent`. b) Filename format `____.md`. - If no valid previous log exists (missing file, parse failure, or agent not in roster): - - Read `scheduler.firstPromptByCadence.daily` from `torch-config.json` if present. + - Read `scheduler.firstPromptByCadence.daily` from `torch-config.json` (repository root) if present. - If that agent is in roster, start there. - Otherwise set `start_index = 0`. - Else set `start_index = (index(previous_agent)+1) mod roster_length`. @@ -62,27 +65,28 @@ MUST 3: Run these commands in this order: 5) Claim via repository lock: AGENT_PLATFORM= lock:lock -- --agent --cadence daily Exit 0 = lock acquired, proceed. Exit 3 = race lost, go back to step 3. -6) Execute selected prompt from src/prompts/daily/ (spawned agent work only; completion publish and final task log writing remain scheduler-owned) -7) Run required memory workflow for this cadence: +6) Run required memory workflow for this cadence: - Before execution, run the retrieval command if configured: `scheduler.memoryPolicyByCadence.daily.retrieveCommand` - - After execution, run the storage command if configured: - `scheduler.memoryPolicyByCadence.daily.storeCommand` - - Emit or collect verifiable evidence for both steps using configured markers/artifacts. -8) Validate memory evidence: +7) Execute selected prompt from src/prompts/daily/ (spawned agent work only; completion publish and final task log writing remain scheduler-owned) +8) After execution, run the storage command if configured: + - `scheduler.memoryPolicyByCadence.daily.storeCommand` + - Emit or collect verifiable evidence for both retrieval and storage steps using configured markers/artifacts. +9) Validate memory evidence: - Confirm retrieval evidence exists (marker and/or artifact file). - Confirm storage evidence exists (marker and/or artifact file). - If `scheduler.memoryPolicyByCadence.daily.mode` is `required`, fail the run if either check is missing. -9) Run repository checks (for example: npm run lint) +10) Run repository checks (for example: npm run lint) + - Do not apply `script_prefix` to repository checks unless you explicitly intend to validate the TORCH package itself. - If any validation command exits non-zero, do not call `lock:complete`. - Instead, write `_failed.md` with the failing command and reason, then stop. -10) Publish completion before writing `_completed.md` (only after step 9 passes): +11) Publish completion before writing `_completed.md` (only after step 10 passes): AGENT_PLATFORM= lock:complete -- --agent --cadence daily (Equivalent command allowed: torch-lock complete --agent --cadence daily) - Exit 0: continue. - Exit non-zero: fail the run, write `_failed.md` with a clear completion-publish failure reason and retry guidance, then stop. -11) Only after step 10 succeeds, write final task log (`_completed.md` for success). For any failure in step 9 or step 10, write `_failed.md`, then stop. -12) Print a final summary message to stdout. +12) Only after step 11 succeeds, write final task log (`_completed.md` for success). For any failure in step 10 or step 11, write `_failed.md`, then stop. +13) Print a final summary message to stdout. - Status: [Success/Failure] - Agent: [Agent Name] - Prompt: [Prompt Path] @@ -99,7 +103,7 @@ MUST 3: Run these commands in this order: Worked example (failed validation, no completion publish): - `AGENT_PLATFORM=codex lock:lock -- --agent content-audit-agent --cadence daily` - execute selected prompt work - - ` lint` exits non-zero (or ` test` exits non-zero) + - `npm run lint` exits non-zero (or `npm run test` exits non-zero) - write `task-logs/daily/__content-audit-agent__failed.md` with failure reason - stop without running `AGENT_PLATFORM=codex lock:complete -- --agent content-audit-agent --cadence daily` - print final summary (Status: Failed, Reason: ) @@ -124,7 +128,10 @@ MUST 0: Normalize execution context before any other step: - `script_prefix = npm run --prefix torch` - `path_prefix = torch/` - Else stop and report: `Unable to locate TORCH scheduler files (checked src/prompts and torch/src/prompts).` +- Ensure dependencies are installed before continuing: + - If `node_modules` does not exist, run `npm install` (host-repo mode example: `npm install --prefix torch`). - Apply `script_prefix` to every `lock:*` command below and apply `path_prefix` to every repository path below. +- `torch-config.json` is always resolved at repository root (do not apply `path_prefix` to it). MUST 1: Set cadence config to: - cadence = weekly @@ -151,7 +158,7 @@ MUST 3: Run these commands in this order: a) YAML frontmatter key `agent`. b) Filename format `____.md`. - If no valid previous log exists (missing file, parse failure, or agent not in roster): - - Read `scheduler.firstPromptByCadence.weekly` from `torch-config.json` if present. + - Read `scheduler.firstPromptByCadence.weekly` from `torch-config.json` (repository root) if present. - If that agent is in roster, start there. - Otherwise set `start_index = 0`. - Else set `start_index = (index(previous_agent)+1) mod roster_length`. @@ -165,27 +172,28 @@ MUST 3: Run these commands in this order: 5) Claim via repository lock: AGENT_PLATFORM= lock:lock -- --agent --cadence weekly Exit 0 = lock acquired, proceed. Exit 3 = race lost, go back to step 3. -6) Execute selected prompt from src/prompts/weekly/ (spawned agent work only; completion publish and final task log writing remain scheduler-owned) -7) Run required memory workflow for this cadence: +6) Run required memory workflow for this cadence: - Before execution, run the retrieval command if configured: `scheduler.memoryPolicyByCadence.weekly.retrieveCommand` - - After execution, run the storage command if configured: - `scheduler.memoryPolicyByCadence.weekly.storeCommand` - - Emit or collect verifiable evidence for both steps using configured markers/artifacts. -8) Validate memory evidence: +7) Execute selected prompt from src/prompts/weekly/ (spawned agent work only; completion publish and final task log writing remain scheduler-owned) +8) After execution, run the storage command if configured: + - `scheduler.memoryPolicyByCadence.weekly.storeCommand` + - Emit or collect verifiable evidence for both retrieval and storage steps using configured markers/artifacts. +9) Validate memory evidence: - Confirm retrieval evidence exists (marker and/or artifact file). - Confirm storage evidence exists (marker and/or artifact file). - If `scheduler.memoryPolicyByCadence.weekly.mode` is `required`, fail the run if either check is missing. -9) Run repository checks (for example: npm run lint) +10) Run repository checks (for example: npm run lint) + - Do not apply `script_prefix` to repository checks unless you explicitly intend to validate the TORCH package itself. - If any validation command exits non-zero, do not call `lock:complete`. - Instead, write `_failed.md` with the failing command and reason, then stop. -10) Publish completion before writing `_completed.md` (only after step 9 passes): +11) Publish completion before writing `_completed.md` (only after step 10 passes): AGENT_PLATFORM= lock:complete -- --agent --cadence weekly (Equivalent command allowed: torch-lock complete --agent --cadence weekly) - Exit 0: continue. - Exit non-zero: fail the run, write `_failed.md` with a clear completion-publish failure reason and retry guidance, then stop. -11) Only after step 10 succeeds, write final task log (`_completed.md` for success). For any failure in step 9 or step 10, write `_failed.md`, then stop. -12) Print a final summary message to stdout. +12) Only after step 11 succeeds, write final task log (`_completed.md` for success). For any failure in step 10 or step 11, write `_failed.md`, then stop. +13) Print a final summary message to stdout. - Status: [Success/Failure] - Agent: [Agent Name] - Prompt: [Prompt Path] @@ -202,7 +210,7 @@ MUST 3: Run these commands in this order: Worked example (failed validation, no completion publish): - `AGENT_PLATFORM=codex lock:lock -- --agent bug-reproducer-agent --cadence weekly` - execute selected prompt work - - ` lint` exits non-zero (or ` test` exits non-zero) + - `npm run lint` exits non-zero (or `npm run test` exits non-zero) - write `task-logs/weekly/__bug-reproducer-agent__failed.md` with failure reason - stop without running `AGENT_PLATFORM=codex lock:complete -- --agent bug-reproducer-agent --cadence weekly` - print final summary (Status: Failed, Reason: ) diff --git a/src/prompts/scheduler-flow.md b/src/prompts/scheduler-flow.md index 44917c4..70c4bb0 100644 --- a/src/prompts/scheduler-flow.md +++ b/src/prompts/scheduler-flow.md @@ -141,8 +141,7 @@ Every agent prompt invoked by the schedulers (daily/weekly) MUST enforce this co 2. Otherwise parse filename convention `____.md` and take ``. - If no valid `latest_file` exists, or parsing fails, or `previous_agent` is not in `roster`, treat as first run fallback. - First run fallback: - - Read `scheduler.firstPromptByCadence.` from `torch-config.json` if present. - - In host-repo mode, resolve this as `torch-config.json`. + - Read `scheduler.firstPromptByCadence.` from repository-root `torch-config.json` if present. - If that agent exists in `roster`, set `start_index = index(configured_agent)`. - Otherwise set `start_index = 0`. - Otherwise: `start_index = (index(previous_agent in roster) + 1) mod len(roster)`. diff --git a/test/ops.test.mjs b/test/ops.test.mjs index 79be123..a75fb20 100644 --- a/test/ops.test.mjs +++ b/test/ops.test.mjs @@ -33,6 +33,7 @@ test('cmdInit creates directory structure and files', async () => { assert.ok(fs.existsSync(path.join(torchDir, 'prompts', 'daily')), 'daily prompts created'); assert.ok(fs.existsSync(path.join(torchDir, 'roster.json')), 'roster created'); assert.ok(fs.existsSync(path.join(torchDir, 'META_PROMPTS.md')), 'META_PROMPTS.md created'); + assert.ok(fs.existsSync(path.join(torchDir, 'eslint.config.mjs')), 'eslint config copied'); // Check content transformation const metaPrompts = fs.readFileSync(path.join(torchDir, 'META_PROMPTS.md'), 'utf8');