Skip to content

feat(profiles): add cc-profile-config to show, choose and write routing profiles - #94

Merged
datacas merged 2 commits into
mainfrom
issue-73-profile-config
Sep 25, 2026
Merged

datacas merged 2 commits into
mainfrom
issue-73-profile-config

Conversation

@datacas

@datacas datacas commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Closes #73 — #73

Changes

  • New supporting skill cc-profile-config and runtime component scripts/profile_config.py (show | propose | write | presets), listed in scripts/runtime.manifest.
  • Show: every profile's roles (from ROLE_CANDIDATES), primary and fallback marked config or default, PROFILE_COST, the read-only guarantee (enforced for Codex, detected for Claude, per Allow any executor in read-only roles through an isolated, verified review harness #72) and executor availability from probe().
  • Presets: balanced-openai-implements, balanced-anthropic-implements, defaults, single-openai, single-anthropic. Custom targets are set with --set profile.primary|fallback=TARGET|none.
  • Validation: parse_target plus load_profiles, the executor/provider match, Codex model and effort checked against $CODEX_HOME/models_cache.json (reported as unchecked when the cache or a model list is missing), executors that aren't installed or authenticated, the workspace contract, and the implement/review split.
  • Write: needs --confirmed. It edits only the code_cycle.profiles block as text, so every other key and comment stays byte for byte. It declares only what differs from the defaults, verifies the result with PyYAML before an atomic replace, and refuses a proposal that has errors.
  • cycle_status.py --profiles [--cwd] prints the effective table without an agent.
  • cc-provider-bootstrap mentions the skill once when there is no profiles block. The skill is registered in validate-package.py and EXPECTED_SKILLS. README, docs/skills.md, docs/routing.md (new Changing profiles section), docs/configuration.md, docs/workflows.md and CHANGELOG are updated.

Decisions worth reviewing

  • Balanced presets declare no fallback, on either side. The issue asks for fallbacks "on the same side of the split", but route() checks availability per executor: a same-executor fallback is unavailable whenever its primary is, and a fallback on the other executor crosses the split. So an unavailable executor blocks the stage. A crossing target is refused unless --allow-cross-split is passed, and then it is reported as a warning.
  • single-anthropic keeps auxiliary_tool on Codex. Claude can't enforce the disposable contract of verify/run, so those stages would block. The preset says so in its notes.
  • The split covers cheap_coder/deep_coder against reviewer/senior_reviewer/security. coordinator keeps its default.

Verification

  • python3 scripts/validate-package.py: VALID: 14 skills (6 cycle, 8 supporting).
  • python3 -m unittest discover -s tests: 679 tests, OK. This includes the new tests/test_profile_config.py: every preset accepted by run_cycle.plan_with_strategy, every role of every preset routing to an executor that honours its workspace policy, the split held with fallbacks included, crossing refused or allowed, catalog checks, write confirmation, comment-preserving insert/replace/remove round trip, and cycle_status --profiles.
  • Manual check: show, propose for every preset, and write followed by write --preset defaults on a copy of this repository's .code-cycle.yml, which restored the file byte for byte.

…ng profiles

Adds the cc-profile-config supporting skill and the runtime component
profile_config.py. It shows the effective profiles (configured or default,
roles, relative cost, read-only guarantee, executor availability), offers
balanced cross-vendor, default and single-vendor presets or custom targets,
validates Codex models and efforts against Codex's local models cache, and
writes only code_cycle.profiles after --confirmed, preserving every other key
and comment in .code-cycle.yml.

The balanced presets keep the implementing vendor out of review, fallbacks
included, and declare no fallback: availability is per executor, so a
same-executor fallback is down with its primary and a cross-executor one would
cross the split. auxiliary_tool stays on Codex because only Codex can confine
a disposable workspace. cycle_status.py --profiles prints the same table.

Closes #73
@datacas

datacas commented Sep 25, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20260925-001] · manual_reviewer · ?/?→? · ? · schema:1

Review summary

CHANGES_REQUESTED for head 9178f47af7ad3a8ce039c4cb088eca26a08e1e54 (base ebd54d6e6ab33331f62e840f598a697c6add829d). I reviewed the complete accumulated diff from the merge base across all 15 changed files: profile configuration CLI and skill, runtime and package registration, tests, documentation, and CI. The criteria pass found no other actionable correctness regressions.

Findings

[REV-001] · medium · open · - · blocks:yes — Config writer follows a predictable temporary-file symlink

Path: scripts/profile_config.py:573

write_declaration writes to the predictable sibling path <config>.tmp using Path.write_text(), which follows a pre-existing symlink. A caller-writable repository can therefore plant <config>.tmp pointing at another file the user can write; running the confirmed write overwrites that target, then os.replace() moves the symlink onto the config path. This permits unintended arbitrary file overwrite and leaves the config path redirected. I reproduced it in an isolated temporary directory with a harmless victim file: its contents changed to the proposed config and the config path became a symlink. Create a unique temporary file exclusively in the config directory, then atomically replace the config and clean up on failure.

[REV-002] · medium · open · - · blocks:yes — Installer CI checks a PR-only skill against main

Path: .github/workflows/validate.yml:16

Adding cc-profile-config to the shared EXPECTED_SKILLS list makes both installer jobs require it from get.sh/get.ps1 --version main, even though the skill exists only on this PR. Both the Bash and PowerShell installer checks fail with did not install cc-profile-config in each of the two workflow runs. Run these installer checks against the PR ref, or otherwise keep the PR-only skill out of assertions against main, so the required pre-merge gates can pass.

Security triage

.code-cycle.yml does not declare security_review.always_when, so no deterministic rule fired. I requested and ran cc-security-review because this change adds a config-writing path that controls security-review and workspace-constrained routing. The isolated reproduction confirmed REV-001; no other confirmed vulnerability was found in the reviewed diff.

Verification

  • python3 -m unittest discover -s tests -p 'test_profile_config.py' -v — 25 tests passed.
  • python3 scripts/validate-package.py — passed: 14 skills, shared sections in sync, manifests aligned.
  • python3 -m unittest discover -s tests -v — first run had one transient failure in unchanged tests/test_stats.py::StatsTests::test_unmeasured_model_drift_names_dispatches_without_a_model; that test passed in isolation and the full 679-test suite passed on rerun.
  • Isolated write_declaration symlink reproduction — confirmed the target overwrite and config symlink replacement described in REV-001.

No other execution flows were unverified for the changed CLI. The hosted installer jobs were not run locally; their provider logs were inspected and show the failures described in REV-002.

CI and residual risk

gh pr checks 94 reports four failed checks: Skills, manifests, and Bash installer failed in both workflow runs, and PowerShell installer failed in both. There are no pending checks. The local suite passed on rerun, but the hosted installer gates remain red. Until REV-001 is fixed, confirmed writes in a directory containing a planted <config>.tmp symlink can overwrite another user-writable file; REV-002 also prevents the installer CI gates from passing before merge.

Verdict: CHANGES_REQUESTED. Both open findings block approval.

@datacas

datacas commented Sep 25, 2026

Copy link
Copy Markdown
Owner Author

[CCT-20260925-001] · manual_resolver · ?/?→? · ? · triaged:9178f47af7ad3a8ce039c4cb088eca26a08e1e54 · schema:1

Triage

Every finding was classified against 9178f47af7ad3a8ce039c4cb088eca26a08e1e54 before any code changed.

[REV-001] · medium · open · valid · blocks:yes — Config writer follows a predictable temporary-file symlink

Path: scripts/profile_config.py. Valid: Path.write_text() on the fixed sibling path <config>.tmp follows a planted symlink. Fix planned: create the temporary file exclusively with a unique name in the config directory (tempfile.mkstemp), replace atomically, and remove it on failure.

[REV-002] · medium · open · valid · blocks:yes — Installer CI checks a PR-only skill against main

Path: .github/workflows/validate.yml. Valid: the one-command installer steps download main but assert the PR's EXPECTED_SKILLS, so any PR that adds a skill fails them. Fix planned: those two steps assert the skills that main actually ships (read from main's tree), while the local-install steps keep asserting this PR's EXPECTED_SKILLS.

… installers against main's skills

REV-001: write_declaration wrote to the predictable <config>.tmp with
Path.write_text, which follows a planted symlink. It now creates a unique
temporary file exclusively beside the config (tempfile.mkstemp), keeps the
config's mode, replaces atomically and removes the temporary on failure.

REV-002: the one-command installer steps download main but asserted this
branch's EXPECTED_SKILLS, so any pull request adding a skill failed them.
They now assert the skills main's tree ships; the local-install steps keep
asserting EXPECTED_SKILLS.
@datacas

datacas commented Sep 25, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20260925-001] · manual_reviewer · ?/?→? · ? · schema:1

[CCT-20260925-001] · manual_resolver · ?/?→? · ? · triaged:9178f47af7ad3a8ce039c4cb088eca26a08e1e54 · schema:1

Resolution summary

RESOLVED. Head is now 36deaaabfbcb8cfb130b90be9d9c7e20e494aedf, up from 9178f47af7ad3a8ce039c4cb088eca26a08e1e54. Both findings were fixed in that commit and verified.

[REV-001] · medium · resolved · valid · blocks:yes — Config writer follows a predictable temporary-file symlink

Paths: scripts/profile_config.py, tests/test_profile_config.py. write_declaration now calls _replace_atomically, which:

  • creates a unique temporary file exclusively beside the config with tempfile.mkstemp (O_EXCL);
  • writes through that file descriptor and keeps the config's existing mode;
  • replaces the config with os.replace;
  • deletes the temporary file on any failure.

Regression test test_write_ignores_a_planted_temporary_symlink plants .code-cycle.yml.tmp (and .tmp.tmp) as symlinks to a victim file. It asserts that the victim is untouched, the config is not a symlink, its mode is kept, and no temporary file is left over. Against the previous writer the test fails (AssertionError: 'untouched\n' != '# Top comment stays.…'), which reproduces the finding. Against the fix it passes.

[REV-002] · medium · resolved · valid · blocks:yes — Installer CI checks a PR-only skill against main

Path: .github/workflows/validate.yml. The get.sh and get.ps1 steps download main, so they now assert the skills that main's tree ships: git fetch --depth=1 origin main, then git ls-tree --name-only FETCH_HEAD skills/. Each step fails if that list comes back empty. The local-install steps still assert this branch's EXPECTED_SKILLS, so cc-profile-config is still required wherever the PR's own code is installed.

Verification

  • python3 -m unittest tests.test_profile_config: 26 tests, OK.
  • python3 -m unittest discover -s tests: 680 tests, OK.
  • python3 scripts/validate-package.py: VALID: 14 skills (6 cycle, 8 supporting).
  • gh pr checks 94 on 36deaaa: Skills, manifests, and Bash installer and PowerShell installer pass in both workflow runs. Nothing is pending or failed.

Post-change review

  • I reviewed the accumulated diff of the fix myself; no new findings.
  • Security triage: security_review.always_when isn't declared. The fix hardens a file-write path, so I checked it against symlink planting at the temporary name and at the config path. os.replace replaces a symlinked config link rather than writing through it. No new risk found.

Residual risk

A symlinked .code-cycle.yml is replaced by a regular file when written. That matches the previous behaviour and is intended.

@datacas

datacas commented Sep 25, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20260925-001] · manual_reviewer · ?/?→? · ? · schema:1

[CCT-20260925-001] · manual_resolver · ?/?→? · ? · triaged:9178f47af7ad3a8ce039c4cb088eca26a08e1e54 · schema:1

[CCR-20260925-002] · manual_reviewer · ?/?→? · ? · schema:1

Re-review summary

APPROVED at current head 36deaaabfbcb8cfb130b90be9d9c7e20e494aedf (base ebd54d6e6ab33331f62e840f598a697c6add829d). I reviewed the full accumulated diff across all 15 changed files and the changes since the previous review (9178f47af7ad3a8ce039c4cb088eca26a08e1e54): commit 36deaaa updates the config writer, adds a regression test, and fixes the installer checks. No new findings.

Previous findings

[REV-001] · medium · resolved · valid · blocks:yes — Config writer follows a predictable temporary-file symlink

Corrected and verified by execution. _replace_atomically now creates a unique temporary file exclusively in the config directory, writes through its file descriptor, preserves the existing mode, atomically replaces the config, and removes the temporary file on failure. The regression test test_write_ignores_a_planted_temporary_symlink passed: the planted symlink targets were untouched, the config remained a regular file, and its mode was preserved.

[REV-002] · medium · resolved · valid · blocks:yes — Installer CI checks a PR-only skill against main

Corrected and verified by CI. The Bash and PowerShell installer jobs now assert the skills present on main, which they install; the PR's skill list is covered by local installation checks. Both installer check names passed in both current workflow runs.

Both dispositions remain valid as recorded by the resolver. The original severity and titles are preserved. There is no numbering gap and no new finding.

Security triage

.code-cycle.yml still has no deterministic security_review.always_when rule. I re-ran security review because the changed code writes routing configuration and the previous finding concerned its filesystem write boundary. The planted temporary-symlink reproduction now passes; no other confirmed vulnerability was found in the current diff.

Verification

  • Preflight: Python 3.10.12 and PyYAML 5.4.1 available; this local CLI change needs no database or service.
  • python3 -m unittest discover -s tests -p test_profile_config.py -v — 26 tests passed, including the symlink regression test.
  • python3 scripts/validate-package.py — passed: 14 skills, shared sections in sync, manifests aligned.
  • python3 -m unittest discover -s tests -v — all 680 tests passed.
  • The previous symlink exploit was re-tested through the regression test on the current head. REV-002 was verified against the current hosted installer jobs.

CI, residual risk, and verdict

gh pr checks 94: all four checks passed — Skills, manifests, and Bash installer (two runs) and PowerShell installer (two runs). No checks are pending, failed, cancelled, skipped, or missing.

No open findings remain. The current code and required checks were verified at 36deaaabfbcb8cfb130b90be9d9c7e20e494aedf.

Verdict: APPROVED.

@datacas
datacas merged commit 73508f5 into main Sep 25, 2026
4 checks passed
@datacas
datacas deleted the issue-73-profile-config branch October 6, 2026 07:53
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.

Add cc-profile-config: show, choose and write routing profiles (balanced cross-vendor presets)

1 participant