Skip to content

Add dela allow#166

Merged
aleyan merged 4 commits into
mainfrom
allowlist
May 21, 2026
Merged

Add dela allow#166
aleyan merged 4 commits into
mainfrom
allowlist

Conversation

@aleyan
Copy link
Copy Markdown
Owner

@aleyan aleyan commented May 21, 2026

Summary by CodeRabbit

  • New Features

    • Added a CLI subcommand to allow a specific task at Task scope; validates task names and reports clear success, not-found, or ambiguity messages.
  • Tests

    • Added serial and integration tests covering success, unknown-task, missing-config, ambiguous-name handling, and end-to-end shell verification.
  • Documentation

    • Updated project plan checklist to mark the related task as completed.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f4a238ee-8dcc-4996-83ed-69b8a7cb2e8d

📥 Commits

Reviewing files that changed from the base of the PR and between e1e820c and f35b25e.

📒 Files selected for processing (1)
  • tests/docker_noinit/test_noinit.sh

📝 Walkthrough

Walkthrough

Implements a new dela allow CLI command with execution logic to discover and allowlist a single task (handling no-match and ambiguity), adds unit and integration tests, updates cargo baseline metrics, and marks the project task DTKT-109 complete.

Changes

Implement dela allow Command

Layer / File(s) Summary
CLI Entry Point
src/main.rs, src/commands/mod.rs
Commands::Allow { task: String } enum variant added; run_command() dispatch routes to commands::allow::execute(); allow module declared.
Allow Command Implementation
src/commands/allow.rs
execute(task_name) discovers tasks from cwd, filters by name including disambiguated variants, updates allowlist for exactly one match, and returns precise errors for zero or multiple matches with stderr ambiguity output.
Tests and Integration
src/commands/allow.rs, tests/docker_noinit/test_noinit.sh
Adds test helpers to set up isolated HOME/project, unit tests for single-task allow, nonexistent task, uninitialized config, and disambiguation, plus an integration Test 31 exercising dela allow end-to-end.
Tooling / Baseline
cargo_crap_baseline.json
Adds baseline entry for execute and updates recorded function line numbers and coverage entries for run_command, main, and evaluate_task_against_allowlist.
Project Tracking
dev_docs/project_plan.md
Marks DTKT-109 ("Implement dela allow command to add allowlist entries.") as completed.

Sequence Diagram

sequenceDiagram
  participant User
  participant CLI
  participant AllowCmd as allow::execute()
  participant TaskDiscovery
  participant Allowlist
  User->>CLI: dela allow <task_name>
  CLI->>AllowCmd: execute(task_name)
  AllowCmd->>TaskDiscovery: discover_tasks(cwd)
  TaskDiscovery-->>AllowCmd: available_tasks
  AllowCmd->>AllowCmd: filter by task_name (incl. disambiguation)
  alt single match
    AllowCmd->>Allowlist: write allowlist entry (scope = Task)
    Allowlist-->>AllowCmd: write confirmation
    AllowCmd-->>CLI: Ok (confirmation)
    CLI-->>User: success message
  else no matches
    AllowCmd-->>CLI: Err("dela: command or task not found: {task_name}")
    CLI-->>User: error message
  else multiple matches
    AllowCmd->>AllowCmd: format ambiguity message
    AllowCmd-->>User: ambiguity on stderr
    AllowCmd-->>CLI: Err("Multiple tasks named '{task_name}' found")
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • aleyan/dela#163: Related cargo baseline / metrics entries for run_command and commands/allow::execute.
  • aleyan/dela#156: Refactors allowlist evaluation logic that interacts with new allowlist entries.
  • aleyan/dela#153: Adjusts allowlist path handling and related tests used by the new integration assertions.

"🐰 Small paws on keys, I hopped to code today,
I added allow so tasks can safely stay,
Tests in my burrow check each ambiguous clue,
A carrot for DTKT‑109—hoppity, we’re through! 🥕"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add dela allow' directly and clearly summarizes the main change: implementing a new CLI subcommand for the dela allow command, which is the primary feature across all modified files.
Docstring Coverage ✅ Passed Docstring coverage is 90.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 allowlist

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/commands/allow.rs`:
- Around line 84-100: The tests (e.g., test_execute_allow_single_task) call
reset_to_real_environment() only at the end, which leaks state if a panic
occurs; make teardown panic-safe by introducing a scope guard or using
std::panic::catch_unwind so reset_to_real_environment() always runs.
Specifically, add a TestEnvGuard (or similar) that calls
setup_test_env()/preferred_allowlist_path_for(...) in its constructor and calls
reset_to_real_environment() in Drop, then instantiate it at the start of each
test (or wrap the test body in catch_unwind and call reset_to_real_environment()
in a finally-like branch). Update all affected tests (those using
setup_test_env() and reset_to_real_environment()) to use the guard or
catch_unwind to ensure cleanup on panic.

In `@tests/docker_noinit/test_noinit.sh`:
- Around line 852-858: The test only checks for the "print-args" task name in
/home/testuser/.config/dela/allowlist.toml but must also assert the Task scope;
update the block that currently greps for "print-args" to additionally verify
the scope value (e.g., ensure the allowlist entry for "print-args" includes
scope = "Task") by either grepping for a combined pattern or checking the lines
around the matched task name (use grep -A/B or awk to find the "print-args"
section and assert a following line like 'scope = "Task"'), and keep the same
success/failure echo and exit behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6f495c1c-de2b-4089-8b52-a0723ab19103

📥 Commits

Reviewing files that changed from the base of the PR and between 4293b60 and 3073d15.

📒 Files selected for processing (5)
  • dev_docs/project_plan.md
  • src/commands/allow.rs
  • src/commands/mod.rs
  • src/main.rs
  • tests/docker_noinit/test_noinit.sh

Comment thread src/commands/allow.rs
Comment thread tests/docker_noinit/test_noinit.sh Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/docker_noinit/test_noinit.sh`:
- Around line 853-856: The current check uses "grep -B 2" which is brittle;
instead locate the allowlist TOML table/entry for name = "print-args" and then
assert its scope field equals "Task" in an entry-aware way. Update the test to
parse /home/testuser/.config/dela/allowlist.toml by finding the block or stanza
that contains name = "print-args" (e.g., with awk/perl: search for the line with
name = "print-args", then scan lines within that entry for scope = "Task") and
base the pass/fail echo on that exact-entry match rather than relying on
context-line ordering.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6720e65c-da9d-4012-a868-326249e8c030

📥 Commits

Reviewing files that changed from the base of the PR and between 3073d15 and e1e820c.

📒 Files selected for processing (3)
  • cargo_crap_baseline.json
  • src/commands/allow.rs
  • tests/docker_noinit/test_noinit.sh

Comment thread tests/docker_noinit/test_noinit.sh Outdated
@aleyan aleyan merged commit 515d1cc into main May 21, 2026
9 checks passed
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