Skip to content

[Feat] Add the Destructive Command Guard binary service - #1060

Open
navedmerchant wants to merge 1 commit into
feat/managed-binary-infrastructurefrom
feat/dcg-binary-service
Open

[Feat] Add the Destructive Command Guard binary service#1060
navedmerchant wants to merge 1 commit into
feat/managed-binary-infrastructurefrom
feat/dcg-binary-service

Conversation

@navedmerchant

Copy link
Copy Markdown
Contributor

Related GitHub Issue

Closes #1056
Part of #1049. Split from #1050.

Description

Adds a self-contained service boundary for the pinned Destructive Command Guard binary. It selects platform-specific archives, installs and verifies the binary through the managed-binary infrastructure, deduplicates concurrent installation requests, and runs DCG with typed allow/deny results.

This PR does not add a setting or change command auto-approval behavior.

Stack

2 / 4 — base: feat/managed-binary-infrastructure

Review only the six files in this PR's own diff. Merge after the managed-binary PR; GitHub will retarget the surviving stack automatically or the base can be changed to main after its dependency merges.

Test Procedure

pnpm --dir src exec vitest run services/destructive-command-guard/__tests__/manager.spec.ts services/destructive-command-guard/__tests__/runner.spec.ts
pnpm --dir src check-types

Result: 2 test files passed, 22 tests passed; type-check passed. Repository pre-push type-check also passed.

Checklist

  • Focused issue and independently meaningful service
  • Tests included and passing
  • Type-check/lint passing
  • No changeset added
  • No user-facing behavior enabled yet

@navedmerchant navedmerchant added the enhancement New feature or request label Jul 30, 2026
@navedmerchant navedmerchant added the enhancement New feature or request label Jul 30, 2026
@navedmerchant navedmerchant self-assigned this Jul 30, 2026
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 06f01a76-057f-4cdb-a5d6-3e5545d20cb8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.89189% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/services/destructive-command-guard/runner.ts 90.47% 0 Missing and 4 partials ⚠️
src/services/destructive-command-guard/manager.ts 92.30% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@navedmerchant
navedmerchant force-pushed the feat/dcg-binary-service branch from 5c460bd to baade5f Compare July 30, 2026 04:50
@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Jul 30, 2026

@edelauna edelauna left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good - just had 2 comments for increased test coverage.

const result = runDcg("/dcg", "echo test", "/workspace")
emitResult(child, payload, code)

await expect(result).resolves.toEqual(expected)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Every case here calls runDcg with "/workspace" as cwd, but none of the assertions check that it actually reaches spawn's options. Worth adding an expect(mockSpawn).toHaveBeenCalledWith(..., expect.objectContaining({ cwd: "/workspace" })) somewhere so a dropped/hardcoded cwd would fail?

"tar",
expect.arrayContaining(["-xJf", "/tmp/dcg.tar.xz", "-C", tempDir, "--no-same-owner"]),
expect.objectContaining({ shell: false }),
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since extractTarXzArchive appends --no-overwrite-dir on Linux, wouldn't arrayContaining/objectContaining here miss that flag being dropped or stdio being stripped? The ZIP test above uses an exact toHaveBeenCalledWith — could this match that for the same strictness?

@github-actions github-actions Bot added awaiting-author PR is waiting for the author to address requested changes and removed awaiting-review PR changes are ready and waiting for maintainer re-review labels Jul 31, 2026
sha256: string
}>

export const DCG_ARCHIVES: Readonly<Record<string, DcgArchiveInfo>> = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

added #1067 similar to what we could use for semble for dependency management

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-author PR is waiting for the author to address requested changes enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants