Skip to content

fix(runtime): resolve .code-cycle.yml from the main worktree in a linked worktree - #248

Merged
datacas merged 1 commit into
mainfrom
task-244
Oct 15, 2026
Merged

datacas merged 1 commit into
mainfrom
task-244

Conversation

@datacas

@datacas datacas commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Closes #244

Work item: #244 (GitHub Issues), split from #234.

Diagnosis

  • Symptom: from a linked worktree with no .code-cycle.yml of its own, run_cycle.py ran silently on the built-in defaults: profiles ignored, and rereview failed with review.trusted_authors is empty.
  • Reproduction: read from code, no run needed. resolve_config looked only at <--cwd>/.code-cycle.yml and returned {} when absent. Covered by the new test test_the_main_roots_file_applies_and_is_named, which fails without the change.
  • Cause: matches the issue. Invariant broken: a run's configuration is the repository's, not the checkout's; absence must be reported, not silent.
  • Related work: basic search (issue links, Problemas al ejecutar un ciclo completo con run_cycle.py (toolkit 0.5.0) #234 tracker). No duplicate or shared cause found.
  • Fix shape: one resolution function, with the fallback in resolve_config through git rev-parse --git-common-dir. No new flag or state.

Work units

Unit Behaviour Files Tests Verification Rollback
WU-1 Fall back to the main worktree root's .code-cycle.yml, report which file (or the defaults) a run uses scripts/run_cycle.py, docs/configuration.md, CHANGELOG.md tests/test_run_cycle.py::LinkedWorktreeConfigurationTests (5 tests) see below independent

Verification (agent-reported)

  • python3 -m unittest tests.test_run_cycle → exit 0, 208 tests OK
  • python3 -m unittest discover -s tests → exit 0, 1449 tests OK
  • python3 scripts/validate-package.py → exit 0, VALID

Environment: the new tests create a real temporary Git repository and linked worktree and pass their own commit identity; they do not use ~/.gitconfig.

Checks

Policy parallel: the head's checks were read once after publication; see the check status of this PR.

@datacas

datacas commented Oct 15, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20261016-001] · reviewer · anthropic/claude-sonnet-5-5→? · high · schema:2

Review of #248 — head 3c75bbd736d6d7ddbb36e5395cda02d51621f6b5

Status: REVIEW_PASSED_AWAITING_CI. The review is complete for this head and no finding blocks approval. This is not an approval: the required checks were still pending when read, and the CI gate decides (policy parallel).

Scope

Accumulated diff origin/main…head (235 lines, SHA-256 b2550b88…7136601, confirmed): scripts/run_cycle.py, tests/test_run_cycle.py, docs/configuration.md, CHANGELOG.md. Linked work item #244. Conventions applied: repository AGENTS.md (nothing review-specific); defaults of this skill.

resolve_config now falls back to the main worktree root's .code-cycle.yml (via git rev-parse --git-common-dir, scrubbed GIT_* env, any Git failure → no fallback). It reports which file (or the defaults) a run uses. Precedence is unchanged: --no-config, then --config, then the file in --cwd, then the fallback, then the defaults. I found no correctness defect.

Findings

[REV-001] · low · open · - · blocks:no — Other config readers keep the cwd-only lookup

Paths: scripts/profile_config.py:610 (_load), scripts/stats.py:1107 (_report_config).
Both still read <cwd>/.code-cycle.yml only. From a linked worktree without its own file, cc-profile-config shows built-in defaults, and cc-stats reports "no repository identity". This is the same defect class as #244, outside this PR's stated scope (run_cycle.py). The PR text says "one resolution function", but the new one lives only in run_cycle.py. Follow-up suggestion only; nothing here regresses.

Security triage

security_review.always_when is not declared in .code-cycle.yml, so the defaults applied. No changed path, filename or label matched (no labels). On my own reading it is not a sensitive change. I read the one trust-relevant point: code_cycle.review.trusted_authors can now come from the main worktree file. That file belongs to the same repository, the lookup root comes from Git's own output, the git call uses an argument list with no shell, and it fails closed to "no fallback".
Not a sensitive change: the security audit was skipped after triage.

Executed verification

Run at the head, exit 0 each:

  • python3 -m unittest tests.test_run_cycle.LinkedWorktreeConfigurationTests → 5 tests OK
  • python3 -m unittest tests.test_run_cycle → 208 tests OK
  • python3 scripts/validate-package.py → VALID
  • Ad-hoc probe with a real linked worktree: _main_worktree_config returns the main root's file from the worktree, from a subdirectory of it, and from the main root itself.

Not run: the full discover -s tests suite (the PR reports 1449 OK; the CI gate runs it).

CI (read once, not waited on)

gh pr checks 248: PowerShell installer ×2 — pending; Skills, manifests, and Bash installer ×2 — pending. 0 passed, 0 failed, 4 pending. These are reported as state, not findings.

Residual risks

  • main() resolves the configuration twice (plan_with_strategy, then resolve_config(..., report=print)); harmless, and the report prints once.
  • The fallback also applies from a subdirectory of a main checkout. This is consistent with the docs' intent and harmless.

Verdict

No finding blocks approval for this head. Awaiting CI.

ORCHESTRATION_RESULT (JSON)

ORCHESTRATION_RESULT
{
"skill": "cc-initial-review",
"status": "REVIEW_PASSED_AWAITING_CI",
"issue_provider": "github",
"issue_id": "244",
"code_host": "github",
"change_request_id": "248",
"change_request_url": "#248",
"pr_number": 248,
"issue_number": 244,
"head_sha": "3c75bbd736d6d7ddbb36e5395cda02d51621f6b5",
"reviewed_head_sha": "3c75bbd736d6d7ddbb36e5395cda02d51621f6b5",
"review_run_id": "CCR-20261016-001",
"reviewer": {
"profile": "reviewer",
"provider": "anthropic",
"model_requested": "claude-sonnet-5-5",
"model_resolved": null,
"effort": "high"
},
"findings": [
{
"id": "REV-001",
"severity": "low",
"status": "open",
"disposition": "-",
"blocks_approval": false,
"category": "maintainability",
"path": "scripts/profile_config.py",
"line": 610
}
],
"blocking_findings": [],
"checks": {"head_sha": "3c75bbd736d6d7ddbb36e5395cda02d51621f6b5", "passed": 0, "failed": 0, "pending": 4},
"blocking": false
}
END_ORCHESTRATION_RESULT

@datacas

datacas commented Oct 15, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20261016-002] · reviewer · anthropic/claude-sonnet-5-5→? · high · schema:2

Re-verification of recovered review (attempt-8826ee7539c449b2bf5e76fe72e6b714) — head 3c75bbd736d6d7ddbb36e5395cda02d51621f6b5

Status: REVIEW_PASSED_AWAITING_CI. The review is complete for this head and no finding blocks approval. This is not an approval: three of four required checks were still pending when read; the CI gate decides (policy parallel).

Scope

Accumulated diff origin/main…head (235 lines, SHA-256 b2550b88…7136601, confirmed; head equals the PR head): scripts/run_cycle.py, tests/test_run_cycle.py, docs/configuration.md, CHANGELOG.md. Work item #244. Conventions applied: repository AGENTS.md; defaults of this skill.

Claimed finding IDs to verify: none. verified_findings is empty. I re-read the whole diff and re-ran the checks independently, and I reuse the recovered comment's finding (REV-001, ID kept) after checking it against the current code. I found no new defect: precedence is --no-config, then --config, then the file in --cwd, then the main worktree root's file, then the defaults, and a Git failure means "no fallback".

Findings

[REV-001] · low · open · - · blocks:no — Other config readers keep the cwd-only lookup

Paths: scripts/profile_config.py:610 (_load), scripts/stats.py:1107 (_report_config).
Re-checked at this head: both still read <cwd>/.code-cycle.yml only and neither calls the new fallback. Same defect class as #244 for cc-profile-config and cc-stats in a linked worktree; outside this PR's stated run_cycle.py scope and not a regression. Follow-up only.

Security triage

No security_review.always_when rule is declared, so the defaults applied; no changed path, filename or label matched. On my own reading it is not a sensitive change (the trusted_authors source stays inside the same repository, the root comes from Git's own output, git runs with an argument list and no shell, and failure falls back to "no fallback").
Not a sensitive change: the security audit was skipped after triage.

Executed verification (head 3c75bbd, exit 0 each)

  • python3 -m unittest tests.test_run_cycle.LinkedWorktreeConfigurationTests → 5 tests OK
  • python3 -m unittest tests.test_run_cycle → 208 tests OK
  • python3 scripts/validate-package.py → VALID

Not run: the full discover -s tests suite (the PR reports 1449 OK; the CI gate runs it).

CI (read once, not waited on)

gh pr checks 248: Skills, manifests, and Bash installer — 1 pass, 1 pending; PowerShell installer ×2 — pending. 1 passed, 0 failed, 3 pending. Reported as state, not findings.

Residual risks

  • main() resolves the configuration twice (plan_with_strategy, then resolve_config(..., report=print)); harmless, the report prints once.
  • The fallback also applies from a subdirectory of a main checkout; consistent with the docs.

Verdict

No finding blocks approval for this head. Awaiting CI.

ORCHESTRATION_RESULT (JSON)

ORCHESTRATION_RESULT
{
"skill": "cc-initial-review",
"status": "REVIEW_PASSED_AWAITING_CI",
"issue_provider": "github",
"issue_id": "244",
"code_host": "github",
"change_request_id": "248",
"change_request_url": "#248",
"pr_number": 248,
"issue_number": 244,
"head_sha": "3c75bbd736d6d7ddbb36e5395cda02d51621f6b5",
"reviewed_head_sha": "3c75bbd736d6d7ddbb36e5395cda02d51621f6b5",
"review_run_id": "CCR-20261016-002",
"reviewer": {
"profile": "reviewer",
"provider": "anthropic",
"model_requested": "claude-sonnet-5-5",
"model_resolved": null,
"effort": "high"
},
"verified_findings": [],
"findings": [
{
"id": "REV-001",
"severity": "low",
"status": "open",
"disposition": "-",
"blocks_approval": false,
"category": "maintainability",
"path": "scripts/profile_config.py",
"line": 610
}
],
"blocking_findings": [],
"checks": {"head_sha": "3c75bbd736d6d7ddbb36e5395cda02d51621f6b5", "passed": 1, "failed": 0, "pending": 3},
"blocking": false
}
END_ORCHESTRATION_RESULT

@datacas

datacas commented Oct 15, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20261016-003] · reviewer · anthropic/claude-sonnet-5-5→? · high · schema:2

Review of #248 — head 3c75bbd736d6d7ddbb36e5395cda02d51621f6b5

Status: REVIEW_PASSED_AWAITING_CI. The review is complete for this head and no finding blocks approval. This is not an approval: required checks were still pending when read; the CI gate decides (policy parallel).

Scope

Accumulated diff origin/main…head (235 lines, SHA-256 b2550b88…7136601, confirmed; head equals the PR head): scripts/run_cycle.py, tests/test_run_cycle.py, docs/configuration.md, CHANGELOG.md. Work item #244. Conventions applied: repository AGENTS.md; defaults of this skill.

resolve_config falls back to the main worktree root's .code-cycle.yml (via git rev-parse --git-common-dir, scrubbed GIT_* env, any Git failure means no fallback) and reports which file, or the defaults, a run uses. Precedence: --no-config, --config, file in --cwd, main worktree root's file, defaults. No correctness defect found.

Findings

[REV-001] · low · open · - · blocks:no — Other config readers keep the cwd-only lookup

Paths: scripts/profile_config.py:610 (_load), scripts/stats.py:1107 (_report_config).
Re-checked at this head: both still read <cwd>/.code-cycle.yml only and do not use the new fallback. Same defect class as #244 for cc-profile-config and cc-stats in a linked worktree; outside this PR's stated run_cycle.py scope and not a regression. Follow-up only. ID kept from the earlier review comments on this head.

Security triage

No security_review.always_when rule is declared, so the defaults applied; no changed path, filename or label matched. On my own reading it is not a sensitive change: trusted_authors can now come from the main worktree file, but that file belongs to the same repository, the root comes from Git's own output, git runs with an argument list and no shell, and failure falls back to no fallback.
Not a sensitive change: the security audit was skipped after triage.

Executed verification (head 3c75bbd, exit 0 each)

  • python3 -m unittest tests.test_run_cycle.LinkedWorktreeConfigurationTests → 5 tests OK
  • python3 -m unittest tests.test_run_cycle → 208 tests OK
  • python3 scripts/validate-package.py → VALID

Not run: the full discover -s tests suite (the PR reports 1449 OK; the CI gate runs it).

CI (read once, not waited on)

gh pr checks 248: Skills, manifests, and Bash installer — 1 pass, 1 pending; PowerShell installer ×2 — pending. 1 passed, 0 failed, 3 pending. Reported as state, not findings.

Residual risks

  • main() resolves the configuration twice (plan_with_strategy, then resolve_config(..., report=print)); harmless, the report prints once.
  • The fallback also applies from a subdirectory of a main checkout; consistent with the docs.

Verdict

No finding blocks approval for this head. Awaiting CI.

@datacas
datacas merged commit cf6cf92 into main Oct 15, 2026
4 checks passed
@datacas
datacas deleted the task-244 branch October 15, 2026 22:46
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.

Resolve .code-cycle.yml from the main worktree when running in a linked worktree

1 participant