Skip to content

Install the runtime, not the instructions alone - #11

Merged
datacas merged 2 commits into
mainfrom
feat/install-runtime
Sep 21, 2026
Merged

datacas merged 2 commits into
mainfrom
feat/install-runtime

Conversation

@datacas

@datacas datacas commented Sep 21, 2026

Copy link
Copy Markdown
Owner

What this fixes

cc-orchestrator instructed its reader to drive every stage through CycleRecorder, and install.sh copied skills/ alone. A clean installation therefore had the instruction and no code to satisfy it: it recorded nothing, and first_pass_rate() stayed unmeasured however many cycles ran.

This is REV-001 from the review of #10, deferred there because widening what the toolkit distributes is a decision about the installation contract, not a fix to fold into a recording primitive.

What changed

Both installers carry the runtime to .code-cycle/runtime — under the home directory for a global installation, under the project root for a project one. One copy per scope rather than one per host: a skill is instructions and duplicates harmlessly, but three copies of the code that records a cycle would be three answers to the question of which one a run used.

scripts/runtime.manifest is the single list both installers read, so Bash and PowerShell cannot drift. It ships cycle, executors, router, telemetry, security_gate and review_contract. calibration_store.py and validate-package.py stay in the checkout: campaign tooling and package tooling, which no installed skill points anybody at.

A project-scope installation writes .code-cycle/.gitignore containing *, so installed code cannot be committed to the target repository by accident.

--no-runtime / -NoRuntime installs the skills alone, and the skill now states that such an installation records nothing rather than implying a rate exists.

The test that could have caught it

None of the 310 existing tests could see this gap, because every one of them imports from scripts/ — precisely the checkout an installation does not have. They would all have passed on an installer that shipped nothing.

tests/installed_stage_check.py refuses that import. It takes an installed runtime directory, strips the repository off sys.path, drives a full stage through a scripted executor — no provider, no network, no credential — and asserts the rows it left. Both CI jobs run it against a real installation.

Three more checks close the doors around it:

  • a test deletes telemetry.py from the installed tree and requires the check to fail, so the check's own premise is verified rather than assumed;
  • a module in scripts/ must be either shipped or declared as tooling, so a new one cannot land without somebody deciding which;
  • the local imports of every shipped module must themselves be shipped, so a runtime that would fail on its first real call fails at installation instead.

Verification

  • python3 -m unittest discover -s tests — Ran 318 tests ... OK (was 305 before Record a stage by running it #10, 310 after).
  • python3 scripts/validate-package.py — VALID.
  • Local install into a temp project, then installed_stage_check.py against it — installed runtime recorded 3 rows.
  • PowerShell path is unverified locally (no pwsh in this environment); the Windows CI job is what exercises it.

What this does not do

Nothing reads the recorded rows automatically, and no installed host is wired to construct a CycleRecorder yet — this makes the code reachable, not the wiring automatic. The rate stays unmeasured until real cycles run.

cc-orchestrator told its reader to drive every stage through CycleRecorder
while install.sh copied skills/ alone. A clean installation had the instruction
and no code to satisfy it, so it recorded nothing and first_pass_rate stayed
unmeasured however many cycles ran. That is the failure this instrument exists
to catch, in the instrument itself.

Both installers now carry the runtime to .code-cycle/runtime, one copy per
scope rather than one per host: three copies would be three answers to the
question of which one a run used. scripts/runtime.manifest is the single list
both read, so they cannot drift. A project-scope installation writes
.code-cycle/.gitignore containing '*', so installed code cannot be committed to
the target repository by accident. --no-runtime and -NoRuntime install the
skills alone, and the skill says such an installation records nothing.

No test could have seen the gap, because every test imports from scripts/ --
the checkout an installation does not have. tests/installed_stage_check.py
refuses that import: it takes an installed runtime, keeps the repository off
sys.path, drives a full stage through a scripted executor and asserts the rows.
Both CI jobs run it against a real installation, and a test deletes a module
from the installed tree to prove the check can still fail. The suite also
refuses a module that is neither shipped nor declared as tooling, and a shipped
module whose own imports are not shipped.
@datacas

datacas commented Sep 21, 2026

Copy link
Copy Markdown
Owner Author

Review summary

Reviewed the accumulated diff from origin/main to 342ff67d27d7ced734ba7bfb2150f60f9c3786ab for PR #11. The change correctly adds a manifest-driven runtime, installs it for both Bash and PowerShell scopes, and verifies a clean installed runtime can record a stage. CONTRIBUTING.md supplied the repository workflow; no additional repository-local AGENTS.md or CLAUDE.md instructions were present.

Findings

[REV-001] · high · open · blocks:yes — Runtime installation overwrites .code-cycle/.gitignore and follows symlinks

Path: scripts/install.sh:158 (same behavior in scripts/install.ps1:86)

Problem: Every default runtime installation unconditionally writes * to $BASE_DIR/.code-cycle/.gitignore with printf > or Set-Content, without checking whether the file already exists or is a symlink. This bypasses the installer’s otherwise explicit --force/-Force overwrite contract.

Impact: A normal installation destroys an existing project or user .code-cycle/.gitignore and its rules. More seriously, a target repository can contain a symlink at that path; the Bash installer follows it and overwrites the symlink target, allowing an untrusted repository to cause arbitrary file truncation when a user installs into it.

Reproduction: In a temporary project, an existing .code-cycle/.gitignore containing keep-existing-rules became exactly * after a successful install. With .code-cycle/.gitignore symlinked to a temporary victim.txt, the install exited 0 and changed the victim contents to *.

Suggestion: Refuse symlink/reparse-point targets, create .gitignore only when absent, and preserve or safely merge existing rules. If replacement is intended, require --force/-Force and still reject symlinked targets rather than following them. Add Bash and PowerShell regression coverage for an existing file and a symlink/reparse point.

Security triage

The change is sensitive because both installers write code and control files into a user-selected project or home directory, and the runtime is then placed on PYTHONPATH. The scoped security audit confirmed REV-001 as an unsafe file-handling vulnerability. No other confirmed injection, secret-exposure, authentication, authorization, or unsafe runtime-data issue was found in the accumulated diff.

Verification

  • python3 scripts/validate-package.py — VALID.
  • python3 -m unittest tests.test_install_runtime -v — Ran 8 tests ... OK.
  • python3 -m unittest discover -s tests -v — Ran 318 tests ... OK.
  • bash -n scripts/install.sh — passed.
  • git diff --check origin/main...HEAD — passed.
  • Clean Bash project installation plus tests/installed_stage_check.py — exit 0, installed runtime recorded 3 rows.
  • Existing-file and symlink overwrite reproductions — both confirmed the unsafe behavior described in REV-001.

Unverified items

  • shellcheck is unavailable in this environment; the Linux CI gate reports success.
  • Native PowerShell execution is unavailable locally; the Windows CI gate reports success and runs the installed-runtime smoke check.
  • No live Codex, Claude, or Orca dispatch was attempted; runtime tests use scripted adapters and require no credentials or network.

CI

All four current PR checks completed successfully: two Skills, manifests, and Bash installer runs and two PowerShell installer runs. No check is pending, failed, cancelled, or skipped. The repository’s Linux and Windows validation gates are present and green.

Residual risks

The installed runtime still requires the host or user to put its scope-specific directory on PYTHONPATH and construct CycleRecorder; the PR documents that wiring boundary and tests the runtime independently. The overwrite/symlink issue must be fixed before relying on the installer with existing or untrusted target repositories.

Verdict

CHANGES_REQUESTED — REV-001 blocks approval.

The runtime install wrote '*' to .code-cycle/.gitignore unconditionally. Two
things were wrong with that. It destroyed an existing file, bypassing the
--force contract the rest of the installer honours. And it followed a symlink:
a repository could point that path at any file on the disk, and installing into
that repository truncated it. Reproduced both -- an existing file containing
keep-existing-rules became '*', and a link to victim.txt left victim.txt
containing '*'. With --force the same held for a linked runtime module.

An installation is not authority to modify a file nobody named. Every path the
runtime install writes to is now checked: the .code-cycle directory, the
runtime directory, the ignore file and each module. A symlink on any of them is
refused with the path named, not followed. An existing .gitignore is kept as it
is and reported, never merged and never replaced by --force, which asks to
replace this toolkit's files and not the target project's. --force on a module
removes the entry before copying, so it replaces our file rather than writing
through a link.

The module loop no longer relies on cp declining a dangling symlink, which is
GNU behaviour; PowerShell uses Get-Item over Test-Path for the same reason, a
link whose target is gone being a link that Test-Path reports as absent.

Four regression tests, all of which fail against the previous installer and
pass against this one, plus a Windows CI step covering the existing file and
the reparse point. The skills copy is deliberately untouched: a deliberately
symlinked skills directory is a plausible setup, a symlinked .code-cycle
.gitignore is not.
@datacas

datacas commented Sep 21, 2026

Copy link
Copy Markdown
Owner Author

Resolution summary

Reproduced before editing anything, fixed in d1c8365.

[REV-001] · high · resolved · valid · blocks:yes — Runtime installation overwrites .code-cycle/.gitignore and follows symlinks

Valid, and worse than a convenience bug. Both halves reproduced exactly as reported against 342ff67:

  • an existing .code-cycle/.gitignore containing keep-existing-rules became *, exit 0;
  • with that path symlinked to victim.txt, the install exited 0 and victim.txt contained *.

A third case was found while triaging, of the same class: --force on a symlinked module target copied through the link, so cycle.py → victim.py left victim.py containing the toolkit's source. The -e guard missed it because --force skipped straight to cp.

The rule the code was missing: an installation is not authority to modify a file nobody named. It writes into a directory somebody else chose, which may be a repository it did not create; a symlink on a path it writes to is that repository asking it to modify something outside itself.

Every path the runtime install touches is now checked and refused by name — the .code-cycle directory, the runtime directory, the ignore file, and each module. Beyond that:

  • an existing .gitignore is kept exactly as it is and reported, never merged and never replaced. --force does not authorise replacing it: that flag asks to replace this toolkit's files, not the target project's.
  • --force on a module rms the entry before copying, so it replaces our file instead of writing through a link.
  • the module loop no longer leans on cp declining a dangling symlink, which is GNU behaviour and not BSD's. PowerShell uses Get-Item -Force rather than Test-Path for the same reason: a link whose target is gone is still a link, and Test-Path reports it as absent.

Deliberately not changed

copy_skills is untouched. It already removes an existing entry rather than copying over it, and a deliberately symlinked ~/.claude/skills is a plausible setup somebody may rely on, whereas a symlinked .code-cycle/.gitignore is not something an installer should ever honour. Widening the refusal to the skills path would change behaviour this finding did not report, in a direction that can break a working installation.

Regression coverage

Four Bash tests in tests/test_install_runtime.py, one per case: existing ignore file preserved, symlinked ignore file refused with the victim intact, --force replacing a symlinked module without touching its target, symlinked runtime directory refused with the pointed-at directory left empty.

They were checked against the previous installer, not just the new one: with scripts/install.sh restored from 342ff67, Ran 12 tests ... FAILED (failures=4) — exactly these four. Against d1c8365, OK.

PowerShell has the same coverage in CI, since it cannot run in this environment: a step creates an existing ignore file, installs, asserts the content survived, then replaces it with a real SymbolicLink, asserts the install throws, and asserts the link target still reads precious. Had the link creation silently failed on the runner, the install would have succeeded and the step would have failed on its own assertion.

Verification

  • Reproductions before the fix: existing file → *; symlinked file → victim.txt became *; --force on a symlinked module → target overwritten with toolkit source.
  • Same three after the fix: content preserved, Refusing to write through a symlink (ignore file): … with exit 1, link replaced and target untouched.
  • python3 -m unittest discover -s tests — Ran 322 tests ... OK (was 318).
  • python3 scripts/validate-package.py — VALID.
  • bash -n scripts/install.sh — passed.
  • CI on d1c8365 — all four checks pass. The Windows job reports success :: Leave an existing ignore file alone and refuse a linked one and success :: Run a stage from the installed runtime; the Linux job includes shellcheck, which is unavailable locally.

Residual risks

shellcheck and native PowerShell remain unrunnable in this environment; CI is the only evidence for both, and it is green. The wiring boundary from the PR description is unchanged: the runtime is installed and proven to record, but a host still has to put it on PYTHONPATH and construct the recorder.

Status: RESOLVED — REV-001 closed at d1c8365.

@datacas

datacas commented Sep 21, 2026

Copy link
Copy Markdown
Owner Author

Re-review summary

Reviewed the complete accumulated diff from origin/main to d1c8365 (632 insertions, 14 deletions), including the fix delta since the previous review (201 insertions, 25 deletions). The fix preserves existing ignore files and refuses writes through symlink/reparse-point paths across the Bash and PowerShell installers.

Previous findings

[REV-001] · high · resolved · blocks:no — Runtime installation overwrites .code-cycle/.gitignore and follows symlinks

Corrected and verified by execution. The original reproductions now behave safely:

  • an existing .code-cycle/.gitignore is preserved exactly;
  • a symlinked .gitignore is refused without modifying its target;
  • --force replaces a symlinked toolkit module without modifying its target;
  • a symlinked runtime directory is refused without writing into it.

The finding is closed at d1c8365.

Current review and security triage

No new findings were identified in the accumulated change. Security triage was activated because the installers write code and control files into a user-selected project path and place the runtime on PYTHONPATH. The security audit found no additional confirmed vulnerabilities after the link-safe write changes.

Verification

  • python3 scripts/validate-package.py — VALID.
  • python3 -m unittest tests.test_install_runtime -v — Ran 12 tests, OK.
  • python3 -m unittest discover -s tests -v — Ran 322 tests, OK.
  • bash -n scripts/install.sh — passed.
  • git diff --check origin/main...HEAD — passed.
  • Original and regression reproductions — 4/4 passed.
  • Clean installed-stage smoke test — passed; recorded 3 rows.

Local ShellCheck and PowerShell executables are unavailable; the current GitHub workflow covers those environments. GitHub checks are current and successful: 2 Skills, manifests, and Bash installer runs and 2 PowerShell installer runs, with 0 failures.

Residual risk is intentional and documented: when an existing .code-cycle/.gitignore is present, the installer leaves it unchanged, so users who want installed runtime files ignored must add runtime/ to that file.

Verdict

APPROVED

@datacas
datacas merged commit 8472b8c into main Sep 21, 2026
4 checks passed
@datacas
datacas deleted the feat/install-runtime branch September 21, 2026 16:36
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.

1 participant