Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/evolution-loop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ describe("evolution loop", () => {
)
.replace(AUTOMATION_MODEL_RE, 'model = "custom-model"')
.replace(AUTOMATION_REASONING_RE, 'reasoning_effort = "medium"')
.replace(AUTOMATION_RRULE_RE, 'rrule = "RRULE:FREQ=WEEKLY;BYDAY=FR"') +
.replace(AUTOMATION_RRULE_RE, 'rrule = "FREQ=WEEKLY;BYDAY=FR"') +
'\nnotification_policy = "failed_runs_only"\nexecution_environment = "local"\ntarget = { type = "project", project_id = "saved-project" }\n';
await Bun.write(automationPath, updated);
await Bun.write(
Expand All @@ -1392,7 +1392,7 @@ describe("evolution loop", () => {
true
);
const reenabled = await enableEvolutionLoop(project);
expect(reenabled.config.rrule).toContain("WEEKLY");
expect(reenabled.config.rrule).toBe("RRULE:FREQ=WEEKLY;BYDAY=FR");
const after = Bun.TOML.parse(
await readFile(automationPath, "utf8")
) as Record<string, unknown>;
Expand Down
8 changes: 6 additions & 2 deletions src/evolution-loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,11 @@ async function enableEvolutionLoopScoped(args: {
);
}
if (existingAutomation.exists && !args.rrule && existingAutomation.rrule) {
config.rrule = normalizeRrule(existingAutomation.rrule);
config.rrule = normalizeRrule(
existingAutomation.rrule.startsWith("RRULE:")
? existingAutomation.rrule
: `RRULE:${existingAutomation.rrule}`
Comment on lines +675 to +677

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize before checking the recurrence prefix

For a stored canonical recurrence whose prefix differs only by case or surrounding whitespace, such as rrule:freq=weekly, the previous direct normalizeRrule call accepted it because that helper trims and uppercases first. This case-sensitive precheck now prepends another prefix, producing RRULE:RRULE:FREQ=... and making re-enable fail. Apply the same trim/case normalization before deciding whether the native value needs a prefix.

Useful? React with 👍 / 👎.

);
}
const scaffold = existingAutomation.exists
? { path: join(args.homeDir, ".codex", "automations", name) }
Expand All @@ -697,7 +701,7 @@ async function enableEvolutionLoopScoped(args: {
homeDir: args.homeDir,
name,
status: "ACTIVE",
rrule: config.rrule,
rrule: args.rrule ? config.rrule : undefined,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore recurrence when the task has none

When an owned automation has lost its rrule field or stores an empty string, automationStatus still considers it registered because ownership identity only covers id, created_at, and cwds. Passing undefined here then activates the task without restoring a cadence, while enable persists a valid recurrence in its config and reports success, so the supposedly enabled loop may never be scheduled. Preserve the stored recurrence only when it is nonempty; otherwise pass the configured recurrence or reject the task.

Useful? React with 👍 / 👎.

});
await appendLoopAudit(args, {
generatedAt: now,
Expand Down
Loading