Repository navigation
[Epic] Agents v1: Scheduled Autonomous Report Agents Platform - #2821
Conversation
…issue #2800. The shared package builds, `npm run typecheck` is clean, and the new test file passes (21 of 21 tests). To get the build and typecheck running I first had to install dependencies with `npm ci --ignore-scripts`, since this worktree had none. I also had to build `@propr/local-setup`: before that, typecheck failed in `packages/api/publicInstanceIdentity.ts` because it couldn't find that module. That error had nothing to do with this change. `packages/shared/src/agentDefinitions.ts` - Everything the issue lists, written in the same style as `goalCreation.ts`: plain functions that return a user-facing error string or `null`. - `isUnattendedTrigger` returns `false` only for `manual`. - Repository handles reuse `GOAL_REPOSITORY_PATTERN`. - `AGENT_TYPES_SUPPORTING_PROPR_MCP` is `['claude', 'codex']`, with a small helper `agentTypeSupportsProprMcp`. - `validateAgentDefinitionInput(input, { partial })` rejects every case in the acceptance criteria. As the issue specifies, it does not require `propr_mcp` for `auto`. - My additions, beyond the spec: - The validator also rejects duplicate repositories or capabilities, and checks `enabled`, `agentId`, `model` and `previousReportCount` when they are given. - I added defaults (capabilities `['repository_read']`, autonomy `dry_run`) and type guards for each vocabulary list. Limits I chose (the issue didn't give numbers, so adjust as you see fit): | Limit | Value | | --- | --- | | Name | 100 characters | | Description | 1,000 characters | | Prompt | 32,768 characters | | Repositories | 10 | | Attachments | 10 | | Previous reports | up to 5 (default 0), 50,000 characters combined | | Schedule expression | 128 characters | The interfaces also include fields of my own, such as `reportTaskId` and `actingTaskId` on `AgentRun`. Later issues may want to reshape them. `packages/shared/src/cronSchedule.ts` - `parseCronExpression` handles everything the issue lists. It also accepts both 0 and 7 as Sunday. When both day-of-month and day-of-week are set, a day matches if either one does, which is how standard cron behaves. - `nextCronOccurrence` works in UTC only and steps minute by minute, skipping days and hours that can't match. It gives up and throws after 366 days. - `validateAgentSchedule`: - Rejects malformed expressions and anything that fires more often than every 15 minutes. This includes gaps that cross midnight, such as 23:55 followed by 00:05. - Rejects schedules that never fire (`0 0 31 2 *`) and ones that fire less than once a year, such as `0 0 29 2 *`. Without that check the scheduler's 366-day search could throw on a schedule that validation had accepted. Other changes - Both modules are re-exported from `packages/shared/src/index.ts`. - `test/agentDefinitionsContract.test.ts` covers every acceptance case: `*/15` after 10:07Z gives 10:15Z, `@daily` gives the next midnight, `0 9 * * 1-5` skips the weekend, and the validation rejections. There's nothing visual in this change, so I didn't create any previews.
…. The new test file passes (10 of 10), `npm run typecheck` is clean, and the migration applies and rolls back cleanly on a file database built from all the earlier migrations.
Migration (`packages/core/src/db/migrations/20261006000000_create_agent_definitions.js`)
- Creates `agent_definitions` and `agent_runs` with the columns, defaults and indexes the issue lists.
- Deleting a definition deletes its runs.
- `(definition_id, idempotency_key)` is unique. Rows with no key are never treated as duplicates.
- `down` drops `agent_runs` first, then `agent_definitions`.
Store (`packages/core/src/services/agents/agentDefinitionStore.ts`)
- It has the seven functions the issue lists. Each takes an optional `{ database, now }`, the same way `epicExecutionQueue` does, and every read, update and delete filters by owner. Another owner's definition comes back as `undefined` (or `false` from delete).
- Bad stored data: if a JSON column can't be read, it becomes an empty array. Unknown capabilities and attachments without an id are dropped, and an unknown autonomy mode falls back to `dry_run`. So one damaged row can't break the list page.
- Next run time: it's recalculated in UTC whenever the cron, the schedule switch or the enabled flag changes, and set on create. It stays empty unless the definition is enabled, scheduled and has a cron.
- Revisions: a stale `expectedRevision` throws an error with `status: 409`. The write also checks the revision it read, so two simultaneous edits can't both succeed.
- Store types: the store uses its own types, which match the database columns rather than the shared `AgentDefinition` contract from issue 1. The two use different names and units (for example epoch milliseconds here, ISO strings there), so they'll need mapping or aligning when the API is built.
- It's exported from `packages/core/src/index.ts`.
Choices the issue didn't settle:
- Attachments don't change the revision. `setAgentDefinitionAttachments` updates `updated_at` only, so uploading a file doesn't make an open edit fail with 409. Say if you'd rather it counted as an edit.
- Schedules are UTC only. The timezone column is always written as `'UTC'` and the store has no way to set it, matching issue 1's UTC-only scheduling.
- A bad cron is rejected with `status: 400` when the store has to calculate the next run time.
- Paging uses `{ limit, offset }` (default 50, at most 200), newest first, and returns `{ definitions, total, limit, offset }`.
Tests (`test/agentDefinitionStore.test.ts`) run the real migrations against an in-memory SQLite database. They cover each acceptance criterion, plus a damaged-JSON row, the 400 on a bad cron and the unique run key.
Rolling back the whole database in one step (all 79 migrations) failed in another migration's rollback. I didn't track down which one. Rolling back just this migration and reapplying it worked.
Nothing in this change is visible in the UI, so I didn't create any previews.
…y module that writes `agent_runs`, and exported it from `packages/core/src/index.ts`. The new tests pass (13 of 13) and `npm run typecheck` is clean. Like the earlier agent tests, they have to be run with `tsx`, which is how `npm run test:server` runs them. Plain `node --test` fails on an import path in the existing definition store.
How the store meets the issue
- Creating a run: `createAgentRun` ignores a duplicate `(definition_id, idempotency_key)` insert and returns the stored row. A replay with the same key gives `created: false` and the same run. Runs created without a key never count as duplicates. Each run keeps a copy of the definition as it was and its autonomy mode, so later edits don't change it.
- State changes: every change is a single update that only applies if the run is still in one of the allowed `from` states. It returns `null` if another process got there first or the run is missing. A late `cancelled → report_ready` returns `null` and the row is untouched.
- Illegal transitions: `AGENT_RUN_TRANSITIONS` lists the allowed moves exactly as in the issue. Asking for a pair it doesn't allow, or an empty `from` list, throws an error.
- Timestamps and counters: moving to `running` sets `started_at` the first time only, `report_ready` sets `reported_at`, and terminal states set `finished_at`. Moving to `deferred` requires `deferredUntil` and adds one to `deferrals`.
- Reports: a report is cut to `AGENT_REPORT_MAX_CHARS` when written and `report_truncated` is set.
- Reads: `getAgentRun` and `listAgentRuns` (newest first, paged like the definition store) only return the owner's runs; `getAgentRun(id, 'other')` returns `undefined`. `getAgentRunById` is the internal unscoped read. `listDueDeferredRuns` returns deferred runs whose time has passed, oldest due first.
- Previous reports: `listPreviousReports` returns `{ runId, reportedAt, report }` newest first, up to `limit`. It only includes runs in `report_ready`, `awaiting_approval`, `acting`, `completed` or `rejected`, so failed and skipped runs are left out.
Choices the issue didn't settle
- `AGENT_REPORT_MAX_CHARS` didn't exist, so I added it to the shared agent contract at 100,000 characters. Change the number if you want a different limit.
- `listPreviousReports` also takes an optional `excludeRunId`. `beforeCreatedAt` alone could still include the current run if another run was created in the same millisecond.
- A run can be created directly as `queued`, `deferred` (which needs `deferredUntil` and counts as one deferral) or `skipped` (which sets `finished_at`).
- The autonomy notes in the transition table, such as `completed (dry_run)`, are comments only. The store doesn't check the run's autonomy mode, so the callers in later issues have to choose the right next state.
- A stored state the store doesn't recognise is read back as `failed`, so the scheduler never picks that run up again.
Tests (`test/agentRunStore.test.ts`) run the real migrations on an in-memory SQLite database. They cover each acceptance criterion, plus report truncation, deferral, paging and a damaged row.
Nothing here is visible in the UI, so there are no previews.
…, schedule, API/MCP/CLI) will call, along with the agent-run job types and worker dispatch. Typecheck and lint are clean. The new `test/agentRunTrigger.test.ts`, the agent run store tests, `test/worker.test.ts` and `test/taskIntentWithdrawal.test.ts` all pass under `npm run test:server`. Plain `tsx --test` won't run these: the trigger and store tests need `NODE_ENV=test` to get past the GitHub-auth startup check, and the withdrawal test needs node's module-mock flag. The suite runner provides both. What a trigger does (`packages/core/src/services/agents/agentRunTrigger.ts`): 1. Replay: if the idempotency key already has a run, that run comes back unchanged. Nothing is enqueued and the gate isn't asked again. 2. Disabled definition: throws 409 `AGENT_DISABLED`. 3. Runtime check fails: throws 400 `AGENT_INVALID`. Neither error creates a run. 4. Gate: if it says `skip` or `defer`, the run is created as `skipped` or `deferred` and nothing is enqueued. 5. Otherwise: the run is created as `queued` and the report phase is enqueued with `attempts: 1`. 6. Queue failure: the run is marked `failed` with a reason naming the job queue and the underlying error, and the error is rethrown. Jobs use the ID `agent-run-<runId>-<phase>`, so BullMQ drops a second enqueue of the same phase. The queue, database and config loaders are all injectable, so the tests use a fake queue and an in-memory database with no Redis. Choices beyond the issue text: - Replay comes first. A replayed key returns the original run even if the definition has since been disabled or made invalid. - Acting step needs a supported agent. Preview and auto runs always use `propr_mcp` in their acting step, so they need a supported agent type even if the capability isn't ticked. - Synthetic agents with `propr_mcp`. They pass only if every enabled member of the chosen model routes to a supported type, because the router can pick any of them. - No agent set. This passes, and the worker will use the default agent. A model with no agent is rejected. - Defer reasons are only logged. The store has no column for them; skip reasons are saved in `skipReason`. - New store helper. I added `getAgentRunByIdempotencyKey` to `agentRunStore.ts`, which stays the only module that writes `agent_runs`. Worker: `processAgentRun` and `processAgentAction` are wired into `src/workerFactory.ts` and `src/worker.ts`. Until issues 7 and 10 land, their stand-in processors in `src/jobs/processAgentRunJob.ts` mark the run `failed` with "Not implemented" and then throw, so runs don't sit in `queued` or `acting`. I updated the worker dispatch test and the withdrawal test's processor map to include the two new names. The job types and `agentRunTrigger.ts` are exported from `packages/core/src/index.ts`. Nothing visible changed, so there are no previews.
…15) under `node scripts/run-test-suite.mjs`, and typecheck and eslint are clean. I didn't boot the real server, so `assertNoDuplicateRoutes` hasn't actually run. A scan of the route tables in `server.ts` and `packages/api/routes/` found no duplicate method+path pairs.
What was added
- Routes: `packages/api/routes/agentDefinitionRoutes.ts` has all 12 routes from the issue, registered in `packages/api/server.ts` under `/api/agent-definitions` and `/api/agent-runs`.
- Delete guard: a small read helper, `hasAgentRunInStates`, in `agentRunStore.ts`. Delete uses it to refuse with 409 `AGENT_RUN_ACTIVE` while a run is `running` or `acting`.
- Tests: `packages/api/test/agentDefinitionRoutes.test.ts`.
How the rules are met
- Owner scoping: every route returns 401 without a user. Another user gets 404 on every route, never 403.
- Demo mode: confirmed that the existing global middleware already blocks every non-GET request under `/api`.
- Repository grant: checked on create, on update only when the repository set actually changes (ignoring case), and on every trigger. A repository the user can't read returns 404 `REPOSITORY_NOT_ACCESSIBLE`.
- Validation: `validateAgentDefinitionInput` runs first, then `validateAgentDefinitionRuntime`. On create the runtime check uses the would-be definition before it is saved. A failure returns 400 `AGENT_INVALID`.
- Trigger:
- Returns 202 `{ run, created }`. A repeated `Idempotency-Key` returns 200 with the same run and nothing is enqueued again.
- The trigger kind defaults to `manual` for a browser session and `api` otherwise. `cli` is accepted; `schedule` and `mcp` get 400.
- A `gate` service hook is in place and defaults to undefined.
- Cancel: the run is marked `cancelled` first, so a late worker write can't bring it back. For a `running` run it then calls `stopTaskExecution(reportTaskId)`. If stopping the task fails, that is logged and the cancel still succeeds.
- Input files:
- Uploads use the goal attachment multer, wrapped so a rejected file gets a JSON 400 instead of an HTML error.
- Files are stored under `storage/agent-definitions/<definitionId>/`, with a limit of 10 files per agent.
- Responses never include stored file paths.
- Deleting an agent also removes its folder.
- Errors: core errors come back as `{ error, code }` with their own status.
Decisions you may want to review
- Field names don't match between request and response. Requests use the shared input names (`autonomy`, `schedule`, `agentId`, `model`, `previousReportCount`), but responses return the store's field names (`autonomyMode`, `scheduleCron`, `agentAlias`, …). I did this because the responses need `revision` and `attachments`, which the shared `AgentDefinition` type lacks. The UI work in #2814 will have to handle the mismatch, or we add a mapping to the shared shape.
- The default for previous reports follows the shared contract (0), not the store's default (1). On create, if `previousReportCount` is omitted, previous reports are off.
- Default trigger source: when the caller doesn't pass `source`, it is recorded as `user:<ownerId>`.
- Cancelling an `acting` run also stops its acting task, which goes slightly beyond the issue.
- Attachment uploads can race. Adding files reads the list and then writes it back, so two uploads at the same moment could lose one of them.
There are no visual previews because nothing in the UI changed.
The Gmail, Google Calendar and Google Drive connectors need authorizing in your claude.ai connector settings before they can be used. This task didn't need them.
…/agentRuns/reportPrompt.ts`. The new tests pass (13 of 13) under `node scripts/run-test-suite.mjs`, `npm run typecheck` is clean, and eslint reports no errors on the new module. The existing agent contract tests still pass. `buildAgentReportPrompt(input)` - Sections: it builds the six sections in the order the issue lists. - Role and boundaries: produce a report; don't modify files, commit or open pull requests. When `propr_mcp` is enabled, it adds that MCP tools are for reading context only and acting happens in a later step. - Capabilities: each of repository code, web and ProPR MCP is stated as available or not, with a line telling the model not to claim it used anything it doesn't have. Repository code counts as available only when the definition has `repository_read` *and* `workspace.repositoriesReadable` is true. When it is, the checkout paths are listed. - Task: the user's prompt inside `<agent-task>`, with the agent name and run info. - Input files: inside `<input-files>`, labelled as data, not instructions. - Previous reports: only when `includePreviousReports` is set. They are listed newest first, each inside `<previous-report run="…" reported-at="…">` and labelled as data. Long reports are cut with a `[truncated]` marker, and the "Compare with the previous report(s)…" instruction follows. If there are no previous reports yet, it says this is the first run. - Output: the Markdown report instructions. It asks for no JSON. - Fence escaping: a closing tag such as `</previous-report>` inside user content becomes `<\/previous-report>`, including case and spacing variants, so it can't close its own fence. Run IDs and file names are cleaned so they can't break the tag attributes. - Size limit: if the prompt would exceed 200,000 characters, the oldest previous reports are dropped first, then files are cut from the end of the list. Each cut is noted in the prompt. `extractAgentReport(result)` uses `summary`, then the last assistant text in `conversationLog`, then `rawOutput`. It then runs the text through `sanitizeAgentReport` and `redactSecrets`. Things to review: - New constants. `AGENT_PREVIOUS_REPORT_MAX_CHARS` didn't exist, so I added it to `packages/shared/src/agentDefinitions.ts`. I set it to 10,000 per report: the existing 50,000 combined limit divided by the 5-report maximum. I also added `AGENT_REPORT_PROMPT_MAX_CHARS` (200,000) there. - Import from `@propr/core`. The spec says the module should import nothing from `@propr/core`, but it also wants `extractAgentReport` in this file using core's sanitizer and redactor. So that one function imports from core, and the prompt builder itself uses nothing from core. - Workspace fields are paths. I treated `primaryRepository` and `contextRepositories` as checkout paths inside the container, since the prompt has to say "available at `<path>`". The repository names from the definition are listed separately. - Test cleanup. Importing `@propr/core` opens the shared database connection, which kept the test process from exiting. The test file closes it in an `after()` hook, as other tests here do. There are no previews because nothing in the UI changed. The Gmail, Google Calendar and Google Drive connectors need authorizing in your claude.ai connector settings before they can be used. This task didn't need them.
* The run is still going; I'll pick it up when it reports back.
* feat(ai): I fixed the two lint warnings that failed the Core Lint step of CI. `npx eslint src/ --max-warnings 0` now passes with no warnings, `npm run typecheck` is clean, and `test/processAgentRunJob.test.ts` passes. I didn't run the rest of the test suite. No previews, since nothing visible changed.
I fixed the two lint warnings that failed the Core Lint step of CI. `npx eslint src/ --max-warnings 0` now passes with no warnings, `npm run typecheck` is clean, and `test/processAgentRunJob.test.ts` passes. I didn't run the rest of the test suite. No previews, since nothing visible changed.
- **Too many parameters in `copyAgentInputFiles`** (`src/jobs/agentRuns/workspace.ts`): the optional `log` and `inputRoot` arguments are now one options object, `{ log?, inputRoot? }`. I updated the two calls in the same file and the two in `test/processAgentRunJob.test.ts` to match.
- **Complexity too high in `processAgentRun`** (`src/jobs/processAgentRunJob.ts`): I moved three pieces out into small helpers without changing how a run behaves:
- `reportFromResult` throws if the agent failed or gave an empty report, otherwise returns the report.
- `previousReportsFor` fetches earlier reports only when the definition asks for them.
- `failRunningRun` holds what used to be the `catch` block: it works out the failure reason (including the usage-limit case), marks the run failed, and marks the task failed.
PR: #2839
Comment by: @propr-dev[bot] (ID: 6020576741)
Comment by: @github-actions[bot] (ID: 6020577591)
Model: Claude Opus 5.5
* feat(ai): I fixed both findings in `src/jobs/processAgentRunJob.ts`. The processor tests pass (20 of 20), and `npm run typecheck` and `npx eslint src/ --max-warnings 0` are clean. Against the previous processor code, 4 of the 5 new tests fail. The fifth, for a duplicate delivery, passes either way because the old code skipped every non-queued run. I didn't run the rest of the test suite. No previews, since nothing visible changed.
I fixed both findings in `src/jobs/processAgentRunJob.ts`. The processor tests pass (20 of 20), and `npm run typecheck` and `npx eslint src/ --max-warnings 0` are clean. Against the previous processor code, 4 of the 5 new tests fail. The fifth, for a duplicate delivery, passes either way because the old code skipped every non-queued run. I didn't run the rest of the test suite. No previews, since nothing visible changed.
**F1 – interrupted runs.** When a job is delivered again and its run is still `running`, the processor no longer ignores it:
- **Abandoned attempt:** the queue only delivers an active job again after its lock has lapsed, so the earlier attempt is treated as dead. The run is moved from `running` to `failed`, with the reason "The worker running this report stopped before it finished; trigger the agent again", and the task is marked failed. I chose not to re-execute, because if the old attempt were in fact still running, the agent would run twice.
- **Attempt still running in this worker:** the processor now tracks the runs it is executing. A delivery for one of those is skipped and leaves the run alone.
- **Run cancelled in the meantime:** if the move to `failed` loses to a cancel, the task follows the run's actual state instead.
**F2 – late cancellation.** When storing the report is rejected because the run is no longer `running`, the processor now reads the run's current state. It marks the task cancelled (or failed, if the run was failed as abandoned) instead of leaving it in post-processing. The task store never overwrites a task that has already finished, so a task the cancel endpoint did stop keeps the state it was given.
The same mistake existed on the error path. If the run was cancelled and the agent then failed (for example, its container was killed), the task was marked failed while the run said cancelled. That path now checks the run's state the same way.
New tests cover:
- a late report after a cancel the endpoint couldn't stop.
- a cancel followed by an agent failure.
- a delivery after an interrupted worker.
- an abandoned run that is cancelled while being recovered.
- a duplicate delivery while the run is still executing.
**What this can't prevent:**
- A worker on another machine that froze long enough to lose its lock may still be running the agent when its run is failed. Its later result is then discarded and its task ends as failed, but its container isn't stopped from here.
- The workspace of a worker that died isn't cleaned up. That was already the case and is outside these two findings.
The Gmail, Google Calendar and Google Drive connectors need to be authorized in claude.ai's connector settings before they can be used. I didn't need them for this.
PR: #2839
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
* feat(ai): I fixed F3, F4 and F5. `test/processAgentRunJob.test.ts` and `test/agentRunTrigger.test.ts` pass (30 of 30). Root and `packages/core` typecheck are clean, and eslint reports no warnings on `src/` or the changed core file. I added 10 regression tests, and all 10 fail when run against the previous source. I didn't run the rest of the test suite. No previews, since nothing visible changed.
I fixed F3, F4 and F5. `test/processAgentRunJob.test.ts` and `test/agentRunTrigger.test.ts` pass (30 of 30). Root and `packages/core` typecheck are clean, and eslint reports no warnings on `src/` or the changed core file. I added 10 regression tests, and all 10 fail when run against the previous source. I didn't run the rest of the test suite. No previews, since nothing visible changed.
**F3 – a redelivery now finishes a run whose report is already stored** (`src/jobs/processAgentRunJob.ts`)
- When a delivery arrives for a `report_ready` or `completed` run that already has a report, the processor finishes the remaining steps without running the agent again. A dry run is moved to `completed`. Preview and auto runs stay in `report_ready`. In both cases the report task is marked completed.
- These steps are safe to repeat. A run that was already advanced isn't advanced again, and a task that already ended is left alone, so a duplicate delivery doesn't re-complete the task or send a second Inbox notification.
- The normal path and redeliveries share this code. If finishing fails after the report is stored, the error is now thrown so the next delivery can finish the run. Before, that failure marked a run with a stored report as `failed`.
- A delivery that overlaps a run still executing in the same process is skipped, as it already was for `running`.
**F4 – a failure that can't be saved now fails the delivery**
- When saving the `failed` state to the database throws, the processor now raises a new `AgentRunPersistenceError` instead of treating the run as settled. This covers the validation-failure, execution-failure and abandoned-run paths. A run that another writer had already moved on still returns `false` as before, so the two cases stay separate.
- That error is raised from inside the outer `catch`, so it is no longer turned into a normal `{ status: 'failed' }` result. Workspace cleanup still runs.
- **One change outside the processor:** `AGENT_RUN_JOB_OPTIONS` was `attempts: 1`, so a failed delivery would never be retried and these fixes would have nothing to act on. I changed it to `attempts: 3` with exponential backoff (5 s) in `packages/core/src/services/agents/agentRunTrigger.ts` and updated its test. A retry doesn't spend tokens twice: after the run has started, a retry either fails it as abandoned or finishes it from the stored report. Please check you're happy with that change.
**F5 – attachment and context-repo writes can't leave the workspace** (`src/jobs/agentRuns/workspace.ts`)
- A new `prepareReservedDirectory` checks the path from the workspace root down. Any symlink or file in the way, such as `.propr` itself, is unlinked; the place it points to is never touched. The final directory is always recreated empty, which also removes symlinks to individual files inside it. The function then confirms the directory really resolves inside the workspace.
- `copyAgentInputFiles` uses it for `.propr/agent-inputs`. `prepareRepositoryWorkspace` uses it for `.propr/context` before cloning the additional repositories into it.
**Other problems I found and left alone** (outside the selected findings):
- If marking the task failed or cancelled throws, the error is still swallowed. This happens in `failRunningRun`, `recoverAbandonedRun` and `settleTaskWithRun`. Once the run is `failed` or `cancelled`, a redelivery skips it, so the task can stay stuck in a processing state.
- If an interrupted run is retried after all 3 attempts are used up and saving still fails, the run stays `running`. Retries can't fix that; it would need a separate background sweep.
PR: #2839
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
* feat(ai): I fixed F6, F7 and F8. The agent-run tests and the agent git-access tests pass (6 files). Root and `packages/core` typecheck are clean, and eslint reports no warnings on `src/` or the two changed core files. I added 14 regression tests; 12 of them fail when run against the previous source. The other 2 are guards that pass either way: one checks that a `repository_read` run still gets its credential, the other that an already-ended task is left alone. I didn't run the rest of the test suite. No previews, since nothing visible changed.
I fixed F6, F7 and F8. The agent-run tests and the agent git-access tests pass (6 files). Root and `packages/core` typecheck are clean, and eslint reports no warnings on `src/` or the two changed core files. I added 14 regression tests; 12 of them fail when run against the previous source. The other 2 are guards that pass either way: one checks that a `repository_read` run still gets its credential, the other that an already-ended task is left alone. I didn't run the rest of the test suite. No previews, since nothing visible changed.
**F6: repository access is now enforced when the container launches.**
- I added a `repositoryAccess: 'none'` option to `AgentTaskOptions`. When it's set, `prepareAgentGitAccess` returns an empty token and no mounts. It does this before it reads repository settings, mints a token or lists clones.
- Every adapter (Claude, Codex, the Codex app server, OpenCode, Vibe, Antigravity) prepares its launch through that function. Their Docker argument builders keep an empty mount list as it is, so no adapter falls back to the default clone mounts.
- The processor sets the option, and passes an empty token, unless the run has `repository_read` *and* the workspace actually checked out a repository. That also covers a run with `repository_read` but no repositories, which gets an empty scratch directory.
- The new core test sets up existing clones with no context restriction and checks that no token is minted and nothing is mounted.
**F7: a run cancelled during preparation no longer starts the agent.**
- Right before `executeTask`, after the task is moved to execution, the processor re-reads the run.
- If the run is no longer `running`, it settles the task to match and returns without launching.
- If the task was stopped directly while the run is still `running`, it cancels the run and returns.
- A cancel that lands during the launch itself is still left to the execution layer's existing handling.
- The two existing "cancel during execution" tests used to cancel at claim time, so with this check they would never have reached the agent. They now cancel from inside the agent call, so they still test cancellation during execution.
**F8: failed and cancelled runs no longer leave their task active.**
- If the task can't be updated to match the run, the delivery now fails with a new `AgentRunSettlementError` instead of logging and returning. This applies to ordinary failure, abandoned-run recovery and cancellation settlement, and BullMQ retries the delivery.
- When a job is redelivered for a `failed` or `cancelled` run, the processor now ends a task that still exists and is not finished yet. If the task doesn't exist or has already ended, it skips as before.
`toolPolicy` is still passed through unchanged; the repository restriction comes from the new launch option, not from `toolPolicy`.
Separately, the Gmail, Google Calendar and Google Drive connectors in this session need authorization in your claude.ai connector settings; they weren't needed for this work.
PR: #2839
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
* feat(ai): I fixed F9 and F10 in `src/jobs/processAgentRunJob.ts`. The processor and trigger tests pass (65 of 65), root and `packages/core` typecheck are clean, and `npx eslint src/ --max-warnings 0` reports nothing. I added 7 regression tests; 6 of them fail against the previous processor code. I didn't run the rest of the test suite. No previews, since nothing visible changed.
I fixed F9 and F10 in `src/jobs/processAgentRunJob.ts`. The processor and trigger tests pass (65 of 65), root and `packages/core` typecheck are clean, and `npx eslint src/ --max-warnings 0` reports nothing. I added 7 regression tests; 6 of them fail against the previous processor code. I didn't run the rest of the test suite. No previews, since nothing visible changed.
**F9: stopping a task during execution.** After `executeTask` returns, the processor now checks whether the task was stopped directly. If it was, the run moves from `running` to `cancelled`, and the result is thrown away whether it succeeded or failed. The failure path makes the same check before marking the run failed. If that check itself errors (say, Redis is down), it logs and still records the failure, so the run doesn't stay `running`. All of these moves are guarded: if another writer already changed the run, the task follows whatever that writer stored.
- **Same defect in recovery:** a run whose worker died after its task was stopped used to be failed as abandoned. It is now cancelled.
- **Remaining gap:** a stop that lands between this check and storing the report is not caught. Tasks and runs live in different stores, so the check can't be atomic, and a run that already has its report can't be moved to `cancelled`.
**F10: losing the claim.** When the `queued → running` claim fails, the processor now rereads the run.
- If the run was cancelled or failed, the task is ended to match.
- In any other state, another delivery has claimed the run, so this delivery returns `skipped` and leaves the run and its task alone. It no longer goes through abandoned-run recovery.
**Tests:**
- One test for each F10 case: the stale delivery that loses the claim to a stalled-job redelivery (the claimant's task still completes), and a run failed before the claim.
- For F9, a task stopped during execution followed by a successful result, a failed result, and a thrown error. Plus the abandoned-run case.
- The guard that passes either way: when the task can't be read, the failure is still recorded.
- I rewrote the existing "cancelled between pickup and start" test so the run is actually cancelled. It used to fake a claim that returned null while the run stayed `queued`, which now correctly counts as someone else's claim.
To keep the file within its lint limits (400 lines, complexity 20), I moved the run error classes and `reportFromResult` into a new `src/jobs/agentRuns/runErrors.ts`. The error classes are still exported from the processor. I also added a few small helpers in the processor.
Separately, the Gmail, Google Calendar and Google Drive connectors need to be authorized in your claude.ai connector settings before they can be used.
PR: #2839
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
* feat(ai): I fixed the shard 1 timeout in `test/processAgentRunJob.test.ts`. The test file passes (48 of 48 in 2.4s) both normally and with a simulated CI `sudo`; I haven't confirmed it on a real CI runner yet.
I fixed the shard 1 timeout in `test/processAgentRunJob.test.ts`. The test file passes (48 of 48 in 2.4s) both normally and with a simulated CI `sudo`; I haven't confirmed it on a real CI runner yet.
**Cause:** the workspace test calls the real setup code, which runs `sudo chown -R 1000:1000` on the scratch workspace. My local container has no `sudo`, so the call fails, the code logs a warning and the test finishes. GitHub runners have passwordless `sudo`, so there the chown succeeds. The test process then has to clean up a directory owned by another user, and the file hung until the 180s limit killed it. To reproduce this, I used a fake `sudo` that makes the workspace read-only, and the file hung the same way.
**Fix (test-only):**
- At the top of the test file, I put a stub `sudo` that does nothing first on `PATH`. `test/worktreeStartRevision.test.ts` already handles the same problem this way.
- The `after` hook now closes the database connection in a `finally`, so a failed cleanup can't keep the process alive.
With the fix, the file passes against both the fake read-only `sudo` and the normal environment. No other test calls this workspace setup. ESLint ignores files under `test/`, so lint doesn't cover this change. I didn't run the rest of the suite. Nothing visible changed, so there are no previews.
PR: #2839
Comment by: @github-actions[bot] (ID: 6021809239)
Model: Claude Opus 5.5
* feat(ai): I fixed F11 and F12. The processor and trigger tests pass (68 of 68), the root and `packages/core` typechecks are clean, and `npx eslint src/ --max-warnings 0` reports nothing. I added 3 regression tests; the 2 that cover these bugs fail when run against the previous source. I didn't run the rest of the test suite. No previews, since nothing visible changed.
I fixed F11 and F12. The processor and trigger tests pass (68 of 68), the root and `packages/core` typechecks are clean, and `npx eslint src/ --max-warnings 0` reports nothing. I added 3 regression tests; the 2 that cover these bugs fail when run against the previous source. I didn't run the rest of the test suite. No previews, since nothing visible changed.
**F11 – a cancel during the "storing report" update no longer ends as a completed run**
- In `src/jobs/processAgentRunJob.ts`, after the `POST_PROCESSING` task update, the processor now reads the task again through `followCancelledTask` before storing the report. If the task was cancelled, the run is cancelled too and the report is dropped.
- The check has to come before the report is stored: once a run has a stored report (`report_ready`), the run store won't let it become cancelled.
- I looked for the same defect elsewhere. Every other point where the processor waits on something and then changes the run already re-checks for a cancelled task first. The recovery paths for runs with a stored report only pick up runs that already have one, so this check covers them as well.
- A small gap remains between that read and storing the report. The tasks and the runs live in two separate stores, so a cancel landing in that moment can't be fully excluded. The unchecked wait on the update itself is gone.
- **Regression test:** the task is cancelled during the `POST_PROCESSING` update. The test checks that the run ends `cancelled` with no report, is never marked `report_ready` or `completed`, the task stays `cancelled`, and the workspace is cleaned up.
**F12 – runs that don't read repositories no longer need GitHub sign-in**
- I added `definitionReadsRepositories()` to `src/jobs/agentRuns/workspace.ts`: true only when the definition has `repository_read` and at least one repository.
- The workspace setup, the GitHub sign-in and the agent's repository access now all use that same check. GitHub credentials are fetched only when it's true; otherwise the workspace gets an empty token and no GitHub client, and the agent launches without repository access.
- **Regression tests:**
- The GitHub-access step throws for three kinds of definition: no capability and no repositories, repositories but no `repository_read`, and `repository_read` with no repositories. In all three the run completes, GitHub access is never requested, and the agent gets no repository access.
- A guard test checks that a run which does read repositories still fails cleanly when GitHub access fails.
**Unrelated change:** moving the GitHub-access decision into the processor took it over two eslint limits (function complexity and file length). To stay under them, I moved the agent launch options into a new `src/jobs/agentRuns/agentTaskOptions.ts`, along with the `AgentRunToolPolicy` type. `processAgentRunJob.ts` still exports that type, so existing imports keep working.
The Gmail, Google Calendar and Google Drive connectors need authorizing in your claude.ai connector settings before they can be used. I didn't need them for this.
PR: #2839
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
* feat(ai): I fixed F13: before a report run clones any additional repository, it now checks the primary repository's `contextRepositories` setting and rejects any repository the setting doesn't allow. In the reported case (`acme/web` set to `'none'`, run selecting `['acme/web', 'acme/api']`), the run fails before anything is cloned, with a message naming `acme/api` and how to fix the setting. The processor, trigger and git-access tests pass (92 of 92), both typechecks are clean, and eslint reports no warnings on `src/` or the two changed core files. I didn't run the rest of the test suite. No previews, since nothing visible changed.
I fixed F13: before a report run clones any additional repository, it now checks the primary repository's `contextRepositories` setting and rejects any repository the setting doesn't allow. In the reported case (`acme/web` set to `'none'`, run selecting `['acme/web', 'acme/api']`), the run fails before anything is cloned, with a message naming `acme/api` and how to fix the setting. The processor, trigger and git-access tests pass (92 of 92), both typechecks are clean, and eslint reports no warnings on `src/` or the two changed core files. I didn't run the rest of the test suite. No previews, since nothing visible changed.
**What changed**
- **One shared policy rule** (`packages/core/src/agents/agentGitAccess.ts`): I moved the policy calculation out of `prepareAgentGitAccess` into a new exported function, `resolveEffectiveContextRepositories`. It reads every monitored entry for the repository and keeps only repositories that all of them allow, so conflicting entries never widen access. `prepareAgentGitAccess` now calls it, so the agent's token scope and the workspace checkout can't disagree. It is exported from `@propr/core`.
- **Check before cloning** (`src/jobs/agentRuns/workspace.ts`): the new `assertContextRepositoriesAllowed` runs in `prepareRepositoryWorkspace` before the primary checkout and any extra clone. Names are compared ignoring case, and a setting of `'all'` (or none at all) allows everything, as the adapter does. The workspace input takes an optional `resolveContextPolicy` so tests can supply a policy; by default it uses the repository settings.
I checked for other code that copies repositories into the workspace: `cloneContextRepository` is the only one, so this was the only occurrence of the defect.
**Regression tests (3)**
- In `test/processAgentRunJob.test.ts`, a restrictive policy with two repositories is rejected before any clone. This test fails when the check is removed.
- Also in that file, the check itself: `'all'` and no setting allow everything, names match regardless of case, `'none'` leaves only the primary repository, and every excluded repository is named.
- In `test/agentGitAccess.test.ts`, conflicting entries narrow the policy, `'none'` gives just the primary repository, and `'all'` gives no restriction.
One thing to watch: the settings are read when the workspace is prepared and read again at agent launch. If someone tightens them in between, the checkout reflects the older setting while the token follows the newer one. Settings can't be read atomically across both steps, so I left that window as it is.
PR: #2839
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
* feat(ai): I fixed F14 and F15. The tests for the processor, trigger and worker credentials pass (74 of 74). The root and `packages/core` typechecks are clean, and `npx eslint src/ --max-warnings 0` reports nothing. I added 3 regression tests, and all 3 fail when run against the previous source. I didn't run the rest of the test suite. There are no previews, since nothing visible changed.
I fixed F14 and F15. The tests for the processor, trigger and worker credentials pass (74 of 74). The root and `packages/core` typechecks are clean, and `npx eslint src/ --max-warnings 0` reports nothing. I added 3 regression tests, and all 3 fail when run against the previous source. I didn't run the rest of the test suite. There are no previews, since nothing visible changed.
**F14: context clones exposed the worker token.** `cloneContextRepository` in `src/jobs/agentRuns/workspace.ts` now clones from the plain `https://github.com/<owner>/<repo>.git` URL. The token is passed only in the git command's own environment, as an auth header. This is the same helper (`configureGitAuthentication`) that the shared repository clones already use. So the token never appears in the clone URL or in `.git/config`, not even while the clone is running, and the follow-up `remote set-url` step is gone. I exported that helper from `@propr/core` (`packages/core/src/index.ts`).
- **Regression test:** it puts a fake `git` on the path that records each command and writes the clone URL into `.git/config` the way real git does. The test checks that the token is never passed on the command line or written to the config, and that it reaches git only through the header.
- **Same pattern elsewhere:** the only other repository fetch in the report-run path is the primary checkout through `ensureRepoCloned`, and it already authenticates this way.
**F15: validation retries could leave a task stuck.** When a definition fails validation, the run is still marked failed first. After that, a new helper `settleExistingTask` in `src/jobs/processAgentRunJob.ts` ends any report task an earlier attempt already created, using the existing ended-run handling. If there is no task, none is created. If the task can't be read or updated, the error is passed up so the job is retried, and the retry finishes ending it. `reconcileEndedRun` now uses the same helper.
- **Regression tests:**
- The exact reported sequence: the claim fails during a database outage, the definition becomes invalid, and the retry fails both the run and its existing task without executing anything.
- Ending the task fails once: the delivery is rejected, and the retry finishes the job.
- **Unchanged:** the existing test where an invalid definition has no task still passes with no task calls.
I found no other problems while checking these paths.
The Gmail, Google Calendar and Google Drive connectors need authorizing in your claude.ai connector settings before they can be used. They weren't needed for this fix.
PR: #2839
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
* feat(ai): I fixed F16. A report run whose result says the provider stopped it early (for example on the turn limit or a timeout) now fails, even if it reported success and returned text. Before, that text was stored as a finished report.
I fixed F16. A report run whose result says the provider stopped it early (for example on the turn limit or a timeout) now fails, even if it reported success and returned text. Before, that text was stored as a finished report.
**Fix:** `reportFromResult` in `src/jobs/agentRuns/runErrors.ts` now checks why the run stopped before it accepts the report. It does this with the existing `resolveAgentTerminationReason`, so it covers both a `terminationReason` set on the result and termination signs in the result's other fields. If a reason is found, it throws an `AgentRunReportError` with the message `Agent execution stopped before completion: <description>`. That error goes through the processor's existing failure handling: the run and its task are marked failed, the reason is saved, and the workspace is cleaned up. Because no report is saved, a later run can't pick up the partial text as a previous report.
I didn't use the existing `isIncompleteAgentExecution` helper because it only applies when `success === false`, which is exactly the case this bug slipped through. `reportFromResult` is called in only one place (the report step in `processAgentRunJob.ts`), so there were no other copies of the same mistake in this PR's changes.
**Tests:** I added 2 regression tests to `test/processAgentRunJob.test.ts`. Each returns a successful, non-empty result with `terminationReason` set to `max_turns` or `timeout`, then checks that:
- the run ends as `failed`.
- no report is saved.
- the failure reason explains why.
- the task is failed and the workspace is cleaned up.
**Verification:**
- The processor and trigger tests pass (75 of 75).
- Both new tests fail when run against the previous `runErrors.ts`.
- `tsc --noEmit` is clean and `npx eslint src/ --max-warnings 0` reports nothing.
- I didn't run the rest of the test suite.
- The test files only run with `PROPR_DEMO_MODE=true` and `--experimental-test-module-mocks`. Without the first, startup exits because GitHub auth isn't configured. I also rebuilt `packages/shared` and `packages/core` before running them.
No previews, since nothing visible changed.
The Gmail, Google Calendar and Google Drive connectors need authorizing in your claude.ai connector settings before they can be used. They weren't needed for this fix.
PR: #2839
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
---------
Co-authored-by: propr-dev[bot] <1316198+propr-dev[bot]@users.noreply.github.com>
… and Codex now block web access and attach the `propr` MCP server using their own CLI switches, and the token is never placed in the command line.
Testing:
- The new `test/agentToolPolicy.test.ts` passes (18 of 18).
- These existing agent and agent-run test files still pass unchanged: antigravity, opencode, vibe, goal execution, goal launch git access, native goal, scout runtime, context analysis, reasoning level and `processAgentRunJob`.
- `npm run typecheck` is clean.
- Eslint didn't check most of the changed files. It reported them as ignored by its config, so they have not been linted.
- `test/redactSecrets.test.ts` has 3 failures, and they are the same with my change reverted. Two can't write to `/tmp/claude-logs` because that directory is owned by root in this sandbox, and the third fails on a missing bearer-redaction placeholder in a completion-comment test.
- Nothing ran against a real Claude or Codex CLI. In particular, I haven't confirmed that Claude expands `${PROPR_MCP_BEARER_TOKEN}` inside an inline `--mcp-config`, or that this Codex version honours `tools.web_search=false`. The tests only check the arguments we build.
What changed:
- Option and builders: `AgentTaskOptions` has an optional `toolPolicy`. When it's absent the arguments are the same as before. The builders in `packages/core/src/agents/agentToolPolicy.ts` produce these switches:
- Claude, web off: `--disallowedTools WebFetch WebSearch`.
- Claude, MCP: an inline `--mcp-config` whose `Authorization` header is `Bearer ${PROPR_MCP_BEARER_TOKEN}`.
- Codex: `-c tools.web_search=false`, plus `-c mcp_servers.propr.url=…` and `-c mcp_servers.propr.bearer_token_env_var=…`.
The token is only ever in the returned env map. Invalid server or env-var names are rejected.
- Passing the token: the containers get `-e PROPR_MCP_BEARER_TOKEN` with no value, and Docker copies the value from its own environment. `executeDockerCommand` already declared an `extraEnvVars` option but never used it. I wired it into the spawn environment, so the token stays out of the argument list and nothing is written to the worktree.
- Other runtimes: Antigravity, OpenCode and Vibe get a "web access is not allowed" notice added to the prompt. This is best effort only, as the issue intends.
- Mapping for agent runs: the stub from issue 7 was never added as `src/jobs/agentRuns/toolPolicy.ts`; it was the `{ capabilities, readOnly }` placeholder in `agentTaskOptions.ts`. I created the real file:
- Report phase: web is allowed only if the definition has the `web` capability. The MCP is attached only when `propr_mcp` is enabled and a grant was issued.
- Action phase: the MCP is always attached once a grant exists, and web follows the definition.
`agentTaskOptions` now accepts an optional `mcpGrant` for issue 9 to fill in. I updated the one assertion in `test/processAgentRunJob.test.ts` that expected the old placeholder shape.
- Redaction: `redactSecrets` already stripped bearer tokens, but only those of 20 characters or more, so `Authorization: Bearer abc.def` got through. It now strips any token after an `Authorization: Bearer` header, including in JSON, and any value assigned to `PROPR_MCP_BEARER_TOKEN=`.
The `codex app-server` builder, which is only used for goal mode, doesn't pass these switches through. That doesn't affect agent runs, which use task mode.
There's no visual change, so I didn't create a preview.
…oPR MCP grant for their own run, and the worker revokes it in `finally` when the run ends. All the tests I ran pass: the new ones, the processor tests, and the existing MCP OAuth, delegation and Connected-apps tests, plus the CORS, route-authorization, desktop-boundary and status-route tests (which cover the auth boundary). Typecheck and `eslint --max-warnings 0` are clean for `src/` and the new API files.
Not verified: I didn't boot the real server or run a real agent container. So nothing has confirmed that a container can actually reach `http://api:4000/api/mcp`, or that a call shows up in the live MCP access log. Grants are ordinary MCP grants with the label "ProPR Agent: <name>", so they go through the same logging path as other clients. The tests check the label and the Connected-apps listing, not the log itself.
What was added
- `packages/api/mcp/agentRunGrants.ts`
- `issueAgentRunGrant` returns `{ grantId, accessToken, expiresAt }` and `revokeAgentRunGrant(grantId)` uses the same revocation as the Connected apps "Revoke" button.
- Report grants get `read`; action grants get `read`, `plan` and `execute`. Grants last 2 hours and are tagged `membershipSource: 'agent_run'`.
- It fails with `MCP_DISABLED` or `GITHUB_AUTHORIZATION_REQUIRED` as specified.
- The grant id is stored in `mcp_records` as `agent_run_grant` / `<runId>:<phase>` so the issue-12 sweep can find it.
- The `propr-agent-runs` client has no redirect URIs, so it can't be used for browser OAuth.
- `McpOAuthProvider.issueDelegatedGrant` (in `oauth.ts`) saves the grant and access token the same way browser consent does. There's no refresh token, and the access token lives exactly as long as the grant.
- Internal routes (`routes/agentRunInternalRoutes.ts`), registered in `server.ts` before the session guard with the discovery rate limiter:
- `POST /api/internal/agent-runs/:runId/mcp-grants` and `.../revoke`.
- Requests are checked with an HMAC over `runId:phase:ts`, and the timestamp must be within 5 minutes.
- Owner and repositories always come from the run snapshot, never the request body.
- Bad or expired signature returns 401, a run in the wrong state returns 409, a missing run returns 404. Revoke works in any state, so crash recovery can use it.
- Shared signer: `signAgentRunGrantRequest` lives in `@propr/core`, so the API and the worker can't disagree on the format.
- Worker client (`src/jobs/agentRuns/mcpGrantClient.ts`) calls `PROPR_INTERNAL_API_URL` (default `http://api:4000`). Containers get `PROPR_AGENT_MCP_URL` (default `<internal API>/api/mcp`).
- Executor: when the definition has `propr_mcp`, the report phase requests a grant and passes it into the tool policy. A failed revoke is only logged; expiry and the sweep are the backstop.
Behaviour you might not expect
- Admin scope ceiling: grants are narrowed to the instance's MCP scope ceiling. On the default ceiling (`read`, `plan`, `review`), action-phase grants lose `execute` unless an admin raises it. That would block `create_task` in issue 10.
- Grant failure stops the run: if a `propr_mcp` report can't get a grant, the run fails before the agent starts. It does not run without MCP.
- Retried phase: a retry revokes the previous grant for that phase. A revoke that names an old grant id leaves the newer grant alone.
- Revoke signature signature: `revokeAgentRunMcpGrant` takes `(runId, { grantId, phase })` rather than `(runId, grantId)`, because the signed revoke request needs the phase.
- Action phase not wired yet: that phase is still the issue-10 placeholder, so only the report phase uses grants for now.
Tests added: `packages/api/test/agentRunGrants.test.ts` (7 tests), `test/agentRunMcpGrantClient.test.ts` (3), and 4 new cases in `test/processAgentRunJob.test.ts`. They cover:
- forged, expired and phase-swapped signatures, plus a 409 for a `completed` run.
- the token authenticating through `McpPolicy.authenticate` with only the run's repositories.
- an instance repo outside the definition being denied, even with GitHub write access.
- a report token failing with "requires execute".
- the token being rejected after revoke.
- the "ProPR Agent: Nightly triage" entry on `/mcp/apps`.
There's no visual change, so I didn't create a preview.
* The broader regression run is still going. I'll report once it finishes. * feat(ai): I fixed F1. An approval that gets interrupted can now be recovered by approving again, and the approver's note is saved with the approval so the retry still uses it. I fixed F1. An approval that gets interrupted can now be recovered by approving again, and the approver's note is saved with the approval so the retry still uses it. **What changed** - **The note is saved on the run.** There is a new `operator_note` column, added to this PR's own `agent_runs` migration since that migration isn't on main yet. The approval step writes `approvedBy` and the note in the same update that moves the run to `acting`. - **Approving again finishes the handoff** (`packages/api/routes/agentDefinitionRoutes.ts`). If an approved run is still `acting` and its acting step hasn't been picked up (`actionTaskId` is null), approving again returns 200 and enqueues the acting step again, using the saved note. The job id is fixed per run, so a retry can't create a second job, and the existing claim on `actionTaskId` stops the step running twice. An approval whose step was already picked up still gets 409. So does an auto-mode run in `acting`, since it has no approver. - **Every enqueue path uses the saved note.** `enqueueAgentRunActionOrFail` now takes the note from the run by default. That also covers the existing recovery path in `processAgentRunJob` (`resumeActing`). The action worker reads `run.operatorNote` first and only falls back to the note in the job data. **One behaviour change:** a double-clicked Approve used to give 200 and 409. Now both clicks return 200. The run still moves once, only the first click's note is saved, and both clicks enqueue the same job id. I rewrote the existing test to match. **New tests** - The note is saved on approval. - After a simulated crash (run committed as approved, nothing enqueued), approving again enqueues the acting step with the saved note. - An approval whose step was already picked up returns 409. - An auto-mode `acting` run is not started by Approve. - The action worker uses the saved note when the job data has none. **Verification:** the agent autonomy, action, run-processor, run-store, trigger, definition-route and grant suites all pass. `npm run typecheck` is clean, and eslint reports nothing on the changed source files when run from their package directories. Nothing visual changed, so there are no previews. **Found separately, not fixed:** - Recovery depends on the user approving again. There is no background sweep that restarts an approved run stuck in `acting` on its own. - If an action job already failed all its retries before it was picked up, BullMQ keeps it and ignores a new job with the same id. A retried approval would then return 200 without anything running. This was already the case before this change and is outside F1. PR: #2849 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5 * feat(ai): I fixed F2 and F3. The new tests and the related suites pass, `npm run typecheck` is clean, and eslint reports nothing on the changed core files. I fixed F2 and F3. The new tests and the related suites pass, `npm run typecheck` is clean, and eslint reports nothing on the changed core files. **F2: upgrade migration for `operator_note`** - I added a new migration, `20261006010000_add_agent_run_operator_note.js`, which adds the nullable `operator_note` column to `agent_runs`. It skips the change if the column already exists, so installations that ran the edited original migration aren't affected. - I took the column back out of `20261006000000_create_agent_definitions.js`. Old installations and new databases now get the column the same way, from the new migration. - **New test:** it rolls back only the new migration, which leaves the schema an existing installation has today. It checks the column is gone, then migrates to latest, creates a run and approves it with a note. The note is saved. **F3: a failed redispatch no longer fails a run the worker has claimed** - I added `failUnclaimedAgentRunAction` in `agentRunStore.ts`. It marks a run failed in a single update, and only if the run is still `acting` with no `action_task_id`. If the update matches nothing, it returns null. - `enqueueAgentRunActionOrFail` now uses it when an enqueue fails, and returns the run as stored when the guard doesn't match. The shared helper serves approval, auto mode and the report-phase recovery path (`resumeActing` in `processAgentRunJob`), so all three are covered. - The helper's `transitionRun` option is replaced by `failUnclaimedAction`. I updated `autonomy.ts` and the in-memory test store to match. - **New tests:** - Two approvals where the worker claims the run between the first enqueue and the second one failing: the second still returns the run in `acting` with the worker's claim and no failure reason, and the worker can still complete it with its summary. - A failed enqueue on a run no worker has claimed still fails it with the reason. - Report-phase recovery: the claim lands after recovery read the run as unclaimed, then the enqueue fails. The run stays untouched. Two cases are still possible and can't be closed: the worker can claim the run just after the guarded update commits, or the run is failed first and its job was already queued. Either way the database update is the only thing that decides the outcome, and the worker's own claim, which uses the same condition, then finds nothing to claim. No external action runs on a run that has already been marked failed. There's nothing visual in this change, so I didn't make previews. PR: #2849 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5 --------- Co-authored-by: propr-dev[bot] <1316198+propr-dev[bot]@users.noreply.github.com>
|
/merge |
|
🔀 Resolved merge conflicts from Conflicting Files
Resolution SummaryI resolved the merge conflict, and the The conflict: The only conflict was in
How I resolved it: I kept all five export lines, with the PR's agents exports first and Why: Each side added different features, so they don't actually clash. The PR's agents work still needs its exports, and A search of the whole repo found no other conflict markers. The Gmail, Google Calendar and Google Drive connectors need to be authorized in your claude.ai connector settings before they can be used. They weren't needed for this task. 🤖 Resolution Details
System-triggered merge conflict resolution |
Automatically resolved merge conflicts after merging target branch into PR branch. Resolved conflicts in: - packages/core/src/index.ts PR: #2821 Model: Claude Opus 5.5
|
CI failed: CodeQL Please investigate and fix this CI failure.
Failure evidence
|
|
✅ Applied the requested follow-up changes in commit 5767210 Processed 2 comments:
Summary of ChangesI fixed both CodeQL "Missing rate limiting" alerts on The test server set up both routes without any rate limiting, which is what CodeQL flagged. It now uses All 10 tests in the file pass and the type check is clean. The tests need No preview: this change has no visible effect. 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
…ages/api/test/agentRunGrants.test.ts`. Both point at test routes, not production code. In `packages/api/server.ts:344-345`, the real grant routes already go through `createDiscoveryRequestRateLimiter()`.
I fixed both CodeQL "Missing rate limiting" alerts on `packages/api/test/agentRunGrants.test.ts`. Both point at test routes, not production code. In `packages/api/server.ts:344-345`, the real grant routes already go through `createDiscoveryRequestRateLimiter()`.
The test server set up both routes without any rate limiting, which is what CodeQL flagged. It now uses `createRequestRateLimiter({ identifier: 'agent-run-grants-test-fixture', limit: 100, windowMs: 60_000 })` before `express.json()`, the same way `demoMode.test.ts` does. That one setting covers both routes (issue and revoke). It's a two-line change to that file only.
All 10 tests in the file pass and the type check is clean. The tests need `PROPR_DEMO_MODE=true` set, because without GitHub auth the file fails to load. Lint has nothing to check because ESLint is set to ignore this file.
No preview: this change has no visible effect.
PR: #2821
Comment by: @github-advanced-security[bot] (ID: 4201323271)
Comment by: @github-advanced-security[bot] (ID: 4201323286)
Model: Claude Opus 5.5
|
✅ Applied the requested follow-up changes in commit 76f8cca Summary of ChangesThe CodeQL failure was on commit To make it more likely to pass, I changed const rateLimiter = createRequestRateLimiter({ identifier: 'agent-run-grants-test-fixture', limit: 100, windowMs: 60_000 });
app.use(express.json());
app.post('/api/internal/agent-runs/:runId/mcp-grants', rateLimiter, routes.issueGrant);
app.post('/api/internal/agent-runs/:runId/mcp-grants/revoke', rateLimiter, routes.revokeGrant);The test file is the only change; production code is untouched. All 10 tests in the file pass (run with No preview: nothing visible changed. 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
…er it (`5767210ea`, the current HEAD) already tried to fix it by adding a rate limiter to the test server with `app.use('/api', limiter, express.json())`. I can't confirm CodeQL accepts that version: the bot token gets a 403 on the code-scanning alerts API, and CodeQL hasn't run on HEAD yet.
The CodeQL failure was on commit `26f7514f`. The commit after it (`5767210ea`, the current HEAD) already tried to fix it by adding a rate limiter to the test server with `app.use('/api', limiter, express.json())`. I can't confirm CodeQL accepts that version: the bot token gets a 403 on the code-scanning alerts API, and CodeQL hasn't run on HEAD yet.
To make it more likely to pass, I changed `packages/api/test/agentRunGrants.test.ts` so the limiter sits directly on each of the two flagged routes. That's how production does it in `packages/api/server.ts:344-345`, and CodeQL doesn't flag those routes there:
```ts
const rateLimiter = createRequestRateLimiter({ identifier: 'agent-run-grants-test-fixture', limit: 100, windowMs: 60_000 });
app.use(express.json());
app.post('/api/internal/agent-runs/:runId/mcp-grants', rateLimiter, routes.issueGrant);
app.post('/api/internal/agent-runs/:runId/mcp-grants/revoke', rateLimiter, routes.revokeGrant);
```
The test file is the only change; production code is untouched. All 10 tests in the file pass (run with `PROPR_DEMO_MODE=true`), and the type check showed no errors. Whether CodeQL clears both alerts will only show on the next CI run.
No preview: nothing visible changed.
PR: #2821
Comment by: @propr-dev[bot] (ID: 6027180909)
Model: Claude Opus 5.5
|
CI failed: Validate Changes Please investigate and fix this CI failure.
Failure evidence
|
Checks FailedValidation failed during setup, tests, CLI packaging, linting, or build checks. View Logs |
|
✅ Applied the requested follow-up changes in commit f23ba80 Summary of ChangesI fixed the Validate Changes failure, and both Cause: Only the "Core Service" lint check failed; every other build and lint check passed. Fix: In import { generateCorrelationId, logger, reconcileEpicExecutionQueues } from '@propr/core';This matches how the branch already combined the There's nothing visual to show, so I didn't create a preview. 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
…int src/worker.ts --max-warnings 0` and the full `npm run lint` now pass locally.
I fixed the **Validate Changes** failure, and both `npx eslint src/worker.ts --max-warnings 0` and the full `npm run lint` now pass locally.
**Cause:** Only the "Core Service" lint check failed; every other build and lint check passed. `src/worker.ts` was 401 lines when counted by ESLint's `max-lines` rule, and the limit is 400. This branch added the `processAgentRunJob` and `processAgentActionJob` imports, which pushed the file one line over. With `--max-warnings 0`, that one warning failed the step.
**Fix:** In `src/worker.ts`, I combined two separate imports from `@propr/core` into one line:
```ts
import { generateCorrelationId, logger, reconcileEpicExecutionQueues } from '@propr/core';
```
This matches how the branch already combined the `loadSettings` imports. No behaviour changes.
There's nothing visual to show, so I didn't create a preview.
PR: #2821
Comment by: @propr-dev[bot] (ID: 6027548722)
Model: Claude Opus 5.5
|
ℹ️ Analyzed the follow-up request by @github-actions[bot] Analysis SummaryI didn't change anything: this failure is from an older commit, and the current branch already passes the check.
Re-running the checks on the current HEAD should clear Core Lint. Every other step in this run already passed. The file is now exactly at the limit, so the next line added to it will trigger the warning again. There's nothing visual here, so I didn't create a preview. No code changes were necessary based on the current state of the branch. 🤖 Analysis Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
…, API, MCP and CLI runs and `auto` acting steps now check provider usage before spending tokens. One part of the issue isn't wired yet: the deferred-run retry belongs to issue 12, which isn't on this branch. The gate already handles the 6-deferral limit when a retry passes in the existing run, and a test simulates that path.
All six acceptance criteria are covered by `test/agentRunCostGate.test.ts` (20 tests, passing). The existing agent, settings and Agent Tank test files I ran also pass. Typecheck is clean for the root, `packages/core` and `packages/api`, and eslint is clean on everything I touched.
The threshold setting. There was no instance-wide "pause at % of subscription usage" control; synthetic pools only have per-member limits. So I added `agent_run_usage_pause_percent` (whole number 50–100, default 90). It is validated on save, returned by the settings endpoint, listed in `SETTINGS_CATALOG`, and readable and writable through `get/update_execution_settings`. I regenerated `docs/docs/operations/settings-locations.md` to include it. It has no Settings UI field yet, so it can only be changed through MCP or the API.
The gate (`packages/core/src/services/agents/agentRunCostGate.ts`):
- Manual "Run now" always proceeds.
- No usage data (Agent Tank disabled, unreachable or no recent snapshot): the run proceeds. This is logged once per provider until data comes back.
- Weekly usage at or over the threshold: the run is skipped.
- Session usage at or over the threshold: the run is deferred until 2 minutes after the session resets, or 30 minutes at most. Once a run has been deferred 6 times, the next check skips it.
- Synthetic pools: every enabled member is checked, and the pool counts as near its limit only if all members are.
- Reasons: every skip and defer reason is a full sentence, e.g. "Weekly subscription usage for claude is at 95% (pause threshold 90%), so this run was skipped; …".
- Snapshots: the gate only reads the cached snapshot and never triggers a refresh. It accepts snapshots up to 1 hour old, longer than the 5 minutes used for pool routing.
- Future escalation: the module header states that any future escalation path must call this gate.
Wiring:
- REST trigger: uses this gate by default.
- Deferred runs now store their reason in `skipReason`. Before, it was only saved for skipped runs.
- `auto` acting step: if the gate holds back an unattended run, the run moves to `awaiting_approval` with "Acting paused: …", and the owner gets the same Inbox notification as preview runs.
- New route: `GET /api/agent-definitions/:id/capacity` returns `{ capacity, threshold }` for the UI warning.
- Usage snapshots now include when the session window resets (from Agent Tank's `resetsInSeconds`), which the deferral time is based on.
Existing tests I changed: I added the new setting to four expected settings responses in `test/configRoutes.followup.test.ts`. The existing auto-mode autonomy tests and the route tests now inject a gate that always lets runs through, so they don't read real config.
There's no visible UI change, so I didn't capture previews.
…res scheduled agents once per slot, retries deferred runs, fails stuck runs, and revokes leftover MCP grants. The 15 new tests in `test/agentRunScheduler.test.ts` pass, and so do the existing agent run tests I re-ran. Typecheck and eslint (`--max-warnings 0`) are clean. What's in `src/agentRunScheduler.ts` - Schedule sweep (`runAgentScheduleSweep`): - It picks up to 50 due definitions and claims each slot by moving `next_run_at` off the exact value it read. - It then fires through `triggerAgentRun` with the cost gate and the idempotency key `schedule:<slot ISO>`. - If the daemon missed several slots, one run is created for the latest due slot, and `next_run_at` moves to the next future slot. - If the owner is no longer a member, the schedule is turned off and no run is created. - If the definition no longer validates (`AGENT_INVALID`), a `skipped` run records the reason via a new `recordSkippedRun` helper. - Each definition has its own try/catch and logs one line with `definitionId`, `slot`, `runId` and `decision`. - Deferred retry: this reuses `retryDueDeferredAgentRuns`, which was already on the branch, with the same cost gate as the schedule sweep. - Stuck runs: `running`/`acting` runs whose task has been terminal in `task_history` for over 10 minutes are marked `failed` with "The worker stopped before recording the result." - Grant cleanup (every 10 minutes): revokes `agent_run_grant` records whose run has ended or is gone, or whose record has expired. It goes through the signed internal revoke route, and a failed revoke is retried on the next pass. - `scheduleAgentRunSweeps(intervalMs = 60_000)`: runs everything once at start, then on its interval, and never overlaps itself. It replaces `startDeferredAgentRunRetry` in `src/daemon.ts`. Shutdown clears both intervals and waits for any sweep still running. New core store helpers: `listDueScheduledAgentDefinitions`, `claimAgentDefinitionScheduleSlot` and `disableAgentDefinitionSchedule`. I removed `startDeferredAgentRunRetry` from core because nothing else used it. Where I differed from the issue - No `rescheduleDeferredRun`: the existing `redeferAgentRun` already does the guarded "stay deferred, count one more" update. - Revoke without a grant id: `revokeAgentRunMcpGrant` now accepts a call with no grant id, which the sweep needs because it only knows the run and phase. Decisions for you - Membership check: an owner counts as a member if they have an `instance_members` row or are in `PROPR_ADMIN_USERS`, and are allowed by the GitHub user whitelist if one is set. Users who log in without a membership row are not counted, so their schedules get turned off on the first due slot. That follows the issue's wording, but if those users are meant to keep scheduled agents, the check needs to include them. - Grant cleanup needs config: it only works if the daemon has `SYSTEM_TASK_SECRET` and can reach the API at `PROPR_INTERNAL_API_URL`. Without them it logs a warning for each leftover grant every 10 minutes and revokes nothing. There's nothing visual in this change, so I made no previews.
…es/api/mcp/toolsAgentRuns.ts`, registered in the tool catalog. The 7 new tests in `packages/api/test/mcpAgentRuns.test.ts` pass, and so do the existing MCP, agent-definition-route, run-grant and docs-manifest tests I re-ran. Typecheck and eslint (`--max-warnings 0`) are clean. The tools - Read scope: `list_agent_definitions`, `get_agent_definition`, `get_agent_definition_contract`, `list_agent_runs` and `get_agent_run`. - `list_agent_definitions` is paged, takes an optional `repository` filter, and leaves out prompts to keep pages small. - `get_agent_run` cuts reports over 200 KB, sets `reportTruncated: true`, and returns a `url` of the form `/agents/:definitionId/runs/:runId`. That path comes from the web UI issue (#2815), which isn't on this branch yet, so the link won't open until that UI lands. - Execute scope: - `trigger_agent_run` starts the run with trigger kind `mcp`, passes `'mcp:' + idempotencyKey` and goes through the cost gate. It returns `{ runId, state, created, continuation: { agentRunId } }` with status 202. - `approve_agent_run` (optional `note`) and `reject_agent_run` reuse the existing HTTP route logic, so a double approval still moves the run only once. Approving a run that isn't in preview mode fails with `AGENT_RUN_NOT_PREVIEW`. The rules from the issue - Repository access: every tool checks every repository of the definition, plus the repositories saved with the run. A definition with one repository the grant can't access is left out of lists. Calling a tool on it directly gives `REPOSITORY_FORBIDDEN`. Another user's definition or run gives `NOT_FOUND`. - No recursion: a token issued to an agent run gets `AGENT_RECURSION_FORBIDDEN` from trigger, approve and reject. It can still read. - `get_operation`: trigger and approve receipts now report the run's `state`, `reportedAt` and `finishedAt`. The receipt shows `running` once the run starts. It becomes `completed` when the run completes, is rejected or is skipped, and `failed` (code `AGENT_RUN_FAILED`) when the run fails. Changes outside the new module - New `authorize` hook on tools (`packages/api/mcp/toolExecution.ts`): it runs before the receipt is written. Without it, a recursion or repository denial would be stored as a failed receipt instead of being returned as the standard error. - Test hook: `ToolDeps` has a new optional `agentRuns` field so tests can supply their own trigger, cost gate and acting step. - Cancelled runs: the issue doesn't say what a cancelled run should do to its receipt. I chose to mark the receipt `cancelled`. - Docs: I added a row to `docs/mcp-coverage.md` and a "Run a saved agent" section to `docs/mcp.md`. - Existing test changed: `mcpObservableSurface.test.ts` checks every backticked word in `docs/mcp.md`. I added the new ones it flagged to its allowed list (`deferred`, `awaiting_approval`, `dry_run`, `preview`, `auto`, `note`, `created`). Acceptance criteria - Covered by tests: the same key returns the same receipt and creates one run; a grant missing a repository can't read or trigger; an agent-run token is refused; `get_operation` reaches `completed`. - Partly covered: the scope check filters the catalog the same way `tools/list` does, but doesn't call the MCP server's `tools/list` itself. There's nothing visible to capture, so I made no previews.
…ions`) for issue #2813. All 19 new tests pass, as do the 59 existing goal, index, completion and API-error tests I re-ran. `npm run typecheck` is clean. The CLI package has no eslint config, so the linter skips these files and I couldn't lint them. Nothing ran against a live server, so the server-side acceptance criteria are covered only by tests with stubbed HTTP responses. Client functions (`packages/cli/src/api/automations.ts`) - The eight requested functions call `/api/agent-definitions` and `/api/agent-runs`. - The trigger sends `Idempotency-Key` and `{ trigger: 'cli', source }`, and retries transient failures with the same key. It reuses the `mutate` helper from `goals.ts`, which I exported for this. - Approve, reject and cancel are sent once, without retries. The server checks the run's state before changing it, so a blind retry after a lost reply would just get a 409. Commands (`packages/cli/src/commands/automationCommands.ts`) - Subcommands: `list`, `show`, `run`, `runs`, `report`, `approve --note`, `reject` and `cancel`. - Key and `created`: `run` prints the run id, state, `created: true/false` and the key. If you don't pass a key, it generates `cli-<uuid>` and prints it. A failed command also prints the retry hint with that key. - `--wait`: polls every 5 s. Run metadata and state changes go to stderr; the report goes to stdout. - Exit codes: 0 completed, 2 timed out, 3 skipped or deferred (reason on stderr), 4 awaiting approval, and 1 for failed, rejected, cancelled or error. - `report`: writes only the Markdown to stdout. It exits 1 if the run has no report yet. - Errors: handled with `classifyApiError` / `presentApiError`. A 404 prints `Agent not found` (`Agent run not found` for run ids). - JSON: `--json` prints `{ version: 1, kind: ... }` documents, with kind `automation-run` for run results. - Help: the `run` help text includes a GitHub Actions example. Registration and docs - The group is registered in `commands/index.ts` and `index.ts`, and listed under "Command Groups" in `propr --help`. `propr agent` itself is unchanged. - I added an "Agents (saved automations)" section to `docs/docs/features/propr-cli.md`. Choices that differ slightly from the issue: - `--wait` stops on `deferred` (exit 3). A deferred run can wait hours for provider capacity, so polling would otherwise just run to the timeout. - `run` without `--wait` uses the same exit codes. A trigger that is deferred straight away exits 3, which is what the acceptance criterion describes. - Rejected and cancelled runs exit 1. The issue doesn't list them. - Help labels changed. The two group lines in `propr --help` are now labelled "Automations … (Agents: saved automations)" and "Agents … (coding-agent configurations)" so the two concepts don't get confused. No preview images were made, since this is a CLI-only change.
…client, the `/agents` routes, the sidebar entry, the list, and the create/edit form. The 10 new tests pass, as does the full UI suite (2043 tests). UI typecheck and lint are clean, and so is typecheck for the root and `packages/api`. Everything ran against stubbed API responses, never a live server, so the "edit in two tabs" check is only simulated.
What's in place
- API client (`propr-ui/src/api/agentDefinitionsApi.ts`): all 14 wrappers. Failed requests keep their HTTP status, so the editor can tell a 409 conflict from other errors.
- Routes and sidebar: `/agents`, `/agents/new`, `/agents/:definitionId` and `/agents/:definitionId/runs/:runId`, loaded as their own chunk. Agents sits after Goals with the `Workflow` icon; "Coding Agents" is unchanged.
- Page (`AgentsPage.tsx`): from 1280px wide, the list stays on the left and the selected agent opens beside it (Esc or ✕ closes it). Below that, the list and the agent are separate pages with a "Back to list" link.
- List (`AgentList.tsx`): each row shows the name, autonomy badge, short repo names, model, schedule ("Daily 09:00 UTC · next in 3h" or "Manual") and last run state. It has search, a "New agent" button, a skeleton while loading, and an empty state explaining what an agent is.
- Editor (`AgentEditor.tsx`, split into section files, each under 300 lines):
- All the requested fields: repo multi-select (max 10), prompt, input files, previous reports, model, capabilities, schedule and autonomy.
- The schedule has the four presets, a live "Next run" in UTC and inline errors from `validateAgentSchedule`.
- Saving checks with `validateAgentDefinitionInput` first and sends nothing if invalid.
- Saving sends `expectedRevision`; a 409 shows "Changed elsewhere — reload" with a Reload button and blocks Save.
- Delete asks for confirmation, and a 409 shows as an error.
- In demo mode the form is read-only and Run/Save are disabled.
Changes and choices you should know about
- Server change: the instance catalog had no agent type, so the UI couldn't tell an OpenCode agent from a Claude one. I added an optional `type` to catalog entries for direct agents (`packages/shared/src/instanceCatalog.ts`, `packages/api/routes/instanceCatalogRoutes.ts`) and updated the three existing tests that compare the exact catalog output. Pooled agents still have no type, so the UI allows `propr_mcp` for them and leaves the check to the server.
- Autonomy is also locked: for an unsupported agent like OpenCode, Preview and Auto are disabled as well as `propr_mcp`, because the server rejects those for agents without ProPR tools.
- Last run state costs one request per agent: the list endpoint doesn't return it, so the page fetches the latest run for each agent separately. Adding it to the list endpoint would be cheaper.
- Run detail isn't built yet: `/agents/:id/runs/:runId` currently just shows the agent editor until issue 16 adds the run view. "Run now" starts a run and shows a short notice rather than opening it.
Screenshots of the split view, the locked OpenCode toggles and the narrow-screen cron error are attached as previews.
|
/merge |
|
🔀 Resolved merge conflicts from Conflicting Files
Resolution SummaryAll five conflicts are resolved and no conflict markers remain. The root typecheck is clean and The conflicts1. 2. 3. 4. 5.
Extra changes needed for main's API spec checksOnce the agent routes were in the registry, main's spec generator and route coverage test failed. I made three small changes so the merged branch passes main's pull request checks:
ESLint couldn't check the files I touched, because there is no ESLint config that covers them. 🤖 Resolution Details
System-triggered merge conflict resolution |
Automatically resolved merge conflicts after merging target branch into PR branch. Resolved conflicts in: - CHANGELOG.md - packages/api/routes/taskHelpers.ts - packages/api/server.ts - packages/api/test/mcpObservableSurface.test.ts - src/daemon.ts PR: #2821 Model: Claude Opus 5.5
|
/ultrafix |
|
🔄 Ultrafix loop started (goal: 8/10, max cycles: 10) First action:
|
|
✅ AI Code Review Complete requested by @integry Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThis PR adds saved Agents across shared contracts, storage, execution, scheduling, REST, MCP, CLI, and UI. It needs changes before merge: MCP approval rejects auto runs paused for approval, and report sizing can exceed the MCP response limit. ✅ Shared validation — Definition limits, capability vocabulary, and UTC scheduling rules are centralized and exercised by boundary tests. ✅ Grant lifecycle — Phase grants use restricted scopes, transactional replacement, and grant-specific revocation that protects newer credentials from stale cleanup. ✅ UI response ordering — Version checks prevent older polling responses from overwriting newly recorded run state. This review is partial because 22 files were explicitly omitted, including the scheduler, REST routes, stores, and report executor. No commands or tests were run. The supplied authoritative check summary reports no blocking failures. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F1: 🔴 Allow approval of paused auto runs
F2: 🔴 Bound the entire MCP run response
SuggestionsThese are optional follow-ups and are not sent to S1: 🟢 Cache cron validation results
S2: 🟢 Reuse the accessible confirmation dialog
ScoreThe implementation has substantial defensive logic and targeted coverage, but two verified MCP correctness defects remain. Explicitly omitted files also limit confidence in the complete execution lifecycle. Score: 6/10 🤖 Review Details
Files omitted from review diff22 files were omitted from the review diff. Large, binary, generated, and lockfile changes are deprioritized. Did not fit the review context budget
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit e4b50fa
Summary of ChangesI fixed F1 and F2. All 12 tests in F1: approving paused auto runs. I checked the other places that make the same assumption. The web UI and CLI already decide by the run's state, not its autonomy mode. New test: an auto run paused by the cost gate can be approved, including repeating the same approval (the acting step starts once). It can also be rejected. An auto run that isn't waiting is refused, and its acting step isn't started. F2: whole-response budget for
The report still sets New test: every field at its stored limit in three-byte characters (the review's scenario) fits under the limit with the summary whole and the report cut. A second case uses characters that grow to six bytes when JSON-encoded; the summary and failure reason are then cut and flagged. I updated the I found nothing else outside these two findings. 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
…entRuns.test.ts` pass, including two new ones, and the `packages/api` typecheck is clean. ESLint skips these files because no lint config covers them, so they aren't linted. This is backend-only, so there are no previews. I fixed F1 and F2. All 12 tests in `packages/api/test/mcpAgentRuns.test.ts` pass, including two new ones, and the `packages/api` typecheck is clean. ESLint skips these files because no lint config covers them, so they aren't linted. This is backend-only, so there are no previews. **F1: approving paused auto runs.** `approve_agent_run` now refuses only `dry_run` runs, which never wait for approval; that refusal keeps the `AGENT_RUN_NOT_PREVIEW` code. Auto runs that the cost gate moved to `awaiting_approval` can now be approved. The ownership, repository and recursion checks are unchanged. Whether a run is still waiting is decided by the route's existing guarded state change, so approving an auto run that isn't waiting fails with `AGENT_RUN_NOT_AWAITING_APPROVAL`. I checked the other places that make the same assumption. The web UI and CLI already decide by the run's state, not its autonomy mode. `reject_agent_run` never had the check, so I only updated its description. New test: an auto run paused by the cost gate can be approved, including repeating the same approval (the acting step starts once). It can also be rejected. An auto run that isn't waiting is refused, and its acting step isn't started. **F2: whole-response budget for `get_agent_run`.** `runDetail` in `packages/api/mcp/toolsAgentRuns.ts` now fits the entire response under the 256 KiB limit, keeping 4 KiB free for the response wrapper. It sizes everything except the free-text fields first, then gives those fields the remaining room in this order: - **Short fields:** trigger source, skip reason, failure reason and operator note, up to 16 KiB each. - **Action summary:** up to 64 KiB. A summary at its 20,000-character limit in three-byte characters (about 60 KB) comes back whole. - **Report:** whatever room is left, up to the existing 200 KB. The report still sets `reportTruncated: true` when cut. Any other field that gets cut now carries its own flag, such as `actionSummaryTruncated: true`. New test: every field at its stored limit in three-byte characters (the review's scenario) fits under the limit with the summary whole and the report cut. A second case uses characters that grow to six bytes when JSON-encoded; the summary and failure reason are then cut and flagged. I updated the `get_agent_run`, `approve_agent_run` and `reject_agent_run` tool descriptions to match. I also changed one line each in `docs/docs/features/agents.md` (the truncation limits) and `docs/docs/features/mcp.md` (which runs can be approved). I found nothing else outside these two findings. PR: #2821 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
|
⏳ Ultrafix is waiting for CI before the next These blocking checks on
Checks matching this repository's non-blocking checks never gate Ultrafix. The loop continues automatically once the blocking checks pass; if they have not settled within 2 hours, Ultrafix stops. |
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThis PR adds saved Agents across contracts, storage, execution, scheduling, API, MCP, CLI, and UI. It needs a localized correction before merge. ✅ Separate acting phase — Report generation and acting use separate tasks, prompts, and phase-specific MCP grants. ✅ Guarded state changes — The supplied transitions and tests protect cancelled runs from late completion writes and prevent duplicate action claims. ✅ Credential handling — MCP tokens travel through process environment variables rather than command arguments, with explicit redaction coverage. This review is static and partial: 23 files were explicitly omitted, including the scheduler, report executor, stores, and REST handlers. No commands were run. The authoritative checks show 32 passed, none failed, and one pending. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F3: 🔴 Apply the production acting cost gate
SuggestionsThese are optional follow-ups and are not sent to S3: 🟢 Exercise runtime tests in CIThe native tool-policy tests skip unless the exact pinned CLI versions are installed. A dedicated CI job with those versions would make their behavioral checks dependable. This is optional validation improvement; the supplied check summary does not establish whether these particular tests executed. S4: 🟢 Reuse the accessible confirmation dialog
ScoreThe supplied implementation shows substantial defensive work and focused tests, but the production acting cost gate remains incomplete. Explicitly omitted execution and persistence files also limit review confidence. Score: 6/10 🤖 Review Details
Files omitted from review diff23 files were omitted from the review diff. Large, binary, generated, and lockfile changes are deprioritized. Did not fit the review context budget
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 6148762
Summary of ChangesI fixed F3: the acting step now re-checks the production cost gate when its queued job starts. All 267 tests in the related agent suites pass, including the new ones, and the root and What changed
Tests
The production-defaults test only proves a gate is wired in and that manual runs pass it. It doesn't run the over-threshold path against real Agent Tank data. The gate's threshold logic is covered separately in The checks between the gate and the claim are still not one atomic step. If usage rises just after the gate passes, the step still starts. The pause and the claim are both conditional database updates, so whichever runs first wins and the other does nothing. ESLint only checked the two 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
…st gate when its queued job starts. All 267 tests in the related agent suites pass, including the new ones, and the root and `packages/core` typechecks are clean. This is backend-only, so there are no previews. I fixed F3: the acting step now re-checks the production cost gate when its queued job starts. All 267 tests in the related agent suites pass, including the new ones, and the root and `packages/core` typechecks are clean. This is backend-only, so there are no previews. **What changed** - **`src/jobs/processAgentActionJob.ts`:** the processor's defaults now include the real cost gate (`createAgentRunCostGate()`), and it can no longer be left out. - Any acting step no human approved is checked against the gate after preflight. Approved steps are not checked, and the gate itself still lets "Run now" (`manual`) runs through. - If the gate skips or defers the step, the run goes back to **Awaiting approval** with an "Acting paused: …" reason. This happens before any task, workspace, MCP grant or container is created. The owner gets an Inbox item on a best-effort basis, the same way the after-report path does it. - A capacity hold no longer fails the run as "Acting step not started", which is what the old injected-gate code did. - **`packages/core/src/services/agents/agentRunStore.ts`:** a new `pauseUnclaimedAgentRunAction` moves a run from `acting` to `awaiting_approval`. It only does so while no action job has claimed the run and no one has approved it, so it can't override a run another delivery claimed, or a cancel or failure. I also added this `acting → awaiting_approval` step to `AGENT_RUN_TRANSITIONS` and its comment. - **`src/jobs/agentRuns/autonomy.ts`:** the "Acting paused: …" wording is now a shared helper (`actingPausedReason`), so both places that pause a run produce the same message. **Tests** - `test/processAgentActionJob.test.ts`: by default the test setup now passes every run through the gate. New tests cover: - a skip and a defer each returning the run to Awaiting approval without creating a task, grant or container. - an approved run not consulting the gate. - a run that left `acting` in the meantime not being paused. - a failed Inbox notification not undoing the pause. - the production defaults actually including a gate. - `test/agentRunStore.test.ts`: the new store function moves only runs that are unclaimed and unapproved. The production-defaults test only proves a gate is wired in and that manual runs pass it. It doesn't run the over-threshold path against real Agent Tank data. The gate's threshold logic is covered separately in `test/agentRunCostGate.test.ts`. The checks between the gate and the claim are still not one atomic step. If usage rises just after the gate passes, the step still starts. The pause and the claim are both conditional database updates, so whichever runs first wins and the other does nothing. ESLint only checked the two `src/jobs` files, which pass. It skips the store and test files because no lint config covers them. The existing Agents guide already describes this behavior, so I left the docs alone. PR: #2821 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
|
⏳ Ultrafix is waiting for CI before the next These blocking checks on
Checks matching this repository's non-blocking checks never gate Ultrafix. The loop continues automatically once the blocking checks pass; if they have not settled within 2 hours, Ultrafix stops. |
|
/review fable |
|
✅ AI Code Review Complete requested by @integry Posted 1 review: |
🔍 AI Code Review — fableOverall EvaluationThis PR delivers the complete Agents v1 epic (issues #2800–#2816): a shared contract and UTC cron evaluator, durable definition/run stores with a compare-and-set state machine, a single trigger primitive shared by REST/MCP/CLI/schedule, a report executor and a separate acting executor built on the existing task/worktree/container pipeline, native tool-policy enforcement for Claude/Codex (prompt-only elsewhere), run-scoped delegated MCP grants signed with ✅ Guarded state machine applied uniformly — Every writer to ✅ Token never enters the argument list — ✅ Obligations survive process death — The schedule slot stays pending until the receipt exists and is dispatched ( The PR is merge-ready within scope, conditional on the in-progress checks completing green. Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S5: 🟢 Cron validation is a 146k-day scan per call
S6: 🟢 Internal grant request signature does not cover a nonce or body
S7: 🟢 Internal grant endpoints share the discovery rate limiter
S8: 🟢 Confirm the MCP mount accepts the internal URLAgent containers call S9: 🟢 Normalise an empty agent selection to null in the form
S10: 🟢 Minor documentation inaccuracies
S11: 🟢 Repository-free runs launch with an empty
|
|
/merge |
|
🔀 Resolved merge conflicts from Conflicting Files
Resolution SummaryAll five conflicted files are resolved and no conflict markers remain anywhere in the repo. The root and
🤖 Resolution Details
System-triggered merge conflict resolution |
Automatically resolved merge conflicts after merging target branch into PR branch. Resolved conflicts in: - CHANGELOG.md - docs/static/openapi/propr-api.yaml - packages/api/mcp/toolsManagement.ts - packages/api/routes/configSettings.ts - src/worker.ts PR: #2821 Model: Claude Opus 5.5
|
CI failed: Validate Changes Please investigate and fix this CI failure.
Failure evidence
|
Checks FailedValidation failed during setup, tests, CLI packaging, linting, or build checks. View Logs |
|
✅ Applied the requested follow-up changes in commit 26f1c39 Processed 2 comments:
Summary of ChangesI fixed the CI failure. It was a lint error, not a test failure: What changed:
Checks:
This is backend-only, so there are no previews. 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
…lure: `packages/core/src/services/agents/agentRunStore.ts` had grown to 410 lines, over the 400-line `max-lines` limit, and the Core Package Lint step allows zero warnings. I fixed the CI failure. It was a lint error, not a test failure: `packages/core/src/services/agents/agentRunStore.ts` had grown to 410 lines, over the 400-line `max-lines` limit, and the Core Package Lint step allows zero warnings. **What changed:** - **New file `packages/core/src/services/agents/agentRunReports.ts`:** I moved the previous-report lookup there unchanged — `listPreviousReports` plus its `PreviousAgentReport` and `ListPreviousReportsOptions` types. It only reads `agent_runs`, so `agentRunStore.ts` is still the only module that writes run rows. The new file depends on `agentRunStore.ts`, but not the other way round. - **`packages/core/src/index.ts`:** it now exports the new module too, so code that imports from `@propr/core`, such as `src/jobs/processAgentRunJob.ts`, needed no changes. - **`test/agentRunStore.test.ts`:** it now imports `listPreviousReports` from the new file. **Checks:** - ESLint on the agents folder with zero warnings allowed passes. - The `packages/core` and root typechecks are clean. - All 81 tests in `test/agentRunStore.test.ts` and `test/processAgentRunJob.test.ts` pass. This is backend-only, so there are no previews. PR: #2821 Comment by: @propr-dev[bot] (ID: 6046750676) Comment by: @github-actions[bot] (ID: 6046751207) Model: Claude Opus 5.5
Agents v1: Scheduled Autonomous Report Agents Platform
This Epic PR aggregates all changes for the plan: Agents v1: Scheduled Autonomous Report Agents Platform
Issues in this Epic
propr automationcommand group with the run trigger primitive #2813: Agents v1 (14/17): CLI —propr automationcommand group with the run trigger primitiveAuto-close
When this PR is merged, the following issues will be automatically closed:
Fixes #2800
Fixes #2801
Fixes #2802
Fixes #2803
Fixes #2804
Fixes #2805
Fixes #2806
Fixes #2807
Fixes #2808
Fixes #2809
Fixes #2810
Fixes #2811
Fixes #2812
Fixes #2813
Fixes #2814
Fixes #2815
Fixes #2816
Created automatically by ProPR