Skip to content

feat: Cairn Dev Loop workflow, CAIRN_PATH_GITIGNORED remediation, and test hardening - #131

Merged
George-RD merged 7 commits into
devfrom
claude/cairn-dev-workflow-iFP17
Jun 5, 2026
Merged

feat: Cairn Dev Loop workflow, CAIRN_PATH_GITIGNORED remediation, and test hardening#131
George-RD merged 7 commits into
devfrom
claude/cairn-dev-workflow-iFP17

Conversation

@George-RD

Copy link
Copy Markdown
Collaborator

Summary

Cloud agent session delivering the Cairn Dev Loop: a repeatable development workflow for iterating on cairn using cairn's own graph queries and gates. Includes documentation, skill command, remediation mapping, and test fixture hardening.

Changes

  • Docs: New docs/agent/cairn-dev-workflow.md (266 lines) defining the canonical orient/scope/propose/implement/verify/record/loop cycle
  • Skills: New .claude/commands/cairn-loop.md command for Claude Code integration
  • Decision: meta/decisions/adopt-cairn-dev-loop.md recording the architectural decision
  • Agent docs: Updated AGENTS.md and CLAUDE.md with agent context profiles and workflow references
  • Remediate: Mapped CAIRN_PATH_GITIGNORED finding to a concrete fix_gitignored_path remediation action in src/query_api/handlers.rs
  • Tests:
    • New integration test test_gitignored_path_surfaces_remediation_action in tests/gitignore_lint.rs
    • Fixed tests/hooks_architecture.rs to disable commit signing in throwaway git repos (prevents failures in GPG-enforced environments)
  • Beads: Seeded backlog with open issues for follow-up work

Verification

  • cargo test: 791 passed
  • cargo fmt --check: clean
  • cargo clippy --lib --tests: clean
  • cairn lint / cairn hook all: pass

Known pre-existing

src/query_api/handlers.rs exceeds the 500-line module size gate (now 783 lines). Issue cairn-7km filed for tracking.

Copilot AI review requested due to automatic review settings June 5, 2026 14:03
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 74be2072-6620-4d8f-b5b2-70cd9defb621

📥 Commits

Reviewing files that changed from the base of the PR and between 2bce463 and cdd6951.

📒 Files selected for processing (19)
  • .beads/.gitignore
  • .beads/config.yaml
  • .beads/hooks/post-checkout
  • .beads/hooks/post-merge
  • .beads/hooks/pre-commit
  • .beads/hooks/pre-push
  • .beads/hooks/prepare-commit-msg
  • .beads/interactions.jsonl
  • .beads/issues.jsonl
  • .claude/commands/cairn-loop.md
  • .claude/settings.json
  • .gitignore
  • AGENTS.md
  • CLAUDE.md
  • docs/agent/cairn-dev-workflow.md
  • meta/decisions/adopt-cairn-dev-loop.md
  • src/query_api/handlers.rs
  • tests/gitignore_lint.rs
  • tests/hooks_architecture.rs

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Introduced Cairn Dev Loop as standardized development workflow
    • Added Agent Context Profiles for managing permissions across sessions
    • Enhanced remediation actions for gitignored paths
  • Bug Fixes

    • Fixed commit signing configuration in test setup
    • Improved timeout handling in Git hooks (v1.0.5)
  • Documentation

    • Added comprehensive Cairn Dev Loop documentation
    • Updated Beads integration guidance and session completion protocol
  • Chores

    • Updated Git hooks to v1.0.5
    • Updated configuration defaults and expanded gitignore patterns

Walkthrough

This PR upgrades Beads Git hooks to v1.0.5 with improved timeout handling, introduces the Cairn Dev Loop as the repository's canonical development workflow with supporting documentation and agent context profiles, and implements remediation action generation for gitignored paths. The changes span infrastructure updates, workflow documentation, and new lint remediation features.

Changes

Beads Integration v1.0.5 Upgrade

Layer / File(s) Summary
Hook timeout mechanism upgrade
.beads/hooks/post-checkout, .beads/hooks/post-merge, .beads/hooks/pre-commit, .beads/hooks/pre-push, .beads/hooks/prepare-commit-msg
All five hooks are upgraded from v1.0.4 to v1.0.5 with timeout handling refactored to support GNU timeout, gtimeout, or Perl alarm implementations. Exit-code detection now accounts for both coreutils timeout code (124) and Perl-specific codes, while preserving database-not-initialized skip behavior (exit code 3).
Beads configuration and state tracking
.beads/config.yaml, .beads/.gitignore, .gitignore, .beads/interactions.jsonl, .beads/issues.jsonl
Beads configuration sets the default audit-trail actor to cairn-loop. Local runtime artifacts are excluded via gitignore patterns for proxieddb/, proxied_server_client_info.json, dolt-pprof/, and .auto-import-issues.jsonl. Issue tracking records status transitions for remediation actions and updates dependency metadata.

Cairn Dev Loop Workflow Adoption

Layer / File(s) Summary
Development workflow phases and decision record
docs/agent/cairn-dev-workflow.md, meta/decisions/adopt-cairn-dev-loop.md
Documents the Cairn Dev Loop as a ten-phase continuous iteration (Orient → Scope → Propose → Implement → Test → Verify → Record → PR → Merge → Continue) with explicit exit criteria, required cairn/cargo commands, and gate validation steps (cairn scan, cairn hook all). Autonomous mode guidance describes the in-process review DAG and responses to unfixable findings. Decision record formalizes adoption with metadata and provenance boundaries.
Claude command definition and hook configuration
.claude/commands/cairn-loop.md, .claude/settings.json
Defines the /cairn-loop Claude command specifying phase sequencing, required setup, and quality guardrails. Updates Claude session hooks to remove PreCompact and modify SessionStart to use --hook-json for structured logging.
Agent context profiles and session completion protocol
CLAUDE.md, AGENTS.md
Replaces fixed session-completion requirements with three agent context profiles (Conservative/default, Minimal, Team-maintainer) that conditionally govern git/Dolt push behavior. Rewrites session-ending steps with profile-based git sync flows, explicit handoff checklists, and critical rules for overrides and blocked sync reporting. Updates generated Beads codex section with current workflow instructions.

Gitignored Path Detection and Remediation

Layer / File(s) Summary
Remediation action generation for gitignored paths
src/query_api/handlers.rs
Extends remediate_json to detect CAIRN_PATH_GITIGNORED lint findings and generate a fix_gitignored_path remediation action. Introduces has_gitignored_paths flag and gitignored_nodes list to accumulate affected nodes (deduplicated), then emits the action with command cairn lint and the collected node identifiers.
Integration tests and test infrastructure fixes
tests/gitignore_lint.rs, tests/hooks_architecture.rs
Adds test_gitignored_path_surfaces_remediation_action integration test that spawns cairn remediate --json, parses the JSON output, and asserts that the fix_gitignored_path action includes the expected affected nodes. Updates git_init test helper to disable GPG commit signing in temporary repos, preventing commit failures that could impact subsequent architecture gate assertions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • cairn-framework/cairn#127: Modifies remediate_json in src/query_api/handlers.rs to generate remediation actions based on lint/hook finding codes, overlapping at the same function with the gitignore remediation changes in this PR.

Poem

🐰 Beads now timeout with flair,
Ten-phase loops through the air,
Gitignore paths caught and mended,
The dev workflow's now transcended! ✨🔁

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/cairn-dev-workflow-iFP17

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a documented and runnable “Cairn Dev Loop” workflow for developing Cairn using Cairn’s own queries/gates, while also improving remediation output for CAIRN_PATH_GITIGNORED and hardening related integration tests. It additionally updates Beads-related repo configuration, exported data, and git hooks.

Changes:

  • Add the Cairn Dev Loop documentation + a Claude Code /cairn-loop command, and record an accompanying decision.
  • Map CAIRN_PATH_GITIGNORED to a concrete fix_gitignored_path remediation action and add an integration test for it.
  • Harden test fixtures (git commit signing) and update Beads configuration/hooks/exports.

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/hooks_architecture.rs Disables commit signing in throwaway git repos used by architecture hook tests.
tests/gitignore_lint.rs Adds integration test asserting remediate --json surfaces fix_gitignored_path.
src/query_api/handlers.rs Adds remediation action mapping for CAIRN_PATH_GITIGNORED.
meta/decisions/adopt-cairn-dev-loop.md Records decision adopting the dev loop workflow.
docs/agent/cairn-dev-workflow.md Adds canonical, detailed “Cairn Dev Loop” workflow documentation.
CLAUDE.md Links to the dev loop and updates agent context guidance in the Beads block.
AGENTS.md Updates agent guidance and adds Beads codex setup block.
.gitignore Ignores Beads/Dolt proxied DB directory.
.claude/settings.json Updates Claude Code hooks to run bd prime --hook-json at session start.
.claude/commands/cairn-loop.md Adds a Claude Code command to orchestrate one dev-loop iteration.
.beads/issues.jsonl Updates exported Beads issues (including adding new issues/metadata adjustments).
.beads/interactions.jsonl Updates exported Beads interactions.
.beads/hooks/prepare-commit-msg Updates Beads-managed hook wrapper (adds more timeout strategies).
.beads/hooks/pre-push Updates Beads-managed hook wrapper (adds more timeout strategies).
.beads/hooks/pre-commit Updates Beads-managed hook wrapper (adds more timeout strategies).
.beads/hooks/post-merge Updates Beads-managed hook wrapper (adds more timeout strategies).
.beads/hooks/post-checkout Updates Beads-managed hook wrapper (adds more timeout strategies).
.beads/config.yaml Sets default Beads actor value.
.beads/.gitignore Expands ignored Beads runtime/proxy/debug artifacts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/query_api/handlers.rs
Comment on lines +672 to +676
if has_gitignored_paths {
actions.push(json!({
"priority": 2,
"action": "fix_gitignored_path",
"command": "cairn lint",
Comment thread tests/gitignore_lint.rs
Comment on lines +113 to +118
let output = Command::new(env!("CARGO_BIN_EXE_cairn"))
.current_dir(&root)
.args(["remediate", "--json"])
.output()?;
let stdout = String::from_utf8(output.stdout)?;
let parsed: serde_json::Value = serde_json::from_str(&stdout)?;
Comment on lines +31 to +34
Command::new("git")
.current_dir(root)
.args(["config", "commit.gpgsign", "false"])
.output()?;
Comment thread .beads/config.yaml
Comment on lines 23 to +24
# Default actor for audit trails (overridden by BEADS_ACTOR or --actor)
# actor: ""
actor: "cairn-loop"
Comment on lines +160 to +165
---
id: dec.<short-name>
nodes: [<node.id>]
status: accepted
date: <YYYY-MM-DD>
---
claude added 7 commits June 5, 2026 16:03
Introduce a repeatable seven-phase development loop (orient, scope,
propose, implement, verify, record, land) driven by cairn's own graph
queries and gates. The framework verifies its own development: every
iteration must leave `cairn scan` clean.

- docs/agent/cairn-dev-workflow.md: canonical loop with per-phase exit
  criteria and the cairn commands that gate each step
- .claude/commands/cairn-loop.md: /cairn-loop orchestrator command
- CLAUDE.md: point to the loop from "Using cairn in this repo"
- meta/decisions/adopt-cairn-dev-loop.md: decision record, the first
  written under the loop it describes

Used the loop on its own creation: orient/scope via cairn context,
neighbourhood, and rationale; verify via `cairn scan` (0 findings) and
`cairn hook all` (pass).

https://claude.ai/code/session_011eqwicBikHcRCCSbmu9XRM
Add test, PR, merge, and continue phases so the loop covers the whole
coding path, not just authoring: write a failing-then-passing test for
new behaviour, open one PR per logical unit, drive CI to green and
resolve review, then select the next unit and loop. Ten phases total.

- docs/agent/cairn-dev-workflow.md: phases 5 (Test), 8 (PR), 9 (Merge),
  10 (Continue) with exit criteria; path-to-merge via PR-activity gating
- .claude/commands/cairn-loop.md: ten-phase orchestrator, continuous
- meta/decisions/adopt-cairn-dev-loop.md: record the expansion

https://claude.ai/code/session_011eqwicBikHcRCCSbmu9XRM
Describe how the loop runs unattended: commit verified iterations to the
working branch and substitute an internal review DAG (strict warn=fail
build/clippy/scan, a subagent code-review pass, a subagent simplify pass,
re-verify until clean) for the human PR review gate. The bar does not
drop; it moves in-process.

https://claude.ai/code/session_011eqwicBikHcRCCSbmu9XRM
A blueprint path that matches a .gitignore pattern emits a Warning and
becomes a Ghost node, but `remediate_json` dropped the code in its
`_ => {}` arm, so `cairn remediate` reported "good shape" while
`cairn lint` warned about it. Map the finding to a node-specific
`fix_gitignored_path` action (priority 2, the drift tier) so remediate
and lint agree.

Test: tests/gitignore_lint.rs drives `cairn remediate --json` on a
gitignored declared path and asserts the action names the affected node.
Fails before the fix, passes after.

https://claude.ai/code/session_011eqwicBikHcRCCSbmu9XRM
git_init() built throwaway repos that inherit ambient commit-signing
config. In environments that enforce signing, the fixture's initial
commit fails, leaving HEAD without cairn.blueprint; the architecture
gate reads `git show HEAD:cairn.blueprint`, finds nothing to diff, and
passes, so the two "gate fires" tests failed. Set commit.gpgsign=false
in the fixture repo so commits always succeed. No product change.

https://claude.ai/code/session_011eqwicBikHcRCCSbmu9XRM
Track this session's loop work in beads: close the two fixes landed
(cairn-2r1 remediate gitignored mapping, cairn-9al architecture-gate
test signing) and file three genuine findings for follow-up:
- cairn-7km: handlers.rs exceeds the 500-line size gate (no directive)
- cairn-v1t (epic): wire decisions into the provenance graph
- (cairn-9al closed)

Export the backlog to .beads/issues.jsonl so it persists across clones;
ignore the local-only auto-import runtime file.

https://claude.ai/code/session_011eqwicBikHcRCCSbmu9XRM
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.

3 participants