Skip to content

[3662 by Claude Opus 5.5] Automations: schedule "every N hours" (and daily/weekly at a time) without writing cron - #3667

Merged
integry merged 2 commits into
3602-epic-0-9-o23from
3662/claude-opus-5-5-automations-schedule-ever-20261117-0951-0yy
Nov 17, 2026
Merged

integry merged 2 commits into
3602-epic-0-9-o23from
3662/claude-opus-5-5-automations-schedule-ever-20261117-0951-0yy

Conversation

@propr-dev

@propr-dev propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI Implementation Summary

Closes #3662

Branch: 3662/claude-opus-5-5-automations-schedule-ever-20261117-0951-0yy
Commits: ✅ Changes committed (fc5554b)


AI Processing Completed

Execution Details:

Summary:
The schedule row now has three modes, Off, Repeat and Custom (cron), so "every 3 hours" or "weekdays at 09:00" can be set without writing cron. The stored value is the same cron string as before, so nothing changed in the API, storage or scheduler. All 230 tests in the Agents folder and the Agents page pass, typecheck and lint are clean, and 25 Playwright tests pass at 1440 px and 390 px.

Repeat controls

  • The row reads Every [N] [minutes | hours | day | week], then at [HH] : [MM] UTC for days and weeks, and Mon–Sun day toggles for weeks. Turning a schedule on starts from every day at 09:00 UTC.
  • Only intervals that repeat exactly are offered: every 15, 20 or 30 minutes; every 1, 2, 3, 4, 6, 8 or 12 hours; every day; and chosen weekdays. I left out 5 and 10 minutes because the validator's 15-minute minimum refuses them, rather than offering choices that always fail. The list is worked out from that minimum, so it follows if the minimum changes.
  • "Every 2 days" is not offered, even though the issue title mentions it: cron restarts a day count each month, so it would run on a different rhythm.
  • The last checked weekday can't be unchecked, so a weekly schedule always has at least one day.
  • I used separate hour and minute dropdowns instead of the browser's time field. In a US-English browser that field shows "07:30 AM", which clashes with the 24-hour UTC times shown elsewhere.

Opening and switching

  • An automation opens in Repeat only if the controls would produce exactly its stored expression. Anything else opens in Custom and is saved untouched. For example, 0 9 * * 1,2,3,4,5, @daily and 0 9 * * 7 stay in Custom.
  • Switching to Custom shows the expression Repeat generated, and the presets are still there as shortcuts.
  • Switching to Repeat on an expression it can't show keeps that expression, with the note "Keeps … until you change a control".
  • The "Next run" preview and the validator's error messages appear in every mode.
  • The hint is one line: "Times are UTC. Off: it runs only when started."

Wording in lists and run details
I extended the existing schedule describer (no second one). Schedules now read "Every hour", "Every 3 hours", "Every day at 09:00 UTC", "Every weekday at 07:00 UTC", "Every Mon, Wed, Fri at 09:00 UTC" and "Every month on day 1 at 06:00 UTC". Before, they read "Daily 09:00 UTC", "Weekdays 07:00 UTC", "Hourly" and so on. I also changed the monthly wording to match, which the issue didn't ask for. The run page's "Scheduled · …" text changes the same way. The existing tests and the docs table in docs/docs/features/agents.md are updated.

Code and tests

  • The mapping both ways is in a new agentScheduleRepeat.ts, next to agentPresentation.ts. The controls are in a new AgentScheduleRepeatControls.tsx. AgentScheduleSection.tsx still calls the same onChange({ scheduleEnabled, schedule }), so the editor and the template flow needed no changes.
  • Mapping tests cover every offered interval round-tripping, a set of expressions that must stay custom, and 0 9 * * 1-5 reading as Monday–Friday at 09:00.
  • Editor tests check that choosing "every 3 hours" saves 0 */3 * * * without typing. They also check that 0 9 * * 1-5 opens as weekly Mon–Fri at 09:00, and that a hand-written 15 9,17 * * 1-5 opens in Custom and saves unchanged. Further cases cover the kept-expression note, an inline validator error, and turning the schedule off and on again.
  • A new Playwright spec, e2e/automations-schedule-repeat.pw.ts, checks at 1440 px and 390 px that the controls fit on two rows or fewer with no horizontal scroll, that each one has a label, and that they can be reached with the keyboard.
  • I updated existing tests that clicked the old "Cron" button or looked for the cron field on a template.

Screenshots of Repeat (every 3 hours, weekly) and Custom at both widths are in the preview manifest.

Review digest

Risk-tiered paths

  • High risk (1 file)
    • docs/docs/features/agents.md (+7/−2): agent configuration
  • Normal risk (5 files)
    • propr-ui/src/components/Agents/AgentScheduleRepeatControls.tsx (added, +133/−0)
    • propr-ui/src/components/Agents/AgentScheduleSection.tsx (+110/−38)
    • propr-ui/src/components/Agents/agentPresentation.ts (+13/−13)
    • propr-ui/src/components/Agents/agentRunPresentation.ts (+1/−1)
    • propr-ui/src/components/Agents/agentScheduleRepeat.ts (added, +123/−0)
  • Low risk (9 files)
    • propr-ui/e2e/automations-form-validation.pw.ts (+1/−1)
    • propr-ui/e2e/automations-schedule-repeat.pw.ts (added, +97/−0)
    • propr-ui/src/components/Agents/AgentEditor.schedule.test.tsx (added, +164/−0)
    • propr-ui/src/components/Agents/AgentEditor.templates.test.tsx (+4/−1)
    • propr-ui/src/components/Agents/AgentEditor.test.tsx (+1/−1)
    • propr-ui/src/components/Agents/AgentEditor.validation.test.tsx (+1/−1)
    • propr-ui/src/components/Agents/agentSchedulePresentation.test.ts (+13/−13)
    • propr-ui/src/components/Agents/agentScheduleRepeat.test.ts (added, +84/−0)
    • propr-ui/src/pages/AgentsPage.test.tsx (+3/−3)

Validation evidence

  • No repository validation commands ran.

Diff size: 15 files changed, +755/−74 lines

Detailed Logs:

  • Conversation: 139 messages
  • Session: 7b93db02-c186-4fcd-b21e-f1b8a03291e5

Log files stored at:

  • conversation: /usr/src/app/logs/executions/issue-3662-2026-11-17T10-16-45-330Z-conversation.json
  • output: /usr/src/app/logs/executions/issue-3662-2026-11-17T10-16-45-330Z-output.txt
Latest Conversation Messages
ASSISTANT: [content unavailable]

ASSISTANT: The schedule row now has three modes, **Off**, **Repeat** and **Custom (cron)**, so "every 3 hours" or "weekdays at 09:00" can be set without writing cron. The stored value is the same cron string as ...


This PR was created automatically by ProPR after processing issue #3662.


💡 Need changes?

Comment on this PR to request refinements — the AI agent monitors comments and will update the implementation based on your feedback. Keep iterating until you're satisfied!


Visual preview

Custom (cron) shows the generated expression (1440px)

Custom (cron) shows the generated expression (1440px)

Switching to Custom shows 30 7 * * 1,2,4 written by the Repeat controls, with the presets as shortcuts

Full-size original

Custom (cron) (390px)

Custom (cron) (390px)

Custom mode at phone width

Full-size original

Repeat: every 3 hours (1440px)

Repeat: every 3 hours (1440px)

Schedule row with Off / Repeat / Custom (cron); Every 3 hours chosen from selects, live next run

Full-size original

Repeat: every 3 hours (390px)

Repeat: every 3 hours (390px)

Same controls at phone width

Full-size original

Repeat: weekly on chosen days (1440px)

Repeat: weekly on chosen days (1440px)

Every week at 07:30 UTC on Mon, Tue, Thu with weekday toggles

Full-size original

Repeat: weekly on chosen days (390px)

Repeat: weekly on chosen days (390px)

Weekly controls fit on two rows at phone width, no horizontal scroll

Full-size original

…so "every 3 hours" or "weekdays at 09:00" can be set without writing cron. The stored value is the same cron string as before, so nothing changed in the API, storage or scheduler. All 230 tests in the Agents folder and the Agents page pass, typecheck and lint are clean, and 25 Playwright tests pass at 1440 px and 390 px.

Repeat controls
- The row reads `Every [N] [minutes | hours | day | week]`, then `at [HH] : [MM] UTC` for days and weeks, and Mon–Sun day toggles for weeks. Turning a schedule on starts from every day at 09:00 UTC.
- Only intervals that repeat exactly are offered: every 15, 20 or 30 minutes; every 1, 2, 3, 4, 6, 8 or 12 hours; every day; and chosen weekdays. I left out 5 and 10 minutes because the validator's 15-minute minimum refuses them, rather than offering choices that always fail. The list is worked out from that minimum, so it follows if the minimum changes.
- "Every 2 days" is not offered, even though the issue title mentions it: cron restarts a day count each month, so it would run on a different rhythm.
- The last checked weekday can't be unchecked, so a weekly schedule always has at least one day.
- I used separate hour and minute dropdowns instead of the browser's time field. In a US-English browser that field shows "07:30 AM", which clashes with the 24-hour UTC times shown elsewhere.

Opening and switching
- An automation opens in Repeat only if the controls would produce exactly its stored expression. Anything else opens in Custom and is saved untouched. For example, `0 9 * * 1,2,3,4,5`, `@daily` and `0 9 * * 7` stay in Custom.
- Switching to Custom shows the expression Repeat generated, and the presets are still there as shortcuts.
- Switching to Repeat on an expression it can't show keeps that expression, with the note "Keeps `…` until you change a control".
- The "Next run" preview and the validator's error messages appear in every mode.
- The hint is one line: "Times are UTC. Off: it runs only when started."

Wording in lists and run details
I extended the existing schedule describer (no second one). Schedules now read "Every hour", "Every 3 hours", "Every day at 09:00 UTC", "Every weekday at 07:00 UTC", "Every Mon, Wed, Fri at 09:00 UTC" and "Every month on day 1 at 06:00 UTC". Before, they read "Daily 09:00 UTC", "Weekdays 07:00 UTC", "Hourly" and so on. I also changed the monthly wording to match, which the issue didn't ask for. The run page's "Scheduled · …" text changes the same way. The existing tests and the docs table in `docs/docs/features/agents.md` are updated.

Code and tests
- The mapping both ways is in a new `agentScheduleRepeat.ts`, next to `agentPresentation.ts`. The controls are in a new `AgentScheduleRepeatControls.tsx`. `AgentScheduleSection.tsx` still calls the same `onChange({ scheduleEnabled, schedule })`, so the editor and the template flow needed no changes.
- Mapping tests cover every offered interval round-tripping, a set of expressions that must stay custom, and `0 9 * * 1-5` reading as Monday–Friday at 09:00.
- Editor tests check that choosing "every 3 hours" saves `0 */3 * * *` without typing. They also check that `0 9 * * 1-5` opens as weekly Mon–Fri at 09:00, and that a hand-written `15 9,17 * * 1-5` opens in Custom and saves unchanged. Further cases cover the kept-expression note, an inline validator error, and turning the schedule off and on again.
- A new Playwright spec, `e2e/automations-schedule-repeat.pw.ts`, checks at 1440 px and 390 px that the controls fit on two rows or fewer with no horizontal scroll, that each one has a label, and that they can be reached with the keyboard.
- I updated existing tests that clicked the old "Cron" button or looked for the cron field on a template.

Screenshots of Repeat (every 3 hours, weekly) and Custom at both widths are in the preview manifest.
@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

/ultrafix goal=8 max=6
Triggered automatically by the requested execution settings.

@propr-dev propr-dev Bot added the ultrafix label Nov 17, 2026
@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

🔄 Ultrafix loop started (goal: 8/10, max cycles: 6)

First action: /review

💡 Tip: Remove the ultrafix label from this PR to stop further ultrafix cycles.

@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

⏳ Ultrafix is waiting for CI before the next /review.

These blocking checks on fc5554b are holding the loop back:

  • CLI Node Compatibility Guard — not finished
  • CLI and Connect Compatibility Guard — not finished
  • Packaged Connect Discovery Guard — not finished
  • Validate Docs Site — not finished

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.

@propr-dev

propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR adds plain-language Repeat controls while preserving the existing cron storage and scheduling contract. It is merge-ready within the reviewed scope, conditional on the pending checks completing successfully.

✅ Conservative cron conversion — cronToRepeat requires an exact normalized round-trip, keeping unsupported expressions in Custom without rewriting them.

✅ Valid interval choices — Offered minute and hour intervals divide their respective periods; weekday controls prevent an empty selection.

✅ Relevant regression coverage — Added tests cover generated schedules, preserved custom expressions, mode switching, validation feedback, and desktop/mobile layouts.

This review used the supplied diff and surrounding context only. No commands or tests were run. The authoritative check summary reports no failures and five pending checks.

Merge blockers

No merge blockers.

Suggestions

These are optional follow-ups and are not sent to /fix.

S1: 🟢 Complete radio keyboard behavior

AgentScheduleSection.tsx retains button-based radios without arrow-key navigation or a single tab stop. A follow-up could use native radios or implement the expected keyboard interaction, with a focused browser test. This is optional because the limitation predates this PR and the choices remain accessible through Tab and button activation.

Score

The implementation is scoped, preserves existing schedule expressions, and includes substantial targeted coverage. Pending CI results remain the final validation step.

Score: 9/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 30s
  • Tokens: 63,347 (62,877 in / 470 out)
  • Cost: $0.54

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix S1

🤖 Review by ProPR

@propr-dev propr-dev Bot removed the ultrafix label Nov 17, 2026

integry commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Owner decision made after this run started (issue #3662's body is updated to match): a cron schedule is a repeat, so there must not be a third mode.

Please change the schedule row to two segments only: Off and Repeat. Remove the "Custom (cron)" segment.

  • Inside Repeat, the plain controls (Every N minutes/hours/days/weeks, time, weekdays) are the default.
  • Under them, a small secondary link "Use a cron expression" swaps the controls for the expression field (with the preset chips beside it, if kept) and a "Use simple schedule" link to go back. It is an advanced input inside Repeat, not a mode in the segmented control.
  • An existing automation whose expression the controls can produce opens with the controls filled in; any other expression opens in Repeat with the expression field shown and the value unchanged. Going back to the simple controls from an expression they cannot represent keeps the expression until the user changes a control.
  • The word "cron" appears only in that link and the expression field's label: not in the segmented control, the row hint, or the list/detail schedule descriptions.

Update the tests accordingly (the segmented control has exactly Off and Repeat; a hand-written expression opens with the expression field and saves unchanged), and re-check the row at 1440 px and 390 px.

@propr-dev propr-dev Bot changed the title 🔨 [3662 by Claude Opus 5.5] Automations: schedule "every N hours" (and daily/weekly at a time) without writing cron ⚠️⑨ [3662 by Claude Opus 5.5] Automations: schedule "every N hours" (and daily/weekly at a time) without writing cron Nov 17, 2026

integry commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Please apply the change requested in the earlier comment on this PR (it has not been picked up): the schedule row must have exactly two segments, Off and Repeat. Remove the "Custom (cron)" segment; inside Repeat, a secondary link "Use a cron expression" swaps the plain controls for the expression field, with "Use simple schedule" to go back. An expression the controls cannot represent opens in Repeat with the expression field shown and is saved unchanged. The word "cron" appears only in that link and the field's label. Update the tests to match and re-check the row at 1440 px and 390 px.

@propr-dev propr-dev Bot changed the title ⚠️⑨ [3662 by Claude Opus 5.5] Automations: schedule "every N hours" (and daily/weekly at a time) without writing cron 🔨 [3662 by Claude Opus 5.5] Automations: schedule "every N hours" (and daily/weekly at a time) without writing cron Nov 17, 2026
@propr-dev

propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 6fc8586

Summary of Changes

The schedule row now has only two segments, Off and Repeat, and the "Custom (cron)" segment is gone. All 230 tests in the Agents folder and the Agents page pass, typecheck and lint are clean, and the 8 Playwright tests in the two automation-form specs pass at 1440 px and 390 px.

How Repeat works now (AgentScheduleSection.tsx)

  • Repeat opens with the plain controls. Under them, a small link "Use a cron expression" swaps them for the expression field, with the preset chips beside it. A "Use simple schedule" link goes back.
  • Switching to the expression field shows the expression the controls generated.
  • An existing automation whose expression the controls can produce opens with them filled in. Any other expression, such as 15 9,17 * * 1-5, opens in Repeat with the expression field shown and is saved unchanged.
  • Going back to the simple controls from an expression they can't represent keeps it, with the note "Keeps … until you change a control". Changing any control replaces it.
  • In the row, "cron" now appears only in that link and in the field's label, "Cron expression". The segments, the hint and the list/detail descriptions don't use it. A component test and the 1440/390 Playwright test both check the controls view.
  • With the keyboard, pressing Enter on either link leaves focus on the link that replaces it, so you can switch back straight away.

Tests and docs

  • Component tests: they now check that the segments read exactly Off and Repeat, and that a hand-written expression opens in Repeat with the field shown and saves unchanged. They also cover switching to the field and back, and keeping an expression the controls can't show.
  • Existing tests: the editor and validation tests that clicked "Custom (cron)" now choose Repeat and then the link.
  • Playwright (automations-schedule-repeat.pw.ts, automations-form-validation.pw.ts): at both widths the controls fit on two rows or fewer with no horizontal scroll. Every control has a label and can be reached with the keyboard. The new part: the link opens with Enter and shows 30 7 * * 1,2,4, and "Use simple schedule" brings back the weekly controls.
  • Docs: the schedule section of docs/docs/features/agents.md describes the link inside Repeat instead of a Custom mode. A code comment on the presets in agentPresentation.ts no longer mentions Custom.

Screenshots of the row at both widths are in the preview manifest: every 3 hours, weekly on chosen days, and the expression field inside Repeat.

Review digest

Risk-tiered paths

  • High risk (1 file)
    • docs/docs/features/agents.md (+4/−4): agent configuration
  • Normal risk (2 files)
    • propr-ui/src/components/Agents/AgentScheduleSection.tsx (+34/−19)
    • propr-ui/src/components/Agents/agentPresentation.ts (+1/−1)
  • Low risk (5 files)
    • propr-ui/e2e/automations-form-validation.pw.ts (+2/−1)
    • propr-ui/e2e/automations-schedule-repeat.pw.ts (+14/−4)
    • propr-ui/src/components/Agents/AgentEditor.schedule.test.tsx (+24/−13)
    • propr-ui/src/components/Agents/AgentEditor.test.tsx (+2/−1)
    • propr-ui/src/components/Agents/AgentEditor.validation.test.tsx (+2/−1)

Validation evidence

  • No repository validation commands ran.

Diff size: 8 files changed, +83/−44 lines

Visual preview

Off / Repeat: every 3 hours (1440px)

Off / Repeat: every 3 hours (1440px)

Two segments only; plain controls with the secondary "Use a cron expression" link under them

Original unavailable: managed storage is unavailable or the upload has expired.

Off / Repeat: every 3 hours (390px)

Off / Repeat: every 3 hours (390px)

Same row at phone width

Original unavailable: managed storage is unavailable or the upload has expired.

Repeat with the expression field (1440px)

Repeat with the expression field (1440px)

After "Use a cron expression": the generated 30 7 * * 1,2,4 with presets and a "Use simple schedule" link; Repeat stays selected

Original unavailable: managed storage is unavailable or the upload has expired.

Repeat with the expression field (390px)

Repeat with the expression field (390px)

Expression field inside Repeat at phone width

Original unavailable: managed storage is unavailable or the upload has expired.

Repeat: weekly on chosen days (1440px)

Repeat: weekly on chosen days (1440px)

Every week at 07:30 UTC on Mon, Tue, Thu

Original unavailable: managed storage is unavailable or the upload has expired.

Repeat: weekly on chosen days (390px)

Repeat: weekly on chosen days (390px)

Weekly controls fit on two rows at phone width, no horizontal scroll

Original unavailable: managed storage is unavailable or the upload has expired.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @integry
  • Time: 12m 6s
  • Tokens: 1,371,259 (1,359,548 in / 11,711 out)
  • Cost: $0.87
  • Subscription usage: Weekly +1%

Undo Changes • View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR
Processing comment ID: 6947331935✓

…epeat**, and the "Custom (cron)" segment is gone. All 230 tests in the Agents folder and the Agents page pass, typecheck and lint are clean, and the 8 Playwright tests in the two automation-form specs pass at 1440 px and 390 px.

The schedule row now has only two segments, **Off** and **Repeat**, and the "Custom (cron)" segment is gone. All 230 tests in the Agents folder and the Agents page pass, typecheck and lint are clean, and the 8 Playwright tests in the two automation-form specs pass at 1440 px and 390 px.

**How Repeat works now** (`AgentScheduleSection.tsx`)
- Repeat opens with the plain controls. Under them, a small link **"Use a cron expression"** swaps them for the expression field, with the preset chips beside it. A **"Use simple schedule"** link goes back.
- Switching to the expression field shows the expression the controls generated.
- An existing automation whose expression the controls can produce opens with them filled in. Any other expression, such as `15 9,17 * * 1-5`, opens in Repeat with the expression field shown and is saved unchanged.
- Going back to the simple controls from an expression they can't represent keeps it, with the note "Keeps … until you change a control". Changing any control replaces it.
- In the row, "cron" now appears only in that link and in the field's label, "Cron expression". The segments, the hint and the list/detail descriptions don't use it. A component test and the 1440/390 Playwright test both check the controls view.
- With the keyboard, pressing Enter on either link leaves focus on the link that replaces it, so you can switch back straight away.

**Tests and docs**
- **Component tests:** they now check that the segments read exactly Off and Repeat, and that a hand-written expression opens in Repeat with the field shown and saves unchanged. They also cover switching to the field and back, and keeping an expression the controls can't show.
- **Existing tests:** the editor and validation tests that clicked "Custom (cron)" now choose Repeat and then the link.
- **Playwright** (`automations-schedule-repeat.pw.ts`, `automations-form-validation.pw.ts`): at both widths the controls fit on two rows or fewer with no horizontal scroll. Every control has a label and can be reached with the keyboard. The new part: the link opens with Enter and shows `30 7 * * 1,2,4`, and "Use simple schedule" brings back the weekly controls.
- **Docs:** the schedule section of `docs/docs/features/agents.md` describes the link inside Repeat instead of a Custom mode. A code comment on the presets in `agentPresentation.ts` no longer mentions Custom.

Screenshots of the row at both widths are in the preview manifest: every 3 hours, weekly on chosen days, and the expression field inside Repeat.

PR: #3667
Comment by: @integry (ID: 6947331935)
Model: Claude Opus 5.5
@propr-dev propr-dev Bot changed the title 🔨 [3662 by Claude Opus 5.5] Automations: schedule "every N hours" (and daily/weekly at a time) without writing cron ✅⑨ [3662 by Claude Opus 5.5] Automations: schedule "every N hours" (and daily/weekly at a time) without writing cron Nov 17, 2026
@integry
integry merged commit 9a7427b into 3602-epic-0-9-o23 Nov 17, 2026
39 checks passed
@propr-dev propr-dev Bot changed the title ✅⑨ [3662 by Claude Opus 5.5] Automations: schedule "every N hours" (and daily/weekly at a time) without writing cron [3662 by Claude Opus 5.5] Automations: schedule "every N hours" (and daily/weekly at a time) without writing cron Nov 17, 2026
propr-dev Bot pushed a commit that referenced this pull request Nov 18, 2026
…melines. The second is my best reading of the evidence: I had no worker logs, so I couldn't watch it happen. There is no UI change, so no previews.

Cause 1: PRs opened by the retry fallback never got the `AI` label (#3643, propr-site#222, #226)

Evidence:
- All three PR bodies read `Resolves #N\n\n_PR created via retry mechanism_`.
- Their timelines have no `labeled AI` event. #3643's only label was `ultrafix`; #222's only label was `ultrafix`; #226 had none.
- For comparison, #3667 was created normally and has `labeled AI` and `labeled llm-claude-opus55` 2 s after it was opened.

What happened: when post-processing doesn't leave a PR, `retryPRCreationViaAPI` (`src/jobs/issueJobPRRetry.ts`) opens one, but it never added the labels that normal creation adds. The webhook then treats the PR as not opted in, so every plain follow-up was dropped as `no_comment_trigger` with only a debug log. `/ultrafix` still worked on #3643 and #222 because slash commands don't need the label, which is why these PRs looked half-alive. A PR found during final validation had the same gap.

Fix: new `src/jobs/pullRequestProcessingLabels.ts` adds the processing and model labels, with retries. It never throws, and it can't block the PR retry itself. It is called on the three recovery routes: a PR the retry creates, an existing PR it finds after a 422, and a PR found during final validation. `PR_LABEL` and `modelName` are passed in from `processGitHubIssueJob.ts`.

PRs that already exist without the label are not fixed by this. They need the `AI` label added by hand before follow-ups on them are accepted.

Cause 2: a follow-up stored behind a running job could be left with no job to pick it up (#3667)

Evidence:
- The first request (comment 6945632909, 10:37) never got a run.
- The re-sent text (6947331935, 11:56:00) got a brand-new job, `…-1794916564247`, created at 11:56:04. So nothing was queued for the PR at that point.
- That run's receipt lists only `trigger-comment-ids=6947331935`, so the first comment was not waiting anywhere.
- The two comments are 79 minutes apart, more than the pending list's 1-hour expiry.

What happened: when any job for the PR exists, intake only appends the comment to the `pending-pr-comments` Redis list and calls it accepted. An active job has already read that list when it started. It looks once more near the end of its cleanup, and some early-exit paths never look at all. A comment stored after that last look had nothing to read it, and the list expired an hour later: no run, no comment. Which job was running for #3667 at 10:37 is the part I couldn't confirm without logs.

Fix:
- New `packages/core/src/webhook/pendingCommentDrain.ts`: after storing a comment, if no waiting or delayed job exists for the PR, intake queues a drain job. That job waits for the PR lock and then picks up the stored comments. If queuing it fails, the webhook delivery fails and is redelivered instead of being lost.
- `cleanupJob` no longer queues a second follow-up when a job is already queued for the PR. The queue check lives in the new `src/jobs/prCommentQueuedPickup.ts`.

On a labelled PR, a matching follow-up now always ends as a queued run, or as one of the existing outcomes (a held follow-up, or the assignment-gate refusal comment). A PR whose first run failed in post-processing now gets its label, so later follow-ups are accepted.

Tests
- New `test/recoveredPullRequestLabels.test.ts` (6 tests): the retry route, the 422 route and the found-during-validation route all add the labels; transient label failures are retried and a lasting one is logged. 4 of these fail against the old code.
- `test/commentEventHandler.switch-use.test.ts`: 3 new tests (active job → drain queued; delayed job → no drain; a job for a different PR doesn't count). Four existing tests that asserted "nothing queued" behind an active job now expect the drain job. With the drain call disabled, 6 tests fail.
- `test/prCommentCleanupOrder.test.ts`: 3 new tests for the cleanup dedupe.
- 57 related suites (root, core and api tests that touch these files) pass. Lint passes with zero warnings and typecheck is clean for root and core. The Redis integration suite ran 0 tests here because there is no Redis in this container.
integry pushed a commit that referenced this pull request Nov 18, 2026
… is sometimes never picked up (#3700)

* I found two causes and fixed both. The first is proven from the PR timelines. The second is my best reading of the evidence: I had no worker logs, so I couldn't watch it happen. There is no UI change, so no previews.

Cause 1: PRs opened by the retry fallback never got the `AI` label (#3643, propr-site#222, #226)

Evidence:
- All three PR bodies read `Resolves #N\n\n_PR created via retry mechanism_`.
- Their timelines have no `labeled AI` event. #3643's only label was `ultrafix`; #222's only label was `ultrafix`; #226 had none.
- For comparison, #3667 was created normally and has `labeled AI` and `labeled llm-claude-opus55` 2 s after it was opened.

What happened: when post-processing doesn't leave a PR, `retryPRCreationViaAPI` (`src/jobs/issueJobPRRetry.ts`) opens one, but it never added the labels that normal creation adds. The webhook then treats the PR as not opted in, so every plain follow-up was dropped as `no_comment_trigger` with only a debug log. `/ultrafix` still worked on #3643 and #222 because slash commands don't need the label, which is why these PRs looked half-alive. A PR found during final validation had the same gap.

Fix: new `src/jobs/pullRequestProcessingLabels.ts` adds the processing and model labels, with retries. It never throws, and it can't block the PR retry itself. It is called on the three recovery routes: a PR the retry creates, an existing PR it finds after a 422, and a PR found during final validation. `PR_LABEL` and `modelName` are passed in from `processGitHubIssueJob.ts`.

PRs that already exist without the label are not fixed by this. They need the `AI` label added by hand before follow-ups on them are accepted.

Cause 2: a follow-up stored behind a running job could be left with no job to pick it up (#3667)

Evidence:
- The first request (comment 6945632909, 10:37) never got a run.
- The re-sent text (6947331935, 11:56:00) got a brand-new job, `…-1794916564247`, created at 11:56:04. So nothing was queued for the PR at that point.
- That run's receipt lists only `trigger-comment-ids=6947331935`, so the first comment was not waiting anywhere.
- The two comments are 79 minutes apart, more than the pending list's 1-hour expiry.

What happened: when any job for the PR exists, intake only appends the comment to the `pending-pr-comments` Redis list and calls it accepted. An active job has already read that list when it started. It looks once more near the end of its cleanup, and some early-exit paths never look at all. A comment stored after that last look had nothing to read it, and the list expired an hour later: no run, no comment. Which job was running for #3667 at 10:37 is the part I couldn't confirm without logs.

Fix:
- New `packages/core/src/webhook/pendingCommentDrain.ts`: after storing a comment, if no waiting or delayed job exists for the PR, intake queues a drain job. That job waits for the PR lock and then picks up the stored comments. If queuing it fails, the webhook delivery fails and is redelivered instead of being lost.
- `cleanupJob` no longer queues a second follow-up when a job is already queued for the PR. The queue check lives in the new `src/jobs/prCommentQueuedPickup.ts`.

On a labelled PR, a matching follow-up now always ends as a queued run, or as one of the existing outcomes (a held follow-up, or the assignment-gate refusal comment). A PR whose first run failed in post-processing now gets its label, so later follow-ups are accepted.

Tests
- New `test/recoveredPullRequestLabels.test.ts` (6 tests): the retry route, the 422 route and the found-during-validation route all add the labels; transient label failures are retried and a lasting one is logged. 4 of these fail against the old code.
- `test/commentEventHandler.switch-use.test.ts`: 3 new tests (active job → drain queued; delayed job → no drain; a job for a different PR doesn't count). Four existing tests that asserted "nothing queued" behind an active job now expect the drain job. With the drain call disabled, 6 tests fail.
- `test/prCommentCleanupOrder.test.ts`: 3 new tests for the cleanup dedupe.
- 57 related suites (root, core and api tests that touch these files) pass. Lint passes with zero warnings and typecheck is clean for root and core. The Redis integration suite ran 0 tests here because there is no Redis in this container.

* feat(ai): I've fixed F1. A delayed PR comment job no longer counts as the pickup for a stored follow-up if it runs after that follow-up's pending list expires. This applies to both intake and cleanup, so the usage-limit retry an hour away no longer blocks the timely drain or follow-up job.

I've fixed F1. A delayed PR comment job no longer counts as the pickup for a stored follow-up if it runs after that follow-up's pending list expires. This applies to both intake and cleanup, so the usage-limit retry an hour away no longer blocks the timely drain or follow-up job.

**The fix**
- **Run time comes from BullMQ's delayed set.** Both checks read the delayed job's score with `zscore` (the run timestamp shifted left 12 bits). I didn't use the job's `timestamp + delay` fields, because PR-lock waits move the job back to delayed: that rewrites `delay` relative to the move but keeps the original creation timestamp, so the sum would be too early.
- **Expiry comes from the list itself.** Both checks read the list's remaining TTL with `pttl`, instead of assuming 3,600 s. In cleanup the list may have been written up to an hour earlier.
- **The rule:** a waiting job always counts. A delayed job counts only if it runs at least 60 s before the list expires. If either the run time or the TTL can't be read, the code queues the drain rather than suppressing it; the cost is at most one extra job that claims an empty list.
- **Where it lives:**
  - Intake: `packages/core/src/webhook/pendingCommentDrain.ts`, with `storeCommentForBatch` in `commentEventHandler.ts` passing in the list's TTL.
  - Cleanup: `src/jobs/prCommentQueuedPickup.ts`, which `cleanupJob` now calls with the Redis client and the list key.
  - The check is duplicated in the two packages on purpose. Exporting a new helper from `@propr/core` would break the test suites that mock that module by listing its exports one by one.

I checked the sibling paths. Every intake route, including slash commands and `/switch`, goes through `storeCommentForBatch`, so the one intake change covers them all. The other jobs that sit delayed (lock waits) put their claimed comments back on the list with a fresh TTL, and they are now judged by their real run time too.

**Tests**
- New in `test/commentEventHandler.switch-use.test.ts`:
  - A comment arrives behind an active job while a usage-limit retry is queued 65 minutes out; intake queues a drain.
  - A delayed job whose run time can't be read; intake queues a drain.
  - The existing "delayed job, no drain" test now gives that job a run time 3 s away.
- New in `test/prCommentCleanupOrder.test.ts`, each showing cleanup still queues the follow-up:
  - behind a distant usage-limit retry.
  - behind a job due in 5 minutes when the list has only 2 minutes left.
  - behind a delayed job whose run time can't be read.
- All 5 new regressions fail against the previous source and pass now.
- All 32 related root and core suites pass, each run on its own. `ultrafixRecoveryRedisIntegration` ran 0 tests because there is no Redis in this container.
- Root lint passes with zero warnings, core lint is clean on the changed files, and typecheck is clean for root and core.

There is no UI change, so there are no previews.

PR: #3700
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5

* feat(ai): I fixed the failure. It was caused by this PR, and two shards hit it, not just Shard 3. In both, an older test still assumed that no job is queued while another job for the PR is running. The drain job this PR added now queues one in that case, which is the intended behaviour.

I fixed the failure. It was caused by this PR, and two shards hit it, not just Shard 3. In both, an older test still assumed that no job is queued while another job for the PR is running. The drain job this PR added now queues one in that case, which is the intended behaviour.

- **Shard 3/4:** `packages/api/test/taskFollowupRoutes.test.ts`, "review batched behind manual work preserves command metadata", failed with `1 !== 0` on the queued-job count.
- **Shard 1/4:** `packages/api/test/taskReviewRoutes.test.ts`, "dedicated review batched behind manual work retains review metadata and its idempotent receipt", failed the same way.

In both tests the only existing job for the PR is a running one. The command is still stored on the pending list and reported as `batched`, and the new code then queues a drain job to pick it up. That's the same change the earlier commit made to the four core tests in `commentEventHandler.switch-use.test.ts`.

**Fix:** I only changed the two tests, not the product code. They now expect exactly one drain job:
- In the follow-up test, the job is a delayed `processPullRequestComment` with empty `comments` and no `commandMode`. The command itself still goes only to the pending list.
- In the review test, the repeated request still adds nothing, so the count stays at one.

**Verification:** both suites pass locally (62 of 62 tests), and lint passes with zero warnings on the two files.

PR: #3700
Comment by: @propr-dev[bot] (ID: 6977156358)
Model: Claude Opus 5.5

---------

Co-authored-by: propr-dev[bot] <1316198+propr-dev[bot]@users.noreply.github.com>
propr-dev Bot pushed a commit that referenced this pull request Nov 24, 2026
I fixed the Validate Changes failure. The test's row counter was wrong; nothing on this branch caused it. The 390px weekly Repeat layout really is two rows, but the counter in `propr-ui/e2e/automations-schedule-repeat.pw.ts` sometimes counted it as three.

**Cause:** the test came from main (#3667), and this branch doesn't touch it. The previous commit passed this check, and only 1 of 987 browser tests failed in this run. The test counted rows as distinct `Math.round(top / 8)` values. In the first row, the unit select is 33px tall and the time selects are 32px tall. Because the row centres them vertically, their tops are 0.5px apart (465.5 vs 466 here). If the page's vertical position puts a rounding boundary between those two values, one row is counted twice. That position varies slightly by machine and font, which is why it failed in CI but not locally.

**Reproduced:** shifting the page down 2.25px made the old counter report 3 rows for the unchanged 2-row layout.

**Fix:** `rowsOf` now sorts the controls by their top edge. A control starts a new row only when it sits below the bottom of the current row, so controls of different heights on one line count as one row.

**Checked:**
- With the 2.25px shift, the new counter gives 2 rows, using both the bundled Inter font and the fallback font.
- At a 200px viewport it gives 5 rows, so it still catches real wrapping.
- The real spec passes at 1440px and 390px, and ESLint passes.
- I deleted the throwaway probe spec.

The change touches only that one test file; no product code changed and there's nothing visual, so no preview.

PR: #3777
Comment by: @propr-dev[bot] (ID: 7124274385)
Comment by: @github-actions[bot] (ID: 7124275523)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5
integry pushed a commit that referenced this pull request Nov 24, 2026
…read-write host credential mounts (#3777)

* chore: give agent runs per-run credential copies via a broker

I've implemented the credential broker for #3759. Agent task and analysis runs now get a per-run copy of only the credential and config files their CLI needs, instead of the host's whole credential directory mounted read-write. Refreshed tokens are written back afterwards.

How it works
- Manifests (`packages/core/src/agents/credentials/providerManifests.ts`): each provider lists the files it needs and which of them its CLI may refresh. For example, Claude refreshes only `.credentials.json` and Codex only `auth.json`. Antigravity uses the two files its entrypoint already copied. OpenCode has separate config and data stores. Vibe stays read-only, and its `.env` key is passed as a secret variable rather than a file.
- Broker (`broker.ts`, `credentialStoreLock.ts`): it has two calls that work with any runtime:
  - `materialize()` returns the files a run receives and the paths it must hand back.
  - `commit()` writes back only refreshed token files that actually changed. It does this under a per-store lock file and replaces each file atomically, keeping the owner, mode and the run's modification time.
- Concurrent runs: if the host file hasn't changed since the run started, the refreshed copy is written. If another run already replaced it, the more recently modified copy wins, so an older token never overwrites a newer one.
- What is never written back: sessions, logs, edited settings, new files and deletions. Symlinks are neither copied nor written through. A store over 2,000 files or 32 MiB is refused.
- API keys: if the agent's environment already has `ANTHROPIC_API_KEY`/`CLAUDE_CODE_OAUTH_TOKEN`, `CODEX_API_KEY` or `MISTRAL_API_KEY`, the OAuth token file isn't copied. Secrets reach the container by name only, so their values never appear in `docker run` arguments.
- Docker (`hostCredentialStaging.ts` and `runAgent` in `registry.ts`): each provider's credential mount is now tagged with its store. `runAgent` stages the copy in a per-run directory, points the mount at it, and writes back and deletes the copy when the run ends. Copies left behind by a crashed worker are swept after 24 hours.
- Where copies live: `PROPR_AGENT_CREDENTIAL_RUN_DIR`, defaulting to `<PROPR_MANAGED_CREDENTIALS_DIR>/.propr-runs`. Compose already mounts that root at the same path for the worker and the Docker daemon, which this relies on.
- Rollback flag: `PROPR_AGENT_CREDENTIAL_BROKER=legacy` restores the old direct mounts; `per-run` forces copies.

Where the old direct mount is still used
- Goal sessions (native Claude, Codex and Antigravity goals, and Codex goal resume) need their session state to stay in the credential directory between launches, so they keep the direct read-write mount. That gap is still open and is written up in the docs.
- Managed native-log capture (`PROPR_MANAGED_LOGS=1`) also defaults to the direct mount, because it reads provider logs from the host store. I made this choice so hosted diagnostics don't break; the issue didn't specify it.
- Vibe's `.env`: only `MISTRAL_API_KEY` is passed through. Any other variables in that file no longer reach the run.

Tests
- New `test/agentCredentialBroker.test.ts` (14 tests, all pass) covers:
  - a token-refresh round trip for each provider, checking that only manifest files are copied, only the token comes back, and the copy is cleaned up.
  - Vibe's secret variable and API-key runs.
  - the flag modes.
  - both completion orders for concurrent runs, and parallel completions on the lock.
  - stale and timed-out locks, and symlinks.
  - the file-list API and the full `runAgent` path.
- One added golden test checks that every provider tags its mount correctly and that goal runs keep the direct mount. The golden suite (27 tests) passes, and the argument lists are unchanged.
- About 137 related existing test files pass when run one at a time. Running them 4 at a time caused load timeouts and left the shared test SQLite file half-migrated. Three goal suites failed until I removed that file; with a fresh database they pass.
- Typecheck and zero-warning lint pass for `packages/core`.

Docs: `execution-safety.md` now replaces the read-write mount bullet with a "Per-run credential copies" section: a per-provider file table, write-back and conflict rules, the exceptions and the rollback flag. `coding-agent-integration.md` and `agent-runtime.md` are updated to match.

There's nothing visual to preview.

ProPR-Agent: claude/claude-opus-5-5

* chore: keep refreshed credentials safe with leases and write fallbacks

I've fixed F1, F2 and F3. The broker suite now has 19 tests and all pass. The golden argv, OpenCode and Compose-config suites pass too (71 tests), and typecheck and zero-warning lint pass for `packages/core`. I ran the new tests against the original code to make sure they fail there: the F1, F2 and F3 tests all did.

**F1: refreshes lost through read-only worker mounts**
- **Fallback to the direct mount:** before copying a store that has tokens to refresh, the worker now checks that it can write to the host directory. If the store is mounted read-only into the worker, or the worker's user can't write it, that store keeps its direct read-write mount as it did before this PR, and a warning is logged. Read-only stores with nothing to refresh, like Vibe, are still copied.
- **A failed write-back no longer deletes the copy:** if refreshed tokens can't be written back, the staged copy is kept with a `.propr-retained.json` file. It lists each staged file, its host path and the error, and the sweep never removes these copies. If nothing was refreshed, the copy is still deleted.
- **Compose change:** the indexing worker's `.claude`, `.gemini` and `.codex` mounts are now read-write, and so are its OpenCode mounts in `docker-compose.opencode.yml`. This means summarization runs get per-run copies instead of falling back. It does widen what the indexing worker can write on the host, so if you'd rather keep those mounts read-only, the fallback above still protects refreshes.

**F2: OpenCode fallback when there's no data mount**
- The OpenCode config manifest now copies `xdg-data/opencode/auth.json` and `xdg-data/opencode/account.json` into the run and writes them back when refreshed.

**F3: the sweep deleted live runs' credentials**
- **Lease file:** each staging directory now has a `.propr-lease` file that its worker refreshes every 5 minutes until the run's write-back is done. The sweep looks at the newer of the lease and the directory's own timestamp. It only removes a copy after 24 hours without a refresh, which means the worker that owned it is gone. Tests cover a run older than 24 hours with a fresh lease (kept), an abandoned lease (removed), and the timer actually refreshing the lease.

`execution-safety.md` covers all three changes.

**Found separately (not fixed):** the F2 change alone won't make that OpenCode setup authenticate. The launcher drops a user-set `XDG_DATA_HOME` and always sets `XDG_DATA_HOME=/tmp/propr-opencode-data`, filled only from a separate data mount. So OpenCode never reads the `xdg-data` files, and this was already true before this PR. Either the launcher should seed from `<config>/xdg-data/opencode` when there's no data mount, or the documentation in `agent-runtime.md` and `packages/cli/README.md` should drop that setup.

PR: #3777
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5

* chore: harden credential lock, env-file secrets and write-back mode

I've fixed F4, F5 and F6, each with a regression that fails on the previous code and passes now. The broker suite now has 21 tests, all passing, plus a new multiprocess lock test. The golden argv, Vibe, runtime-registry, network-restriction, scout, analysis-git and egress suites also pass, and so do typecheck and zero-warning lint for `packages/core`.

**F4: stale-lock takeover could delete a replacement lock** (`credentialStoreLock.ts`)
- **Lock ownership:** each acquisition now writes a unique token into the lock file. The file is published with `link()`, so it is never visible half-written. Releasing removes the file only if it still holds the releaser's token.
- **Breaking a stale lock:** a worker that sees a stale lock must first create an exclusive marker named after that lock's token, so only one worker can break that lock. The winner reads the lock again and removes it only if the token is unchanged. A worker that resumes late either loses the marker or sees a different token, so it removes nothing.
- **Crashed reclaimers:** if a reclaimer crashes holding a marker, the next one creates a new numbered marker instead of deleting the old one.
- **Remaining race:** a live holder that is mistakenly judged stale can still lose its lock. That needs a stall longer than 60 seconds inside a write-back that takes milliseconds, and no file-based lock can rule it out.
- **Regression:** `test/agentCredentialStoreLockMultiprocess.test.ts` starts five separate processes against a lock left by a crashed worker. Two of them are made to see the same stale lock before either breaks it, and one is paused until the other holds the replacement. Each process records whether it entered the critical section while another was inside. On the old code, four processes got in while another held the lock; on the new code there were no overlaps in 5 of 5 runs. The pause comes from a test-only `onStaleLockObserved` option I added to the lock options; the process script is `test/fixtures/credentialStoreLockContender.ts`.

**F5: environment files ignored when choosing fallback secrets** (`hostCredentialStaging.ts`)
- **The fix:** the check for which variables a run already sets now reads the run's environment files the way the Docker CLI does. A bare `NAME` line takes its value from the launch environment, and later files override earlier ones.
- **Why it matters:** Docker applies `-e` after every `--env-file`, so a key set in an env file now blocks the canonical `.env` fallback.
- **Same defect elsewhere:** the check that skips token files for API-key runs used the same incomplete list. It now also sees `CODEX_API_KEY` and the Claude keys when they come from an env file.
- **Regression:** a Vibe run with `MISTRAL_API_KEY=selected-key` in its env file and `old-key` in `.env` gets no fallback secret and no extra `-e`. A Codex env file with a bare `CODEX_API_KEY` skips `auth.json` when the launch environment sets the key, and copies it when it doesn't.

**F6: write-back changed the file mode** (`broker.ts`)
- **The fix:** `writeCanonical` now sets the canonical mode on the temporary file before the rename, after changing its owner.
- **Same defect elsewhere:** staging's `writeStore` already set the mode explicitly, so nothing else needed changing.
- **Regression:** a `0640` credential refreshed while the worker's umask is `0077` stays `0640`.

`execution-safety.md` now describes all three behaviours.

**Things to know:**
- The lock directory now needs to support hard links. The default `<managed credentials>/.propr-runs/.locks` on a local filesystem does, but a run directory on a filesystem without them would fail to take the lock.
- A takeover marker can be left behind only if a worker crashes in the middle of breaking a stale lock. It is a few bytes and has no effect on later locks.

PR: #3777
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5

* test: count Repeat layout rows by control bounds in schedule e2e test

I fixed the Validate Changes failure. The test's row counter was wrong; nothing on this branch caused it. The 390px weekly Repeat layout really is two rows, but the counter in `propr-ui/e2e/automations-schedule-repeat.pw.ts` sometimes counted it as three.

**Cause:** the test came from main (#3667), and this branch doesn't touch it. The previous commit passed this check, and only 1 of 987 browser tests failed in this run. The test counted rows as distinct `Math.round(top / 8)` values. In the first row, the unit select is 33px tall and the time selects are 32px tall. Because the row centres them vertically, their tops are 0.5px apart (465.5 vs 466 here). If the page's vertical position puts a rounding boundary between those two values, one row is counted twice. That position varies slightly by machine and font, which is why it failed in CI but not locally.

**Reproduced:** shifting the page down 2.25px made the old counter report 3 rows for the unchanged 2-row layout.

**Fix:** `rowsOf` now sorts the controls by their top edge. A control starts a new row only when it sits below the bottom of the current row, so controls of different heights on one line count as one row.

**Checked:**
- With the 2.25px shift, the new counter gives 2 rows, using both the bundled Inter font and the fallback font.
- At a 200px viewport it gives 5 rows, so it still catches real wrapping.
- The real spec passes at 1440px and 390px, and ESLint passes.
- I deleted the throwaway probe spec.

The change touches only that one test file; no product code changed and there's nothing visual, so no preview.

PR: #3777
Comment by: @propr-dev[bot] (ID: 7124274385)
Comment by: @github-actions[bot] (ID: 7124275523)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5

* fix: fix stale lock takeover and Vibe .env trailing comments

I fixed both findings, F7 and F8, and each has a regression test. Core typecheck and zero-warning lint pass, the broker suite passes (22 tests), and the multiprocess lock suite passes (2 tests). With `NODE_ENV=test`, the golden argv suite passes (27 tests); it fails without that variable, the same way the project's own test scripts would.

### F7: a stale takeover could remove the replacement lock
The old lock was one file that both release and takeover deleted after reading its token. That read-then-delete gap is what let an old holder delete another worker's lock. I rewrote `credentialStoreLock.ts` so no worker ever deletes another worker's lock file:

- **Numbered acquisitions:** each store's lock is now a directory of numbered files, one per acquisition. A worker takes the lock by creating the next number, and creation fails if that number already exists, so only one worker can get it.
- **Release:** the holder creates a `<n>.released` marker for its own number. A holder that resumes after being treated as stale only marks its own, already-replaced number, so it can't free the lock that replaced it.
- **Stale takeover:** if the newest number is unreleased and older than 60 seconds, a worker takes the next number. The old takeover-marker files are gone because this rule already lets only one worker win.
- **Cleanup:** after acquiring, a worker deletes numbers at least two behind its own and older than 60 seconds. If a delayed worker then reuses a deleted number, it sees a higher one after creating its file, marks its own released and retries.

One race can't be avoided: a holder paused for more than 60 seconds inside its write-back can be overtaken by another worker. That is the trade-off of a lock that expires without a heartbeat. The race the finding described, where a release runs late, is now fixed.

**Regression:** a new multiprocess test pauses the old holder just before its release until a second worker has taken over the stale lock. A third worker then starts and must wait for the second to finish. I also ran this test against the previous code with the pause placed between its token read and file deletion, and it failed with `later entered while replacement held the lock`. The existing test with competing workers reclaiming a crashed lock and the in-process lock tests now check lock state through a new helper, `inspectCredentialStoreLock`.

### F8: Vibe `.env` values with trailing comments
The new `packages/core/src/agents/credentials/dotenv.ts` parses the file the way python-dotenv does, and `broker.ts` now uses it:

- Quoted values stop at the closing quote and may span lines; a `#` comment may follow the closing quote.
- Escapes are decoded in double- and single-quoted values.
- An unquoted value loses a ` #` comment only when whitespace precedes it, so `mk#secret` keeps its `#`.
- `export ` prefixes and whole-line comments are handled.

`MISTRAL_API_KEY="mk-secret" # production account` now gives exactly `mk-secret`. The new test runs that line and six other cases through Vibe staging. The parser does not expand `${VAR}` references.

I checked the other env-file parser, `envFileValues` in `hostCredentialStaging.ts`. It deliberately follows Docker's `--env-file` rules, where values are taken as written, so it doesn't have this defect and I left it alone.

I also updated the "Concurrent runs" and "API keys" notes in `execution-safety.md` to match. There was nothing visual to preview.

PR: #3777
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5

* chore: skip stored Vibe credentials.json on API-key runs

I fixed F9: an API-key Vibe run no longer gets the stored `credentials.json`.

**What changed**
- **Manifest** (`providerManifests.ts`): manifest entries now have a `login` flag, separate from `refresh`. `refresh` still means "write this back after the run" and also counts as a login. Vibe's `credentials.json` is now a login file but not a refresh file, so it stays read-only with nothing written back.
- **Broker** (`broker.ts`, `materializeStore()`): files are now skipped when the run is an API-key run and the file is a login file. Before, they were skipped only when both API-key and refresh were true, which let Vibe's file through. Write-back still depends only on `refresh`.
- **Docs** (`execution-safety.md`): the API-key bullet now names the stored login file for each provider, including Vibe's `credentials.json`.

**Same defect elsewhere:** none. Only Claude, Codex and Vibe check for an API key. Claude's and Codex's login files are already refresh files, so they were already skipped. Their other copied files (settings, `config.toml`, instructions) hold no login. OpenCode and Antigravity have no API-key variables, so the rule doesn't apply to them. This path has no async or concurrency side.

**Regression test:** I extended the existing API-key test in `test/agentCredentialBroker.test.ts`. The Vibe store now includes `credentials.json`:
- With `MISTRAL_API_KEY` set, only `config.toml` is copied. The skipped list shows `credentials.json` with reason `api-key-env`, and nothing is marked for write-back.
- Without the key, the run still receives `credentials.json`, and nothing is marked for write-back.

**Verification**
- `test/agentCredentialBroker.test.ts` and `test/agentRunSpecGoldenArgv.test.ts`: 49 of 49 pass. They need `npx tsx --experimental-test-module-mocks --test`.
- I put back the old skip condition and the new assertion failed (21 pass, 1 fail). Then I restored the fix.
- Typecheck and zero-warning lint for `packages/core` pass.

There's nothing visual, so I made no preview.

PR: #3777
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5

* chore: withhold Vibe credentials.json when .env has MISTRAL_API_KEY

F10 is fixed. When a Vibe store's `.env` has a nonempty `MISTRAL_API_KEY`, the run gets that key and no longer gets `credentials.json`. A store without a usable key still gets its login.

**Fix** (`packages/core/src/agents/credentials/broker.ts`, `materializeStore()`): a run now counts as an API-key run if the agent's environment defines the key, or if the broker has just pulled a nonempty value for it from the store's `.env`. The run receives that pulled key, so withholding the stored login is correct. An empty `MISTRAL_API_KEY=` doesn't count, so a store like that still gets its login. What gets written back after the run is unchanged.

**Same mistake elsewhere:** none. Vibe is the only provider whose manifest pulls keys from a file (`secretEnvFiles`). Claude and Codex only check keys the run itself sets, which the existing check already covered. OpenCode and Antigravity don't use API-key variables. The change has no async, locking or write-back side.

**Regression test** (`test/agentCredentialBroker.test.ts`): I replaced the last Vibe case, the one that expected `credentials.json` even though its store had a `.env` key. It now checks that:
- a run with only the store's `.env` key gets `MISTRAL_API_KEY: 'from-file'`, receives only `config.toml`, and `credentials.json` is listed as skipped for `api-key-env`.
- a store with no `.env`, and one with an empty key, both still receive `config.toml` and `credentials.json`, with no secret variable, nothing skipped and nothing written back.

**Docs:** I added one sentence to the API-key bullet in `docs/docs/features/execution-safety.md` saying a `.env` key also withholds `credentials.json`.

**Verification:**
- The broker suite passes, 22 of 22.
- With the old line put back temporarily, the updated test fails on "an extracted key excludes the stored login".
- Typecheck for `packages/core` and the zero-warning lint on `broker.ts` both pass.

I didn't add a visual preview because nothing on screen changes.

PR: #3777
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5

* chore: fence stale credential lock takeovers and bound secret reads

I fixed F11 and F12, and each new regression test fails on the old code and passes now.

## F11: stale takeover now fences writes
I didn't use a process-lifetime lock. The worker, API and indexing worker containers share the lock directory but each has its own process ID space, so a pid check can't tell whether another container's worker is still alive. Instead, a takeover now cancels the old holder's right to publish:

- **Each lock holder gets its own folder** (`credentialStoreLock.ts`). It is called `.propr-writeback-<epoch>` and sits inside the host credential folder. `withCredentialStoreLock` hands it to the caller, and the holder removes it before releasing the lock.
- **Write-back prepares the new file there** (`writeCanonical` in `broker.ts`). The new token is written in that folder and then moved into place.
- **A takeover moves the old folders away first.** Every new holder renames older holders' folders before it does anything else. A rename can't half-happen, so the old writer either moved its file in before the takeover, or its move fails because the folder is gone. Either way the new holder reads the host file only after that point.
- **The timing gap during acquisition is closed too.** A new holder creates its folder before re-checking the lock, and a takeover creates its lock number before moving folders. So either the slow holder sees the takeover and backs off, or the takeover finds its folder and moves it.
- **The old writer retries** (`commit`). It takes the lock again and compares against the current host file using the existing newer-wins rule, so it records "kept the host copy" instead of failing. It gives up after 3 attempts.

New test in `test/agentCredentialStoreLockMultiprocess.test.ts` (fixture: `test/fixtures/credentialWriteBackContender.ts`): the older run is paused right before its final move, and the newer run takes over the stale lock and writes its token. The test checks that the newer token survives, the older run reports "kept the host copy", and nothing is left behind in the credential folder. On the old code the older token ends up on the host.

## F12: secret-file size is checked before reading
`readRegularFileInside` (`broker.ts`) checks the size before opening and again after opening. It then reads in 64 KiB pieces and stops once the limit is passed, so a file that grows mid-read is still refused. It also refuses symlinks and won't hang on a special file swapped in at the last moment.

Four places in this PR's code read a whole file before checking its size, and all now use it:
- Vibe's `.env` (64 KiB limit), which is F12 itself.
- Each file copied from the store, limited to what's left of the 32 MiB budget.
- The host token file re-read during write-back. A host file over 32 MiB now stops the write-back with an error instead of being read.
- Refreshed token files collected from the run's copy (1 MiB limit), in `hostCredentialStaging.ts`.

New `test/agentCredentialBoundedReads.test.ts` (5 tests) counts the bytes actually read:
- A 1 GiB sparse `.env` is skipped with 0 bytes read; the old code read the whole 1 GiB.
- For the other cases, the file grows between the size check and the read, and the read stops just past the limit.

## Checks
- The four credential and golden test files: 57 tests pass, and they also pass under umask 0077.
- I ran the multiprocess test file 3 more times with no failures.
- Typecheck and zero-warning lint pass for `packages/core`.

## Worth knowing
- **Visible side effect:** during a write-back, a short-lived `.propr-writeback-<n>` folder appears inside the host credential folder. CLIs that mount that folder directly, as goal sessions do, may briefly see it.
- **Same filesystem assumed:** the new file is now moved from the credential folder's top level rather than from beside the target. If a nested token path sat on a different mount, the move would fail. None of the current manifests do that.
- **API changes:** the `withCredentialStoreLock` callback now receives a lease. `CredentialStoreLease`, `CredentialStoreLeaseRevokedError` and `readRegularFileInside` are exported from `@propr/core`, and the broker options gained an `onBeforePublish` test hook.
- **Docs:** the concurrent-runs paragraph in `execution-safety.md` now describes the fence.

Separate from F11 and F12, I didn't change one related gap: run copies are still cleaned up after 24 hours without a lease refresh. A worker paused for longer than that could lose its run copy before writing back.

PR: #3777
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5

* chore: refuse explicit per-run runs when the store isn't writable

I fixed F13: when an operator explicitly sets `PROPR_AGENT_CREDENTIAL_BROKER=per-run`, a run whose credential store the worker can't write to is now refused. Before, it quietly got the whole canonical store mounted directly.

**What changed** (`packages/core/src/agents/credentials/hostCredentialStaging.ts`)
- The mode check now also records whether the operator set the value or it's just the default. `resolveCredentialBrokerMode` returns the same results as before.
- `stageAgentRunCredentials` throws if the selection is explicit and any per-run store fails the write-access check. This happens before anything is staged. The check covers every spelling of the setting (`per-run`, `on`, `1`, `true`) and still applies when `PROPR_MANAGED_LOGS=1`. Another writable store in the same spec doesn't let the unwritable one through.
- Since `runAgent` stages before it starts the run, the error stops the launch and no container starts. The error names the provider and store; the host paths go only to the worker log.
- With the setting unset, the old behaviour is kept: the store is mounted directly and a warning is logged. Vibe and other stores with nothing to write back are still copied as normal.

**Why refuse instead of staging anyway:** I didn't use the other option the finding allowed, which is to stage the copy and keep it when write-back fails. Claude and Codex replace their refresh tokens when they refresh. If the new token can't be written back, the next run starts from a token that no longer works. Every run that refreshed would also leave a copy that is never cleaned up.

**Tests** (`test/agentCredentialBroker.test.ts`)
- New regression: "explicit per-run refuses a store the worker cannot write instead of mounting the canonical store". It covers:
  - the refusal for each spelling and with managed logs on.
  - a spec mixing a writable and an unwritable store.
  - an API-key run.
  - that nothing is staged and `runAgent` starts no container.
  - that a read-only Vibe store is still copied.

  It fakes a read-only worker mount by making the write-access check fail, so it also runs as root; the existing `chmod`-based test skips itself under root.
- I renamed that existing test to "by default, …", since the direct mount now only happens by default.
- Run against the unfixed source, the new test fails with "Missing expected exception"; with the fix all 23 tests pass.
- Related suites pass: runtime registry (24), network restriction (7), golden argv (27) and the Docker watchdog (14).
- Typecheck and zero-warning lint pass for `packages/core`.

**Docs:** the "Stores the worker cannot write" and "Rollback" bullets in `execution-safety.md` now say that an explicit `per-run` refuses such runs.

**Other paths checked:**
- `runAgent` is the only caller of the staging function.
- Runtimes that can't bind-mount are already refused, so they never fall back to the canonical store.
- A store that becomes unwritable during a run can't be prevented at launch. That case still uses the existing recovery, which keeps the staged copy and logs where it is.

**Found separately, not changed:** goal sessions still get the direct read-write mount even with `per-run` set explicitly. That covers native Claude, Codex and Antigravity goal sessions, plus Codex goal runs. The PR documents this as a known gap, and closing it would mean redesigning how goal sessions resume, which is outside F13.

There's nothing visual to preview.

PR: #3777
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5

---------

Co-authored-by: propr-dev[bot] <1316198+propr-dev[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant