-
Notifications
You must be signed in to change notification settings - Fork 2
Implement WorkSuggestion API and UI enhancements with Inbox features #165
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
46245a7
Implement Phase 2 enhancements for task execution approvals
harshlocham 2cfafbb
fix(execution): limit suggest_only bypass to explicit manager requests
harshlocham a5a8870
test(task-approvals): align suggest_only bypass assertions with S2.4
harshlocham b1bed59
fix(execution): tighten suggest_only bypass and explicit request reco…
harshlocham 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "@semantask/services": minor | ||
| "@semantask/web": patch | ||
| "@semantask/task-worker": patch | ||
| --- | ||
|
|
||
| Phase 2 PR5 — Explicit manager “Allow AI tools” / request-execution path, distinct from WorkSuggestion accept, reusing TaskAction approvals. |
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,53 @@ | ||
| /** | ||
| * S2.4 suggest_only exceptions for explicit manager request / human-approved re-entry. | ||
| * Pure helpers so unit tests can cover the gate without booting the full worker. | ||
| */ | ||
|
|
||
| export type SuggestOnlyExecutionPayloadFlags = { | ||
| humanApprovedExecution?: boolean; | ||
| explicitManagerRequest?: boolean; | ||
| needsApproval?: boolean; | ||
| }; | ||
|
|
||
| /** | ||
| * Skip the leaked-ingress fail-closed path only for the explicit manager | ||
| * "Allow AI tools" request (or its human-approved re-entry) — not for generic | ||
| * needsApproval / silent accept leaks. | ||
| */ | ||
| export function shouldSkipSuggestOnlyIngressFailClosed( | ||
| payload: SuggestOnlyExecutionPayloadFlags | ||
| ): boolean { | ||
| return payload.humanApprovedExecution === true | ||
| || payload.explicitManagerRequest === true; | ||
| } | ||
|
|
||
| export type SuggestOnlyPolicyOverrideInput = { | ||
| policyOutcome: string; | ||
| modeDeniedBySuggestOnly: boolean; | ||
| explicitManagerRequest?: boolean; | ||
| needsApproval?: boolean; | ||
| humanApprovedExecution?: boolean; | ||
| }; | ||
|
|
||
| /** | ||
| * Under suggest_only mode denial: | ||
| * - explicit manager request (not yet human-approved) → force approval_required | ||
| * - humanApprovedExecution after that explicit path → bypass mode denial | ||
| * (grants/policy still apply elsewhere) | ||
| */ | ||
| export function resolveSuggestOnlyPolicyOverride(input: SuggestOnlyPolicyOverrideInput): { | ||
| forceApprovalForExplicit: boolean; | ||
| bypassSuggestOnlyAfterHumanApproval: boolean; | ||
| } { | ||
| const forceApprovalForExplicit = input.policyOutcome === "blocked" | ||
| && input.modeDeniedBySuggestOnly | ||
| && input.explicitManagerRequest === true | ||
| && input.humanApprovedExecution !== true; | ||
|
|
||
| const bypassSuggestOnlyAfterHumanApproval = input.policyOutcome === "blocked" | ||
| && input.modeDeniedBySuggestOnly | ||
| && input.humanApprovedExecution === true | ||
| && input.explicitManagerRequest === true; | ||
|
|
||
| return { forceApprovalForExplicit, bypassSuggestOnlyAfterHumanApproval }; | ||
| } |
98 changes: 98 additions & 0 deletions
98
apps/task-worker/tests/suggest-only-execution-gate.test.ts
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,98 @@ | ||
| import assert from "node:assert/strict"; | ||
| import { test } from "node:test"; | ||
| import { | ||
| resolveSuggestOnlyPolicyOverride, | ||
| shouldSkipSuggestOnlyIngressFailClosed, | ||
| } from "../services/suggest-only-execution-gate.js"; | ||
|
|
||
| test("leaked suggest_only events do not skip fail-closed", () => { | ||
| assert.equal(shouldSkipSuggestOnlyIngressFailClosed({}), false); | ||
| assert.equal( | ||
| shouldSkipSuggestOnlyIngressFailClosed({ | ||
| explicitManagerRequest: false, | ||
| needsApproval: false, | ||
| humanApprovedExecution: false, | ||
| }), | ||
| false | ||
| ); | ||
| }); | ||
|
|
||
| test("needsApproval alone does not skip ingress fail-closed", () => { | ||
| assert.equal( | ||
| shouldSkipSuggestOnlyIngressFailClosed({ needsApproval: true }), | ||
| false | ||
| ); | ||
| }); | ||
|
|
||
| test("explicit manager request skips ingress fail-closed", () => { | ||
| assert.equal( | ||
| shouldSkipSuggestOnlyIngressFailClosed({ explicitManagerRequest: true }), | ||
| true | ||
| ); | ||
| }); | ||
|
|
||
| test("human-approved re-entry skips ingress fail-closed", () => { | ||
| assert.equal( | ||
| shouldSkipSuggestOnlyIngressFailClosed({ humanApprovedExecution: true }), | ||
| true | ||
| ); | ||
| }); | ||
|
|
||
| test("suggest_only + explicit → force approval_required (pending)", () => { | ||
| const result = resolveSuggestOnlyPolicyOverride({ | ||
| policyOutcome: "blocked", | ||
| modeDeniedBySuggestOnly: true, | ||
| explicitManagerRequest: true, | ||
| needsApproval: true, | ||
| humanApprovedExecution: false, | ||
| }); | ||
| assert.equal(result.forceApprovalForExplicit, true); | ||
| assert.equal(result.bypassSuggestOnlyAfterHumanApproval, false); | ||
| }); | ||
|
|
||
| test("suggest_only + needsApproval without explicit does not force approval", () => { | ||
| const result = resolveSuggestOnlyPolicyOverride({ | ||
| policyOutcome: "blocked", | ||
| modeDeniedBySuggestOnly: true, | ||
| explicitManagerRequest: false, | ||
| needsApproval: true, | ||
| humanApprovedExecution: false, | ||
| }); | ||
| assert.equal(result.forceApprovalForExplicit, false); | ||
| assert.equal(result.bypassSuggestOnlyAfterHumanApproval, false); | ||
| }); | ||
|
|
||
| test("suggest_only + humanApproved without explicit does not bypass", () => { | ||
| const result = resolveSuggestOnlyPolicyOverride({ | ||
| policyOutcome: "blocked", | ||
| modeDeniedBySuggestOnly: true, | ||
| explicitManagerRequest: false, | ||
| needsApproval: false, | ||
| humanApprovedExecution: true, | ||
| }); | ||
| assert.equal(result.forceApprovalForExplicit, false); | ||
| assert.equal(result.bypassSuggestOnlyAfterHumanApproval, false); | ||
| }); | ||
|
|
||
| test("suggest_only + explicit + humanApproved → bypass mode denial", () => { | ||
| const result = resolveSuggestOnlyPolicyOverride({ | ||
| policyOutcome: "blocked", | ||
| modeDeniedBySuggestOnly: true, | ||
| explicitManagerRequest: true, | ||
| needsApproval: false, | ||
| humanApprovedExecution: true, | ||
| }); | ||
| assert.equal(result.forceApprovalForExplicit, false); | ||
| assert.equal(result.bypassSuggestOnlyAfterHumanApproval, true); | ||
| }); | ||
|
|
||
| test("non-suggest_only blocks do not force approval or bypass", () => { | ||
| const result = resolveSuggestOnlyPolicyOverride({ | ||
| policyOutcome: "blocked", | ||
| modeDeniedBySuggestOnly: false, | ||
| explicitManagerRequest: true, | ||
| humanApprovedExecution: true, | ||
| }); | ||
| assert.equal(result.forceApprovalForExplicit, false); | ||
| assert.equal(result.bypassSuggestOnlyAfterHumanApproval, false); | ||
| }); |
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.
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.