Skip to content

Cortex pull reads campaign digests; scheduler allowlist + action guard (hpc-campaign p5c) - #548

Merged
Jammy2211 merged 3 commits into
mainfrom
feature/hpc-campaign-p5c-brain
Oct 31, 2026
Merged

Jammy2211 merged 3 commits into
mainfrom
feature/hpc-campaign-p5c-brain

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

Closes #547. Merge after autolens_assistant#173 and #174: this PR uses their verb names.

What changes

  • Cortex conductor pull. For a project row with campaign_file:, it runs hpc/sync status <campaign_file> instead of jobs/squeue. For a row with digest:, it previews cortex sync-runs <key> --dry-run (PyAutoCortex#83). Pull still writes nothing; recording stays a separate sync-runs step, by your ruling.
  • AUTONOMY.md "Scheduler actions" and the Cortex skill. A campaign's jobs start and change only through hpc/sync act <submit|resubmit|hold|release|throttle|update-pending|cancel>, logged to <project_root>/campaign/<name>/actions.log. hpc/sync submit|push-submit sbatch one hand-written script, outside any campaign. Reading is free.
  • bin/scheduler_action_guard.py is a PreToolUse(Bash) hook for Claude and Codex. Its I/O contract is the same as mind_commit_guard.py's.
    • It refuses raw sbatch, scancel, srun, salloc, any scontrol that changes things, and a raw autofit.campaign submit. That covers the same calls over ssh, in bash -c/eval, behind env/wrappers (xargs, parallel, find -exec), chained, substituted, or in heredocs fed to a shell, and quote/backslash spellings the shell reads as the bare word.
    • Allowed: scontrol show, help, usage, version, sbatch --test-only, and mentions such as commit messages or grep.
    • The escape hatch PYAUTO_SKIP_SCHEDULER_GUARD=1 stays (your ruling). It works from the environment or as the leading assignment of the command it excuses; a mention elsewhere excuses nothing.
  • Tests: 175 across the guard and the conductor. The full suite passes, apart from test_hygiene_conductor (6) and test_skill_install (10), which already fail on main da6743f.

Not in this PR: registration

You approved registration on 2026-10-31. It follows the merge, because the guard has to exist on main first:

  • add it to the workspace-root .claude/settings.json Bash hooks
  • add a scheduler-action-guard entry to PyAutoMind/scripts/repos_sync.py CODEX_HOOK_DEFINITIONS and Brain's codex_hooks in repos.yaml

Review

Independent review (a different model from the author's) found 4 items, no blockers:

  • quote/backslash spellings skipped the pre-filter
  • ssh options after the host were not skipped
  • the escape hatch was matched anywhere in the command
  • read-only sbatch flags were denied

All 4 are fixed, with tests. The review also confirmed the hook I/O contract, the Cortex CLI and field names, and the pre-existing failures.

Under the Heart RED development override for hpc-campaign phase 5 (2026-10-30). Merge only with green CI and your /prm; no release.

🤖 Generated with Claude Code

Jammy2211 and others added 2 commits October 31, 2026 11:29
…d (hpc-campaign p5c)

- cortex pull: a row with campaign_file runs `<sync_cli> status <campaign_file>`
  in place of `jobs` (squeue), and a row with digest prints what Cortex
  `sync-runs <key> --dry-run` would change from the pulled digest. Still writes
  nothing; recording is `cortex.py sync-runs <key>` (decision 64).
- AUTONOMY.md "Scheduler actions": `hpc/sync act` is the only way a campaign's
  jobs start or change (submit, resubmit, hold, release, throttle,
  update-pending, cancel); submit/push-submit sbatch one hand-written script;
  read verbs free; actions.log audit contract.
- bin/scheduler_action_guard.py: PreToolUse(Bash) hook source for Claude and
  Codex refusing raw sbatch, scancel, mutating scontrol and
  `autofit.campaign submit` (direct, over ssh, bash -c/eval, wrappers, chains,
  substitutions, heredocs fed to a shell). `scontrol show` stays allowed.
  Source and tests only; not registered.

Interfaces: autolens_assistant 271f939 (hpc/sync act), PyAutoCortex#83 (sync-runs).
Refs #547

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tch as prefix)

Independent review of 2c4b24f:
- the trigger pre-filter now reads the command with quotes and
  backslashes removed, so s\batch / "sb""atch" reach the parser;
- ssh options after the host are skipped (ssh ral -t "sbatch j");
- the escape hatch excuses only the clause it prefixes, not a mention
  anywhere (echo / commit message);
- --help/--usage/--version/sbatch --test-only only read and are allowed;
- find -exec and parallel are unwrapped.
Human rulings 2026-10-31: srun and salloc are refused too; the escape
hatch stays; pull stays write-nothing; registration approved, done after
merge. Cortex skill names the digest path hpc/sync pulls to.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fies skills/hpc_campaign.md

CI on #548: the tenant firewall flagged a library name in a comment in
_cortex.py. autolens_assistant#174's boundary check (which reads this
profile from main) had no side for the new hpc_campaign skill; it is
domain content like hpc/* and init-slam.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jammy2211
Jammy2211 merged commit 72ea37b into main Oct 31, 2026
2 checks passed
@Jammy2211
Jammy2211 deleted the feature/hpc-campaign-p5c-brain branch October 31, 2026 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: cortex conductor reads the campaign digest; scheduler governance hook (hpc-campaign p5c)

1 participant