Skip to content

MAS orchestration: health + remediate queries, webui fixes, scan caching - #127

Merged
George-RD merged 5 commits into
devfrom
feat-phase-7_6-queue-snapshot
Jun 3, 2026
Merged

MAS orchestration: health + remediate queries, webui fixes, scan caching#127
George-RD merged 5 commits into
devfrom
feat-phase-7_6-queue-snapshot

Conversation

@George-RD

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes reconciler duplication bug: each reconciler runs once per language instead of once per target
  • Adds dogfood.sh script with pre-push hook and CI workflow for automated self-linting
  • Implements MAS orchestration health and remediate query commands
  • Adds webui scan caching and server reliability improvements
  • All quality gates pass: cargo test (791+ tests), clippy, fmt, dogfood
  • cairn health reports clean: 23 synced modules, 0 errors/warnings/info

George-RD added 3 commits June 3, 2026 12:09
…d findings

The Rust/TS/Python/Go reconcilers scan the entire project root on every
call. reconcile_targets() called them once per target, so N targets produced
N copies of every orphaned-file finding. With 23 targets this produced 138
findings from 6 unique orphaned files.

Fix: cache reconciler results by Language inside the node loop so each
reconciler runs exactly once. Collect findings once per cached run, then
clear the cache before moving to the next node.

Also closes blueprint drift by declaring three orphaned modules:
- cairn.sse (src/sse.rs)
- cairn.state (src/state)
- cairn.watch (src/watch.rs)

cairn lint now exits 0. cairn hook all now passes.
- scripts/dogfood.sh: runs cairn lint + cairn hook all
- .git/hooks/pre-push: blocks push if dogfood gate fails
- .github/workflows/dogfood.yml: same gate in CI on PR/push
- docs/strongholds/next-phase-plan.md: comprehensive plan with priorities
Copilot AI review requested due to automatic review settings June 3, 2026 13:30
@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@George-RD, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 48 minutes and 51 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 53b17a00-2731-4997-8d78-12163eabaf98

📥 Commits

Reviewing files that changed from the base of the PR and between 184ec73 and 631740e.

📒 Files selected for processing (2)
  • .cairnignore
  • .github/workflows/dogfood.yml
📝 Walkthrough

Walkthrough

This PR resolves blueprint module drift by registering three orphaned Rust modules as top-level cairn declarations, introduces two new query commands (health and remediate) for assessing project state and generating ordered remediation actions, optimizes the scanner via per-language reconciliation caching, adds mtime-based result caching to the UI server, establishes CI enforcement via a dogfood script and workflow, simplifies UI animations, and documents orchestration patterns and future priorities.

Changes

Project Health Assessment and Infrastructure Optimization

Layer / File(s) Summary
Blueprint drift closure
cairn.blueprint, meta/decisions/close-blueprint-drift.md
Declares three previously orphaned modules (sse, state, watch) as top-level cairn.root modules and documents the acceptance decision with issue context.
Health & Remediate query handlers and registry
src/query_api/handlers.rs, src/query_api/registry.rs, src/query_api/mod.rs, src/cli/mod.rs
Implements health_json and remediate_json handlers that execute lint and hook scans, aggregate findings, determine clean state, and compute ordered remediation actions; registers both tools as read-only MCP tools; updates CLI to enforce JSON-only mode; wires dispatch and includes unit tests for both tools.
Health & Remediate user documentation
docs/integration-contract.md, docs/mcp.md, docs/commands.md, docs/agent-prompts.md, examples/demo/README.md
Documents health and remediate command taxonomy, MCP tool descriptions, MAS orchestration loop pattern, agent prompts for iterative health/remediate/action workflows, and demo usage examples.
Scanner reconciliation optimization
src/scanner/mod.rs
Caches reconciliation results per Language per node_id so each language reconciler runs once; derives per-target reports from cached output and aggregates findings only once per cached run.
UI server scan result caching
src/ui/server.rs
Adds in-memory cached_scan and cached_mtime fields to Server; checks blueprint modification time on load and reuses cached ScanResult when mtime unchanged, otherwise loads fresh and updates caches.
CI dogfood gate enforcement
scripts/dogfood.sh, .github/workflows/dogfood.yml
Introduces dogfood.sh script running cairn lint and cairn hook all with fail-fast; adds GitHub Actions workflow that builds release, installs cairn, and executes the dogfood gate on push/pull_request to dev/main.
Node animation simplification
src/ui_assets/style.css
Updates recon-settle keyframes to animate only opacity (removes scale transform) and removes associated transform-origin and transform-box declarations from .canvas-node.settling.
Phase planning documentation
docs/strongholds/next-phase-plan.md
Documents completed fixes, remaining known issues (webui rendering, server reliability), ranked next priorities, session checklist, and long-term roadmap.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

The PR involves multiple independent optimizations (scanner caching, UI server caching) and a substantial new query feature (health/remediate handlers with registry, CLI wiring, and comprehensive tests), spanning 19 files with mixed implementation density. The scanner caching logic and remediate_json handler are particularly dense, requiring careful review of state aggregation and priority sorting logic. The architectural decision to close blueprint drift and the comprehensive documentation add context but low technical complexity.

Possibly related PRs

  • cairn-framework/cairn#92: Adds context command and blueprint-change gate tests, directly aligned with this PR's addition of query tools and decision-driven architecture.
  • cairn-framework/cairn#119: Extends stable JSON-mode outputs for CLI commands, providing the same CLI JSON infrastructure that health/remediate commands now leverage.
  • cairn-framework/cairn#122: Implements findings rollup UI panel to display results that health query tool surfaces in JSON form.

Poem

🐰 Three orphaned modules find their home,
Health and remediate commands roam,
Scanner caches cut the duplication ache,
UI server speeds up for goodness sake,
CI gates now bark to keep us straight,
thump thump — quality assured, it's great!


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Docstring Coverage ❌ Error Docstring coverage is 43.75% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes in the PR: MAS orchestration features (health + remediate queries), webui improvements (caching), and scan optimizations.
Description check ✅ Passed The description is well-related to the changeset, covering key improvements: reconciler duplication fix, dogfood automation, MAS orchestration implementation, webui caching, and quality metrics.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-phase-7_6-queue-snapshot

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 expands Cairn’s MAS orchestration surface by adding health/remediate query tools and related docs/tests, while also attempting to improve web UI reliability via scan caching and fixing reconciler duplication behavior in the scanner.

Changes:

  • Added health and remediate tools to the query API (registry, dispatch, snapshots, tests) and documented the recommended orchestration loop.
  • Introduced UI server scan caching keyed off blueprint mtime and applied minor CSS adjustments for rendering stability.
  • Updated scanner reconciliation logic to cache reconciler runs by language (intended to eliminate duplicate orphan findings).

Reviewed changes

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

Show a summary per file
File Description
tests/snapshots/wire_format_snapshots__api_meta.snap Snapshot update to include health/remediate tools in API meta
src/ui/server.rs Adds blueprint-mtime-based scan caching for UI API routes
src/ui_assets/style.css Tweaks “settle” animation to avoid transform-based effects
src/scanner/mod.rs Attempts to dedupe reconciler runs/findings by caching per language
src/query_api/registry.rs Registers health/remediate tools and updates registry size test
src/query_api/mod.rs Routes health/remediate in query execution and adds tests
src/query_api/handlers.rs Implements health_json and remediate_json payloads
src/cli/mod.rs Marks health/remediate as requiring --json (shared JSON path)
scripts/dogfood.sh Adds a repo “dogfood” script (cairn lint + cairn hook all)
meta/decisions/close-blueprint-drift.md Adds decision artefact documenting blueprint drift closure
examples/demo/README.md Documents MAS orchestration usage in demo
docs/strongholds/next-phase-plan.md Adds internal plan doc for hardening and webui repair
docs/mcp.md Documents new MCP tools + recommended MAS loop
docs/integration-contract.md Adds health/remediate to integration contract table
docs/commands.md Adds CLI docs for health/remediate
docs/agent-prompts.md Adds suggested prompts for health/remediate loop
cairn.blueprint Declares previously orphaned modules (SSE/State/Watch)
.github/workflows/dogfood.yml Adds CI workflow to run the dogfood gate

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

Comment on lines +15 to +17
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

Comment thread src/scanner/mod.rs
Comment on lines +168 to 173
// Collect findings only once per cached reconciler run, not per target.
for report in reconciler_cache.values() {
all_findings.extend(report.findings.clone());
}
reconciler_cache.clear();
reports.extend(node_reports);
Comment thread src/scanner/mod.rs
Comment on lines +126 to 143
let report = reconciler_cache.entry(target.language).or_insert_with(|| {
let req = ReconcileRequest { root, ignores };
match target.language {
Language::Rust => rust_reconciler.reconcile(req).unwrap(),
Language::TypeScript => {
let reconciler =
crate::reconcile::typescript::TypeScriptReconciler::new(ast);
reconciler.reconcile(req).unwrap()
}
Language::Python => {
let reconciler = crate::reconcile::python::PythonReconciler::new(ast);
reconciler.reconcile(req).unwrap()
}
Language::Go => {
let reconciler = crate::reconcile::go::GoReconciler::new(ast);
reconciler.reconcile(req).unwrap()
}
}
Comment thread src/query_api/handlers.rs
Comment on lines +546 to +550
"CAIRN_CONTRACT_MISSING"
| "CAIRN_CONTRACT_MISSING_NODE"
| "CAIRN_CONTRACT_UNKNOWN_NODE" => {
has_orphans = true;
}
Comment thread src/ui/server.rs
Comment on lines +203 to +205
if !should_reload && let Some(scan) = self.cached_scan.borrow().as_ref() {
return Ok(scan.clone());
}
Comment thread docs/commands.md
Comment on lines 34 to 36
| `cairn lint` | Lint the blueprint and report findings (blocking) |

### Node inspection

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.

2 participants