Skip to content

feat(sharecli): land fr007 health-pool-status-csv + agent-call admission kernel - #731

Merged
KooshaPari merged 1 commit into
mainfrom
chore/sharecli-shard-20260812
Aug 13, 2026
Merged

feat(sharecli): land fr007 health-pool-status-csv + agent-call admission kernel#731
KooshaPari merged 1 commit into
mainfrom
chore/sharecli-shard-20260812

Conversation

@KooshaPari

@KooshaPari KooshaPari commented Aug 13, 2026

Copy link
Copy Markdown
Owner

User description

Sharded content from feat/ac-007-82-health-pool-status-csv + feat/agent-call-policy-20260812 onto current main. The recovery/sharecli-dirty-20260801 preservation state is excluded (those files were for historical snapshot only, not for merge).

Includes:

  • fr007 health/pool/status --csv export (AC-007.82)
  • agent-call admission kernel + tests
  • FR + TRACEABILITY doc updates

CodeAnt-AI Description

Add guarded agent command admission and enforce one-shot CSV exports

What Changed

  • Agent-issued commands now receive a bounded deadline and are paused when they target hazardous system roots, exceed project or build concurrency limits, or lack thermal headroom.
  • Recursive grep searches are redirected to bounded project-scoped rg commands that skip common dependency and build directories.
  • Health, pool, and status CSV exports now reject --watch and report the CSV/watch conflict clearly; CSV output remains one-shot with gate, host, pool, and status companion records.
  • Specifications and traceability records now describe the supported one-shot CSV behavior and remove superseded watch, FUSE, and harness requirements.

Impact

✅ Safer agent-issued searches
✅ Fewer resource-overloaded agent calls
✅ Clearer CSV/watch command errors

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

… admission kernel

Sharded from feat/ac-007-82-health-pool-status-csv + feat/agent-call-policy-20260812
onto current main. Drops the sharecli-dirty-20260801 preservation noise (those
state files are not for merging — kept in branch for historical reference).

Includes:
- fr007 health/pool/status --csv export (AC-007.82)
- agent-call admission kernel + tests
Copilot AI lite review requested due to automatic review settings August 13, 2026 01:59
@codeant-ai

codeant-ai Bot commented Aug 13, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR e8fb436 Aug 13, 2026 · 01:59 02:01

@codeant-ai

codeant-ai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@KooshaPari
KooshaPari merged commit e2ceacd into main Aug 13, 2026
33 of 45 checks passed
@KooshaPari
KooshaPari deleted the chore/sharecli-shard-20260812 branch August 13, 2026 01:59
@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Aug 13, 2026
@coderabbitai

coderabbitai Bot commented Aug 13, 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: ASSERTIVE

Plan: Pro Plus

Run ID: 0dd09c1f-1be6-4b2c-b762-e62e96901a7f

📥 Commits

Reviewing files that changed from the base of the PR and between 3b76823 and e8fb436.

📒 Files selected for processing (6)
  • docs/specs/FR.md
  • docs/specs/TRACEABILITY.md
  • src/agent_call_policy.rs
  • src/lib.rs
  • tests/agent_call_policy.rs
  • tests/fr007_health_pool_status_csv.rs

📝 Walkthrough

Summary

This PR adds:

  • fr007 health/pool/status --csv one-shot export rules and tests.
  • Public AgentCallPolicy admission logic with pause decisions, limits, command normalization, and deadlines.
  • Integration tests for agent-call policy behavior.
  • FR and traceability documentation updates.

The changes appear focused and suitable for merge.

Must Fix

No blocking issues identified from the provided change summary.

Should Fix

Run and confirm:

  • cargo fmt --all -- --check
  • cargo clippy --workspace -- -D warnings
  • cargo test --workspace

Consider

  • Keep all new public policy types documented and derive Debug and Clone where practical.
  • Confirm that CSV rejection behavior remains consistent across report, health, pool, and status.

Approve / Request Changes

Approve, subject to successful formatting, clippy, and workspace test checks.

Walkthrough

Changes

Agent call admission policy

Layer / File(s) Summary
Policy implementation and validation
src/agent_call_policy.rs, src/lib.rs, tests/agent_call_policy.rs
The crate exposes AgentCallPolicy, command normalization, hazardous-root checks, project and build limits, thermal gating, pause decisions, and deadlines. Tests cover these behaviors.

Specification and CSV compatibility updates

Layer / File(s) Summary
CSV compatibility requirements and tests
docs/specs/FR.md, docs/specs/TRACEABILITY.md, tests/fr007_health_pool_status_csv.rs
CSV requirements reject incompatible --watch, PID, and JSON combinations. Traceability and tests cover report and health/pool/status CSV behavior.
FR-008 and FR-009 scope reduction
docs/specs/FR.md, docs/specs/TRACEABILITY.md
FR-008 removes cache-key, normalization, and Hypervisor execution criteria. FR-009 limits FUSE coverage to Linux and macOS and removes expanded mount, session, CoW, and CLI criteria.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/sharecli-shard-20260812
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch chore/sharecli-shard-20260812

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.

@sonarqubecloud

Copy link
Copy Markdown

Comment thread src/agent_call_policy.rs
Comment on lines +126 to +129
self.admitted_calls.set(self.admitted_calls.get().saturating_add(1));
if build {
self.admitted_builds.set(self.admitted_builds.get().saturating_add(1));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: The admission counters are incremented for every admitted call, but there is no release method or RAII guard to decrement them when the command finishes. After project_limit calls, or after build_slots builds, every subsequent admission remains paused permanently even though the resume condition says to wait for an active call or build to finish. Return a permit whose Drop implementation releases the corresponding counters, matching the existing build-slot lifecycle. [missing cleanup]

Severity Level: Critical 🚨
- ❌ Limited project policies eventually reject every subsequent call.
- ❌ Limited build pools permanently reject later build commands.
- ⚠️ Pause messages promise recovery that cannot occur.

Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** src/agent_call_policy.rs
**Line:** 126:129
**Comment:**
	*Missing Cleanup: The admission counters are incremented for every admitted call, but there is no release method or RAII guard to decrement them when the command finishes. After `project_limit` calls, or after `build_slots` builds, every subsequent admission remains paused permanently even though the resume condition says to wait for an active call or build to finish. Return a permit whose `Drop` implementation releases the corresponding counters, matching the existing build-slot lifecycle.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment thread src/agent_call_policy.rs
Comment on lines +149 to +158
let mut positional = words[1..].iter().copied().filter(|word| !word.starts_with('-'));
let pattern = positional.next().unwrap_or("");
let target = match positional.next() {
Some(".") | None => self.project_root.as_path(),
Some(target) => Path::new(target),
};
format!(
"rg --hidden --glob '!target' --glob '!node_modules' {pattern} {}",
target.display()
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: The recursive-grep rewrite parses shell input with split_whitespace, then reconstructs the pattern and target without quoting and discards every dash-prefixed argument. A command such as grep -R "foo bar" . is rewritten with only "foo as the pattern and bar" as the target, while options such as --include or --exclude silently disappear. This changes the search semantics and can produce an invalid or unintended command; preserve shell argument boundaries and translate supported grep options explicitly with proper escaping. [api mismatch]

Severity Level: Major ⚠️
- ❌ Agent searches with spaces query incorrect patterns.
- ❌ Include and exclude filters disappear during normalization.
- ⚠️ Search results can include unintended files.

Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** src/agent_call_policy.rs
**Line:** 149:158
**Comment:**
	*Api Mismatch: The recursive-grep rewrite parses shell input with `split_whitespace`, then reconstructs the pattern and target without quoting and discards every dash-prefixed argument. A command such as `grep -R "foo bar" .` is rewritten with only `"foo` as the pattern and `bar"` as the target, while options such as `--include` or `--exclude` silently disappear. This changes the search semantics and can produce an invalid or unintended command; preserve shell argument boundaries and translate supported grep options explicitly with proper escaping.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment thread src/agent_call_policy.rs
Comment on lines +187 to +210
fn targets_hazardous_root(command: &str) -> bool {
command.split_whitespace().any(|word| is_hazardous_root(Path::new(word)))
}

fn is_hazardous_root(path: &Path) -> bool {
const ROOTS: &[&str] = &[
"/",
"/Applications",
"/Library",
"/System",
"/Users",
"/bin",
"/dev",
"/etc",
"/opt",
"/private",
"/proc",
"/sys",
"/tmp",
"/usr",
"/var",
"/Volumes",
];
ROOTS.iter().any(|root| path == Path::new(root))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: The hazardous-root check only accepts exact path matches, so recursive searches of descendants such as /System/Secrets, /etc/shadow, or /proc/1 bypass the policy even though they remain host-level roots. Equivalent paths containing .. or redundant components also bypass it. Normalize or canonicalize the candidate path and reject paths that are the hazardous root or descendants of one. [security]

Severity Level: Critical 🚨
- ❌ Host-level descendant searches bypass hazardous-root admission.
- ⚠️ Sensitive system files may be searched by agent commands.
- ⚠️ Path aliases weaken the intended project boundary.

Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** src/agent_call_policy.rs
**Line:** 187:210
**Comment:**
	*Security: The hazardous-root check only accepts exact path matches, so recursive searches of descendants such as `/System/Secrets`, `/etc/shadow`, or `/proc/1` bypass the policy even though they remain host-level roots. Equivalent paths containing `..` or redundant components also bypass it. Normalize or canonicalize the candidate path and reject paths that are the hazardous root or descendants of one.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment on lines +230 to +246
/// FR-007 / AC-007.82 — health --csv rejects --watch (one-shot export only).
#[test]
#[serial_test::serial]
fn fr007_health_csv_rejects_watch() {
let out = bin()
.args(["health", "--csv", "--watch", "1"])
.output()
.expect("spawn sharecli health --csv --watch 1");
assert!(
!out.status.success(),
"health --csv --watch MUST fail loudly (AC-007.82)"
);
let stderr = String::from_utf8_lossy(&out.stderr);
assert!(
stderr.contains("csv") && stderr.contains("watch"),
"error MUST mention csv/watch incompatibility (AC-007.82); stderr: {stderr}"
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: This test introduces a contradictory contract: the existing fr007_operator_csv_watch integration test requires health --csv --watch 1 to emit multiple CSV frames, and the current command implementation enters that watch loop, but this newly added test requires the same invocation to fail. The test suite cannot satisfy both requirements; either remove this rejection test or update the command and the existing watch contract together according to the intended API. [api mismatch]

Severity Level: Major ⚠️
- ❌ CI cannot satisfy both health CSV contracts.
- ❌ Existing watch behavior conflicts with new one-shot requirements.
- ⚠️ Operators receive inconsistent documented CLI semantics.

Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** tests/fr007_health_pool_status_csv.rs
**Line:** 230:246
**Comment:**
	*Api Mismatch: This test introduces a contradictory contract: the existing `fr007_operator_csv_watch` integration test requires `health --csv --watch 1` to emit multiple CSV frames, and the current command implementation enters that watch loop, but this newly added test requires the same invocation to fail. The test suite cannot satisfy both requirements; either remove this rejection test or update the command and the existing watch contract together according to the intended API.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e8fb436b63

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +238 to +240
assert!(
!out.status.success(),
"health --csv --watch MUST fail loudly (AC-007.82)"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep health CSV watch expectations consistent

This new test now requires health --csv --watch 1 to fail, but the command implementation still accepts that combination by entering the CSV watch branch in src/commands/mod.rs::health, and the existing tests/fr007_operator_csv_watch.rs::fr007_health_csv_watch_stderr_silent_and_envelope still asserts the same command streams CSV frames successfully. As written, the added assertion conflicts with existing behavior and will fail the required test gate until the CLI implementation and old watch contract/tests are updated together.

AGENTS.md reference: AGENTS.md:L134-L140

Useful? React with 👍 / 👎.

Comment thread src/agent_call_policy.rs
Comment on lines +187 to +188
fn targets_hazardous_root(command: &str) -> bool {
command.split_whitespace().any(|word| is_hazardous_root(Path::new(word)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Parse shell quoting before checking hazardous roots

When an agent uses normal shell quoting around a hazardous root, such as rg TODO "/" or grep -R TODO "/", this whitespace split leaves the quotes in the token, so Path::new("\"/\"") does not match / and the decision is admitted; the returned command would then be interpreted by the shell as a search of the filesystem root. Parse the command as shell argv, or otherwise unquote/lexically normalize paths, before applying the hazardous-root check.

Useful? React with 👍 / 👎.

Comment thread src/agent_call_policy.rs
Comment on lines +126 to +128
self.admitted_calls.set(self.admitted_calls.get().saturating_add(1));
if build {
self.admitted_builds.set(self.admitted_builds.get().saturating_add(1));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Return a releasable permit for admitted calls

When a finite project or build limit is configured and the same policy instance is reused, every admitted call permanently increments these counters, but there is no handle or release method that decrements them after the command finishes. After limit successful calls, the policy will return ProjectLimit/BuildSlot forever even though no calls are active, making the limits lifetime quotas instead of active concurrency controls.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown

Quality Gate Report

✅ Unit Tests: PASSED
⏭️ E2E Tests: SKIPPED (no e2e directory)
⏭️ Integration Tests: SKIPPED (no integration directory)
❌ FR Annotations: MISSING

mergify Bot pushed a commit that referenced this pull request Aug 14, 2026
…733)

* fix(test): repair fr007 health-csv test for StatusJson::log_location

e2ceacd (#731) added log_location to StatusJson and updated seven of the
eight fr007 test literals but missed tests/fr007_health_pool_status_csv.rs,
which omits the required field (E0063) and was never rustfmt-formatted.
Main's own ci-gate run on e2ceacd fails; every PR against it inherits the
break.

- Add `log_location: None` to the StatusJson literal.
- cargo fmt --all reflow of the file.

Verified: cargo fmt --all -- --check (0 diffs) and cargo check
--workspace --all-targets both pass.

* ci: re-trigger checks after stuck coverage runner

* fix(test): remove stale health --csv --watch rejection test

fr007_health_csv_rejects_watch asserted that `sharecli health --csv --watch 1`
must fail fast (a misreading of AC-007.82), but AC-007.89 defines health
--csv --watch as a supported multi-frame watch mode and both
tests/fr007_operator_csv_watch.rs and the envelope-parity suite exercise it
as working behavior; the CLI implements the watch loop.

The stale test spawned the infinite watch process and blocked on
output() forever, hanging the fr007 test binary and stalling the Coverage
lane's cargo llvm-cov run (reproduced locally: the suite hung on this test
with and without instrumentation; CI coverage ran 2h45m without
completing).

Remove the test; the AC-007.89 watch envelope behavior remains covered by
fr007_operator_csv_watch.rs / fr007_operator_envelope_parity_suite.rs.
KooshaPari added a commit that referenced this pull request Aug 15, 2026
* fix(test): repair fr007 health-csv test for StatusJson::log_location

e2ceacd (#731) added log_location to StatusJson and updated seven of the
eight fr007 test literals but missed tests/fr007_health_pool_status_csv.rs,
which omits the required field (E0063) and was never rustfmt-formatted.
Main's own ci-gate run on e2ceacd fails; every PR against it inherits the
break.

- Add `log_location: None` to the StatusJson literal.
- cargo fmt --all reflow of the file.

Verified: cargo fmt --all -- --check (0 diffs) and cargo check
--workspace --all-targets both pass.

* ci: re-trigger checks after stuck coverage runner

* fix(test): remove stale health --csv --watch rejection test

fr007_health_csv_rejects_watch asserted that `sharecli health --csv --watch 1`
must fail fast (a misreading of AC-007.82), but AC-007.89 defines health
--csv --watch as a supported multi-frame watch mode and both
tests/fr007_operator_csv_watch.rs and the envelope-parity suite exercise it
as working behavior; the CLI implements the watch loop.

The stale test spawned the infinite watch process and blocked on
output() forever, hanging the fr007 test binary and stalling the Coverage
lane's cargo llvm-cov run (reproduced locally: the suite hung on this test
with and without instrumentation; CI coverage ran 2h45m without
completing).

Remove the test; the AC-007.89 watch envelope behavior remains covered by
fr007_operator_csv_watch.rs / fr007_operator_envelope_parity_suite.rs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants