Repository navigation
fix(cli): translate the shields exit sentinel into a clean exit code #7421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7e1262e
fix(cli): translate the shields exit sentinel into a clean exit code
Dongni-Yang 9187ee2
style(shields): collapse deferred-exit destructure to one line per biome
Dongni-Yang dea8386
Merge branch 'main' into fix/7382-shields-sentinel-exit
Dongni-Yang 2cc00f7
Merge branch 'main' into fix/7382-shields-sentinel-exit
Dongni-Yang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| /** | ||
| * Sentinel thrown in place of process.exit while a shields transition lock is | ||
| * active: process.exit skips finally blocks and would strand the canonical | ||
| * lock. Public command wrappers translate the sentinel into an exit code once | ||
| * every lock has been released (NemoClawCommand.catch). | ||
| * | ||
| * Kept in a leaf module so the CLI base command can guard against the | ||
| * sentinel without loading the shields coordinator, and so tests that mock | ||
| * the shields module keep the real guard. | ||
| */ | ||
| export class DeferredShieldsExit extends Error { | ||
| readonly exitCode: number; | ||
|
|
||
| constructor(message: string, exitCode: number) { | ||
| super(message); | ||
| this.name = "DeferredShieldsExit"; | ||
| this.exitCode = exitCode; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Name-keyed guard: instanceof breaks when dist and src copies of the class | ||
| * are both loaded, so match on the sentinel's shape instead (same pattern as | ||
| * snapshotCommandError). | ||
| */ | ||
| export function isDeferredShieldsExit(error: unknown): error is DeferredShieldsExit { | ||
| if (!error || typeof error !== "object") return false; | ||
| const candidate = error as { name?: unknown; exitCode?: unknown }; | ||
| return candidate.name === "DeferredShieldsExit" && typeof candidate.exitCode === "number"; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.