-
Notifications
You must be signed in to change notification settings - Fork 3
fix: sandbox worker sessions #14
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Independent evaluation | ||
|
|
||
| AgentLoop ran the reproducible [query parser fixture](../examples/query-parser) with three cycles available and polish disabled. The [plan](../examples/query-parser/PLAN.md) requested the complete repair in one pass and prohibited artificial cycle boundaries. The [guidelines](../examples/query-parser/GUIDELINES.md) defined ten acceptance criteria. | ||
|
|
||
| The committed fixture is the pre-run starting state. A reproduction run repairs that working copy, adds tests, and updates `STATE.md`. | ||
|
|
||
| | Cycle | Worker result | Independent critic result | | ||
| | --- | --- | --- | | ||
| | 1 | Repaired the parser and added nine passing tests. | `FAIL`: valid percent escapes remained encoded when a field also contained malformed escapes. | | ||
| | 2 | Fixed tolerant decoding and added regression coverage. | `PASS`: all criteria were satisfied and 11 tests passed. | | ||
|
|
||
| The first worker's own suite passed. A fresh critic tested beyond it, found a real defect, and converted the finding into instructions for the next fresh worker. No package dependencies were added. | ||
|
|
||
| ## Reproduce | ||
|
|
||
| 1. Start the daemon and select **+ New**, then **Loop**. | ||
| 2. Set **Project** to `examples/query-parser` and **Max cycles** to `3`. | ||
| 3. Leave polish disabled and select **Start loop**. |
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,12 @@ | ||
| # Quality Guidelines | ||
|
|
||
| - `parseQuery(input)` accepts strings and throws `TypeError` for other values. | ||
| - A leading `?` is optional; an empty query returns an empty object. | ||
| - Keys and values decode percent escapes and convert `+` to spaces. | ||
| - Repeated keys become arrays in encounter order. | ||
| - A key without `=` receives an empty string value. | ||
| - Malformed percent escapes remain readable instead of crashing the parser. | ||
| - Keys such as `__proto__`, `constructor`, and `prototype` cannot mutate object prototypes. | ||
| - The command-line entry point accepts one query argument, prints JSON, and shows usage with a non-zero exit when missing. | ||
| - Tests use the built-in Node test runner and cover every requirement. | ||
| - No package dependencies are added. |
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,8 @@ | ||
| # Query parser repair | ||
|
|
||
| Repair `query-string.js` for use as a dependable CommonJS utility and command-line tool. | ||
|
|
||
| - Preserve the `parseQuery(input)` export. | ||
| - Replace the fragile parsing behavior with a robust implementation. | ||
| - Add focused automated tests and concise command-line usage. | ||
| - Complete the task in one pass if possible. Do not create artificial cycle boundaries. |
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,13 @@ | ||
| # State | ||
|
|
||
| ## Completed | ||
|
|
||
| - Nothing yet. | ||
|
|
||
| ## Next | ||
|
|
||
| - Repair the query parser and verify it. | ||
|
|
||
| ## Notes | ||
|
|
||
| - No critic feedback yet. | ||
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,9 @@ | ||
| function parseQuery(input) { | ||
| const query = input.replace(/^\?/, ''); | ||
|
|
||
| return Object.fromEntries(query.split('&').map((part) => ( | ||
| part.split('=').map((value) => decodeURIComponent(value)) | ||
| ))); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
|
|
||
| module.exports = { parseQuery }; | ||
|
aiedwardyi marked this conversation as resolved.
|
||
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,37 @@ | ||
| const test = require('node:test'); | ||
| const assert = require('node:assert/strict'); | ||
| const fs = require('node:fs'); | ||
| const path = require('node:path'); | ||
|
|
||
| const daemonSource = fs.readFileSync(path.join(__dirname, '..', 'src', 'daemon.js'), 'utf8'); | ||
| const sandboxArgs = [ | ||
| "'--sandbox', 'workspace-write'", | ||
| "'approval_policy=\"on-request\"'", | ||
| "'approvals_reviewer=\"auto_review\"'", | ||
| "'sandbox_workspace_write.network_access=false'", | ||
| ]; | ||
|
|
||
| function getSessionArgs(functionName) { | ||
| const functionStart = daemonSource.indexOf(`function ${functionName}(`); | ||
| const functionEnd = daemonSource.indexOf('\nfunction ', functionStart + 1); | ||
| const argsStart = daemonSource.indexOf(' const args = [', functionStart); | ||
| const argsEnd = daemonSource.indexOf('\n ];', argsStart); | ||
|
|
||
| assert.notEqual(functionStart, -1); | ||
| assert.ok(argsStart > functionStart); | ||
| assert.ok(argsEnd > argsStart); | ||
| assert.ok(functionEnd === -1 || argsEnd < functionEnd); | ||
| return daemonSource.slice(argsStart, argsEnd); | ||
| } | ||
|
|
||
| test('Codex sessions use workspace sandboxing', () => { | ||
| assert.doesNotMatch(daemonSource, /--dangerously-bypass-approvals-and-sandbox/); | ||
|
|
||
| for (const functionName of ['spawnLoopSession', 'spawnWorker']) { | ||
| const args = getSessionArgs(functionName); | ||
|
|
||
| for (const expectedArg of sandboxArgs) { | ||
| assert.ok(args.includes(expectedArg), `${functionName} is missing ${expectedArg}`); | ||
| } | ||
| } | ||
| }); |
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.