Skip to content

CLI: move sync, list, shell, dash under jobs (breaking) - #95

Open
aflanagan wants to merge 6 commits into
masterfrom
agent/jobs-subcommands-9623
Open

aflanagan wants to merge 6 commits into
masterfrom
agent/jobs-subcommands-9623

Conversation

@aflanagan

@aflanagan aflanagan commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Plan

sync (alias discover), list, shell, and dash move under a new top-level jobs command. ping, exec, and every other command stay at the root. This is a clean break: no root aliases, hidden forwarders, or deprecation shims.

Files:

  • cmd/jobs.go adds jobs and documents the four subcommands. cmd/discover.go, cmd/list.go, cmd/shell.go, and cmd/dash.go reparent those commands and update help, examples, the dry-run rerun hint, and the systemd ExecStart comment. jobs uses cobra.NoArgs, so an unknown subcommand fails instead of printing help and exiting 0. Bare cronitor jobs still prints help.
  • cmd/configure.go points the saved-config hint at cronitor jobs sync.
  • lib/crontab.go does not write an auto-discover line. Auto-discover has been off by default since 2020, and this major release removes the hidden --no-auto-discover opt-in. jobs sync removes an active line only when it is the old installed plumbing: optional run-as user, optional cronitor exec <key>, a cronitor binary, optional global flags, optional jobs, then discover and the whole word --auto. It does not add a replacement. A commented-out copy of that line is left unchanged. A # Name: or # cronitor: ignore above the removed line is not applied to the next job. When sync removes a line, it prints one notice to stderr.
  • In-repo references: README.md, docs/MCP_INTEGRATION.md, docs/MCP_PROMPTS.md, docs/IP-ACCESS-RESTRICTIONS.md, dockerfile, web/src/components/Docs.js, bats tests, the shell-shim fixtures, and the Go tests that invoke the old paths. docs/releases/*.md is unchanged.

Tests:

  • cmd/jobs_test.go locks the layout: the four subcommands live under jobs, jobs discover resolves to sync, the root rejects sync, discover, list, shell, and dash, and jobs not-a-command is an unknown command.
  • TestLegacyAutoDiscoverLine checks that installed legacy lines are removed (a cronitor binary, jobs discover, an exec wrapper, a global flag, and a run-as user), that user jobs which only resemble discover --auto stay, and that a # Name: or # cronitor: ignore above the removed line does not carry onto the next job.

Risks:

  • Scripts, MCP configs, and already-installed cronitor discover --auto crontab lines call commands that no longer exist.
  • jobs sync removes that old plumbing line. It does not install a replacement. The hidden auto-discover opt-in is removed in this major release.
  • Release the dashboard as crontab-dashboard, next to cronitor (34.0) #89 turns cronitor dash into a launcher. Whichever of these two lands second needs a rebase, and that launcher belongs at jobs dash.

Command mapping

Before After
cronitor sync cronitor jobs sync
cronitor discover cronitor jobs discover (alias of jobs sync only)
cronitor list cronitor jobs list
cronitor shell cronitor jobs shell
cronitor dash cronitor jobs dash

Flags are unchanged, except the hidden --no-auto-discover flag, which is removed. jobs dash --mcp-instance and the legacy jobs dash --mcp stay. cronitor exec and cronitor ping crontab lines are unaffected.

Breaking change

Intended for the first Monocle major release. There are no compatibility aliases.

What breaks:

  • Scripts that call cronitor sync, cronitor discover, cronitor list, cronitor shell, or cronitor dash, including pipelines such as cronitor sync --auto file | crontab -. Those invocations fail with Cobra's normal unknown-command error. cronitor jobs <typo> fails the same way.
  • Crontab lines previously installed as cronitor discover --auto ... no longer run, because discover is not a root command. Auto-discover has been off by default since 2020. The hidden --no-auto-discover opt-in is removed in this major release. cronitor jobs sync removes an active recognized discover --auto line, leaves a commented-out one unchanged, and does not add a replacement. An old line that still says cronitor discover --auto --no-auto-discover=false fails as an unknown command, not an unknown flag.
  • MCP client configs that spawn cronitor dash --mcp-instance .... The args become ["jobs", "dash", "--mcp-instance", "..."].
  • Docs, install instructions, and the container CMD that named the old paths. This repo's README, MCP docs, dashboard copy, and dockerfile are updated here.

jobs sync --auto still prints the original crontab on failure, the same as 33.16.

Release notes

  • A Docker CMD override of the old cronitor dash must become cronitor jobs dash.

Pull request #89

Do not merge this onto #89 or the reverse without a rebase. #89 splits the dashboard into crontab-dashboard and turns cronitor dash into a launcher. After both land, that launcher should be cronitor jobs dash, not a root dash.

Dev-only checks

  • cd web && npm ci && npm run build succeeded. web/static/ is gitignored and is rebuilt in CI.
  • go build ./... succeeded. go test ./... passed on this revision, including TestCompat_LogPresignAndUploadFromExec. cronitor jobs prints help and exits 0. cronitor jobs not-a-command prints unknown command and exits 1.
  • go vet ./... still fails on the pre-existing unkeyed TimezoneLocationName literal in cmd/root.go. This change does not touch that line.
  • bats tests/test-list.bats passed 1 and skipped 1 on Linux. The suite needs root because tests/setup_suite.bash writes /etc/cronitor.
  • tests/test-discover.bats is updated and was not run against the live Cronitor API.

Dropped from the committed tests, checked while developing:

  • Flag presence: sync --auto, --dry-run, --format, --with-monitored, --silent; dash --mcp-instance and --mcp; list --json.

Website docs to update

gh api repos/cronitorio/cronitor returns 404 for this token, so these are the published markdown pages that still name the old commands. No docs PR was opened.

  • docs/using-cronitor-cli.md — cronitor sync, list, shell, dash, and cronitor dash --mcp-instance
  • docs/agent-quickstart.md — cronitor sync
  • docs/sdks.md — cronitor sync
  • docs/mcp-server.md — names list and sync as local runtime commands
  • guides/cron-jobs.md — cronitor sync, cronitor discover, and the FAQ that says the alias is top-level
  • guides/windows-scheduled-tasks.md — cronitor sync
  • guides/cron-job-testing.md — cronitor shell
  • guides/running-cron-jobs-inside-a-docker-container.md — cronitor sync --file
Open in Web Open in Cursor 

risky: yes (conservative): it changes the dockerfile CMD to jobs dash and the CI test scripts' command names, which is build-adjacent. Otherwise this moves commands under jobs and rewrites the legacy discover line in crontabs. It doesn't touch auth, API keys, secrets, the release or install scripts, or the API surface.

These four commands now live only under cronitor jobs. Root
invocations fail as unknown commands. discover stays as an alias
of jobs sync, and the auto-discover crontab line targets that
subcommand even when inherited flags sit between the two words.

Co-authored-by: August Flanagan <aflanagan@users.noreply.github.com>
Comment thread cmd/jobs.go
// sync, list, shell, and dash are only available here. The root command does
// not keep those names as aliases or hidden forwarders.
var jobsCmd = &cobra.Command{
Use: "jobs",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Non-blocking: jobs has no Run/Args, so an unknown subcommand exits 0 and prints the group help on stdout:

$ cronitor jobs snyc /etc/crontab; echo $?
Commands for the cron jobs on this machine.
...
0

The root now rejects sync with exit 1, so a typo under the new path is quieter than the removed path. It also interacts with the documented out=$(cronitor jobs sync --auto file) && printf '%s\n' "$out" | crontab - pattern if someone drops the flags. monitor and issue already exit 1 here; group and auth don't, so the repo is mixed. Consider adding Args: cobra.NoArgs (or a RunE that returns an unknown-command error) so jobs <typo> fails like cronitor <typo>.

Comment thread lib/crontab.go Outdated
// `jobs discover`, including when inherited flags sit between the two words
// (`jobs --hostname box sync`). sync is written as discover so
// IsAutoDiscoverCommand still matches. Flag values are not rewritten.
func ensureAutoOnJobsSubcommand(args []string) []string {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Non-blocking, about the legacy cronitor discover --auto line. I checked whether sync should rewrite it, and I don't think that's needed for this PR:

  • Auto-discover has been off by default since 6f51049 (Feb 2020): noAutoDiscover = true, and --no-auto-discover is deprecated and hidden.
  • With that default, Parse(true) drops any recognized plumbing line. I ran a scratch test through runSyncArgs with 17 * * * * cronitor discover --auto /etc/crontab in the fixture. A plain jobs sync --auto output the crontab without the line. Only --no-auto-discover=false kept it, unrewritten and wrapped as CRONITOR=<key> cronitor discover --auto /etc/crontab.
  • Old hourly lines also ran discover --auto under the same default, so they normally removed themselves long ago.

So the only population left is users who pass a hidden, deprecated flag. In that path, a one-line rewrite in Parse (a plumbing line whose command has discover with no preceding jobs gets jobs discover) would be cheap. Key() ignores the command for plumbing lines, so the monitor key stays stable. That's fine as a follow-up.

The PR description's Risks and Breaking-change sections say a later jobs sync "keeps" the old line and tell people to "let sync add the new line". By default, sync removes the line and never adds one. Please fix that wording before it turns into release notes.

Separately, ensureAutoOnJobsSubcommand plus inheritedBoolFlag/inheritedValueFlag is about 120 lines for that same hidden path. The flag tables duplicate RootCmd's persistent flags by hand and will drift when one is added. A new persistent bool flag between jobs and sync would be read as taking a value. The non-jobs discover fallback can't be reached now that the root rejects discover. Consider building the line from the parsed command (or a plain jobs sync to jobs discover replacement) and keeping one test.

Comment thread cmd/jobs_test.go Outdated
if err != nil || viaAlias != discoverCmd {
t.Fatalf("jobs discover resolved to %v (%v)", viaAlias, err)
}
for _, flag := range []string{"auto", "dry-run", "format", "with-monitored", "silent"} {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Non-blocking (tests should be critical only): the layout lock is worth keeping. That means checking that the four subcommands live under jobs, that jobs discover resolves to sync, and that the root rejects the old names. The per-flag Lookup checks for auto/dry-run/format/with-monitored/silent/mcp-instance/mcp/json don't protect anything this PR could break. Reparenting a command can't drop its local flags, and the existing sync tests already exercise those flags through jobs sync. Consider removing this block. The five-case TestCreateAutoDiscoverLineTargetsJobsSubcommand in lib/crontab_test.go could likewise shrink to one or two cases, given the line is only written behind a hidden, deprecated flag.

@cursor

cursor Bot commented Nov 8, 2026

Copy link
Copy Markdown

VERDICT: APPROVE

Second-model review at head 693c5125c72127f2279a38a10b8b88d374da683c.

There is no AGENTS.md at this head, on master, or on any fetched ref, so I reviewed against the brief's rules: critical tests only, and no new env vars or config.

Verification

  • cd web && npm ci && npm run build: ok. go build: ok.
  • go test ./...: lib passes. In cmd, only TestCompat_LogPresignAndUploadFromExec fails, and it fails identically on base b5e7bac, so it is environment-specific to my VM. CI on this head passes Linux, Windows, and stable Go.
  • go vet reports only the existing unkeyed TimezoneLocationName literals in cmd/root.go.
  • I compared master and PR binaries for list, list --json, list on a missing path, sync --auto on a missing file, sync --auto with a bad API version, and an unknown flag. Stdout, stderr, and exit codes are identical apart from the command path in usage and help text.
  • TestSyncAutoPrintsOriginalWhenAPIFails and the other TestSyncAuto* tests pass through jobs sync, so the 33.16 behavior (print the original crontab and exit 1 on failure) is unchanged.
  • The root sync, discover, list, shell, and dash all exit 1 with unknown command. ping and exec are untouched.
  • Wrapper and exec parsing are unaffected. TestWrapDetection (with the new jobs sync, jobs discover, and jobs dash cases) and the exec, shim, and run-as tests pass. The new arg handling runs only in createAutoDiscoverLine.
  • References: help text, the dry-run rerun hint, the configure hint, the dash "run again" message, the systemd ExecStart comment, dockerfile CMD, README, docs/MCP_*, docs/IP-ACCESS-RESTRICTIONS.md, web/src/components/Docs.js (including the MCP args arrays), bats tests, and fixtures are all updated. A repo-wide grep outside docs/releases/ found no stale invocations.
  • No new env vars or config.

Blocking

None.

Non-blocking

  1. Legacy cronitor discover --auto line (inline on lib/crontab.go). No migration is needed here. Auto-discover has been off by default since 2020, and a default jobs sync already removes a recognized plumbing line; I confirmed this with a scratch sync test. The line survives unrewritten, and gets wrapped with a monitor key, only with the hidden, deprecated --no-auto-discover=false. A small rewrite in Parse for that path would be fine as a follow-up. Please correct the PR description: it says a later sync "keeps" the old line and tells people to "let sync add the new line", but by default sync deletes it and never adds one.
  2. jobs <typo> exits 0 with help on stdout (inline on cmd/jobs.go). Consider Args: cobra.NoArgs so it fails like cronitor <typo>.
  3. ensureAutoOnJobsSubcommand is heavy for a hidden path. It is about 120 lines, its flag tables duplicate RootCmd persistent flags by hand and will drift, and its non-jobs fallback can't be reached.
  4. Tests (inline on cmd/jobs_test.go). Keep the layout lock. The per-flag Lookup assertions and the five-case auto-discover-line test go beyond "critical only".
  5. Coordination with Release the dashboard as crontab-dashboard, next to cronitor (34.0) #89, as the description already notes: the launcher must land at jobs dash.

cronitor jobs with an unknown subcommand now returns an
unknown-command error. The hidden auto-discover line writer only
rewrites the jobs subcommand to discover --auto, and the opt-in
path writes an old discover --auto line in that form.

Co-authored-by: August Flanagan <aflanagan@users.noreply.github.com>
@cursor

cursor Bot commented Nov 8, 2026

Copy link
Copy Markdown

VERDICT: APPROVE

Re-review at c36328d, covering git diff 693c512..c36328d plus the full PR against b5e7bac. All four notes from my previous approval are addressed. The description now matches the code, jobs <typo> exits 1, the writer is a single token pass with no hand-copied flag list, and the tests are trimmed.

Blockers

None.

What I checked

  • Builds and tests: cd web && npm ci && npm run build passed. go build passed. In go test ./..., lib passes and cmd has one failure, TestCompat_LogPresignAndUploadFromExec ("expected log presign"). That failure is pre-existing and specific to my VM: it fails the same way on b5e7bac (base) and 693c512, it tests exec log upload (which this PR doesn't touch), and it passes in this PR's CI (Linux, Windows, and stable Go tests are all green). Every other cmd test passes, including the 33.16 --auto and rerun tests.
  • CLI with the built binary:
    • Bare cronitor jobs and jobs --help print help and exit 0.
    • jobs not-a-command prints unknown command "not-a-command" for "cronitor jobs" and exits 1. jobs --bogus exits 1.
    • --help exits 0 for jobs sync, jobs discover, jobs list, jobs shell, jobs dash, jobs --verbose sync, jobs --hostname box sync, --hostname box jobs sync, and help jobs sync.
    • Root sync and discover fail with unknown command and exit 1. ping and exec are unchanged.
  • 33.16 behavior: against the base, cmd/discover.go only changes RootCmd.AddCommand to jobsCmd.AddCommand, plus help and comment text. The path where sync --auto prints the original crontab on failure is untouched.
  • Token rewrite: I drove createAutoDiscoverLine and an opt-in Parse with a throwaway test (not committed). These cases are handled correctly:
    • --exclude-from-name "jobs sync discover" and -e sync stay intact, because only the first sync or discover token after jobs is replaced.
    • Flags before jobs work, including --hostname jobs jobs sync and --hostname sync jobs sync.
    • jobs --hostname box sync becomes jobs --hostname box discover --auto.
    • --auto=true is dropped, and jobs discover --auto doesn't double the flag.
    • Paths are matched as whole tokens, so /home/jobs/sync, C:\Users\jobs\sync\crontab, C:\Program Files\cronitor\cronitor.exe, and a binary at /usr/local/bin/jobs are left alone.
    • On the opt-in path, a legacy cronitor discover --auto line, including one wrapped in exec, is written as jobs discover --auto. The default jobs sync removes it.
    • Rewritten lines are rendered from CommandToRun by writeUsing, because rawJob stops matching once that field changes, so the output is consistent.

Non-blocking notes

  1. One input still produces a broken line. If a flag value between jobs and the subcommand is literally sync or discover, that value is the token that gets rewritten. cronitor jobs --hostname sync sync --no-auto-discover=false writes cronitor jobs --hostname discover --auto sync …, and running that fails with unknown flag: --auto. This needs the hidden opt-in plus that exact flag value, so I accept the trade for dropping the flag list. A one-line comment on autoDiscoverCommand stating the limit would help.
  2. A rewritten legacy line takes the current command's arguments, not its own. In Parse, a legacy cronitor discover --auto /etc/cron.d/foo is replaced with autoDiscoverCommand(c), which is built from os.Args. If jobs sync --no-auto-discover=false ran without a file argument, the new line loses /etc/cron.d/foo. The old createAutoDiscoverLine had the same flaw for new lines, and the path is hidden, so this isn't new risk. If you want to keep the old line's arguments, inserting jobs before discover --auto in the existing line.CommandToRun would do it.
  3. The Parse check for a current line is a substring match, so some valid lines get rewritten again. strings.Contains(line.CommandToRun, "jobs discover --auto") misses lines the writer itself produces with flags between jobs and discover, for example jobs --hostname box discover --auto. It also misses jobs discover --auto with two spaces, which comes from the legacy --verbose strip. On the next opt-in run those lines are rewritten again from that run's arguments. Nothing breaks, it just churns.
  4. jobs is now runnable, which changes two small things. cronitor jobs help now exits 1 with unknown command. Cobra only adds the help subcommand at the root, and cronitor help jobs still works. Usage also shows cronitor jobs [flags] above cronitor jobs [command]. Both are cosmetic.
  5. The typo test changes global state. TestJobsCommandLayout now calls RootCmd.Execute(). The SetArgs(nil) cleanup is there, but if more tests start executing RootCmd, it's worth keeping them out of t.Parallel.

@aflanagan

Copy link
Copy Markdown
Contributor Author

Owner triage of the Opus re-review notes (#95 (comment)), at c36328d. I'm skipping all of them for now, with reasons:

  1. A flag value of sync/discover placed between jobs and the subcommand: this only happens with the hidden, deprecated --no-auto-discover=false opt-in combined with that literal value. That's very unlikely, and it fails loudly rather than silently.
  2. A legacy line takes the current run's args: this matches the pre-existing behavior for new lines, and it's limited to the same deprecated opt-in path.
  3. The substring up-to-date check causes some lines to be rewritten again: harmless, since the rewrite is idempotent and nothing breaks.
  4. jobs help exits 1, and the usage shows jobs [flags]: cosmetic. cronitor help jobs and cronitor jobs --help both work.
  5. The typo test touches root state: the test isn't parallel and its cleanup is already in place, so no change is needed.

CI is green on c36328d and Opus approved, so this PR is ready. It's for the first Monocle major release; not merging.

@cursor

cursor Bot commented Nov 12, 2026

Copy link
Copy Markdown

Interrogate (Grok 4.7 xhigh-fast)

Intent

This change puts sync, list, shell, and dash only under cronitor jobs for the Monocle major release. jobs discover is an alias of jobs sync. ping, exec, and the other root commands stay at the root. Old root names fail as unknown commands, cronitor jobs <unknown> fails the same way, and bare cronitor jobs still prints help and exits 0. There is no compatibility shim.

Auto-discover stays off by default. A normal jobs sync removes a recognized discover --auto line and does not add one. The hidden opt-in --no-auto-discover=false is the only path that keeps or writes that line, and on that path the written command is jobs discover --auto (spelled discover so the existing matcher still sees it). A user's own jobs sync --auto job is left alone. exec and ping lines are left alone. Help, docs in this repo, and the dockerfile use the new paths. Historical release notes and the website repo staying on the old names is intended.

Findings

1. Opt-in rewrite is discarded when the new command is not monitorable

Same root cause, two triggers. Parse(false) replaces the old line's CommandToRun with jobs discover --auto ..., but Write() (what sync saves and prints) emits the original FullLine when IsMonitorable() is false. The new command is not monitorable when it contains cron.daily / cron.hourly / cron.weekly / cron.monthly / run-parts, or cronitor.link / cronitor.io. A normal path with none of those strings is rewritten, so this is not every opt-in sync.

The intent requires the written crontab to contain jobs discover --auto and to no longer contain the old root cronitor discover --auto command.

Command (review worktree at c36328d; repro is lib/interrogate_rewrite_test.go, not part of the PR). Ran twice; both exits were 1 and the failures matched. Second run:

cd /tmp/arena-interrogate/candidate-1 && go test ./lib/ -count=1 -run 'TestInterrogate_OptInRewriteDropped' -v
=== RUN   TestInterrogate_OptInRewriteDroppedWhenCommandLooksMeta
    interrogate_rewrite_test.go:78: meta line monitorable=false cmd="cronitor jobs discover --auto --no-auto-discover=false /tmp/TestInterrogate_OptInRewriteDroppedWhenCommandLooksMeta3182648002/001/cron.daily" full="15 * * * * cronitor discover --auto /etc/crontab"
    interrogate_rewrite_test.go:78: meta line monitorable=true cmd="echo hello" full="0 * * * * echo hello"
    interrogate_rewrite_test.go:81: meta write:
        15 * * * * cronitor discover --auto /etc/crontab
        0 * * * * echo hello
    interrogate_rewrite_test.go:83: rewrite discarded; old command written:
        15 * * * * cronitor discover --auto /etc/crontab
        0 * * * * echo hello
--- FAIL: TestInterrogate_OptInRewriteDroppedWhenCommandLooksMeta (0.00s)
=== RUN   TestInterrogate_OptInRewriteDroppedWhenHostContainsCronitorLink
    interrogate_rewrite_test.go:102: link line monitorable=false cmd="cronitor jobs discover --auto --no-auto-discover=false --ping-api-host eu.cronitor.link /tmp/TestInterrogate_OptInRewriteDroppedWhenHostContainsCronitorLink231623467/001/crontab" full="15 * * * * cronitor discover --auto /etc/crontab"
    interrogate_rewrite_test.go:102: link line monitorable=true cmd="echo hello" full="0 * * * * echo hello"
    interrogate_rewrite_test.go:105: link write:
        15 * * * * cronitor discover --auto /etc/crontab
        0 * * * * echo hello
    interrogate_rewrite_test.go:107: rewrite discarded; old command written:
        15 * * * * cronitor discover --auto /etc/crontab
        0 * * * * echo hello
--- FAIL: TestInterrogate_OptInRewriteDroppedWhenHostContainsCronitorLink (0.00s)
FAIL
FAIL	github.com/cronitorio/cronitor-cli/lib	0.013s
FAIL

The in-memory command is already cronitor jobs discover --auto .... The bytes Write() returns are still 15 * * * * cronitor discover --auto /etc/crontab. --ping-api-host eu.cronitor.link is a real global flag (it is in cronitor jobs --help). A crontab path under cron.daily is enough for the other trigger.

Adversary that found it: none. The fan-out seat did not return a report. Verified by running the command above twice on the PR commit.

2. A flag value of sync or discover before the subcommand writes a line cron cannot run

autoDiscoverCommand treats the first sync or discover token after jobs as the subcommand. cronitor jobs --hostname sync sync --auto --no-auto-discover=false <file> is a legal persistent-flag order (--hostname is global). The written line is cronitor jobs --hostname discover --auto sync ..., which is not jobs discover --auto.

The intent requires that opt-in line to be jobs discover --auto.

Command (same repro file, same two runs as finding 1; both failed this test the same way). Second run:

cd /tmp/arena-interrogate/candidate-1 && go test ./lib/ -count=1 -run 'TestInterrogate_HostnameValueSyncBeforeSubcommand' -v
=== RUN   TestInterrogate_HostnameValueSyncBeforeSubcommand
    interrogate_rewrite_test.go:114: hostname write:
        15 * * * * cronitor jobs --hostname discover --auto sync --no-auto-discover=false /tmp/TestInterrogate_HostnameValueSyncBeforeSubcommand2556694851/001/crontab
    interrogate_rewrite_test.go:116: flag value consumed as the subcommand:
        15 * * * * cronitor jobs --hostname discover --auto sync --no-auto-discover=false /tmp/TestInterrogate_HostnameValueSyncBeforeSubcommand2556694851/001/crontab
--- FAIL: TestInterrogate_HostnameValueSyncBeforeSubcommand (0.00s)
FAIL
FAIL	github.com/cronitorio/cronitor-cli/lib	0.013s
FAIL

That written argv does not start discover. Re-ran the built CLI twice; both exits were 1:

/tmp/arena-interrogate/cronitor jobs --hostname discover --auto sync --no-auto-discover=false --dry-run "$dir/crontab"
EXIT:1
STDERR:
Error: unknown flag: --auto
Usage:
  cronitor jobs [flags]
  cronitor jobs [command]
...
unknown flag: --auto
STDOUT:

cronitor jobs sync --hostname sync ... and cronitor --hostname sync jobs sync ... both get past flag parsing to the API-key check, so this is only the value sync or discover placed before the subcommand.

Adversary that found it: none. Verified by the two test runs and two CLI runs above.

Dropped

  • Adversary grok-4.7-xhigh-fast (bc-960641e0-1f8c-52a9-8896-955f5529e499): 0 findings. The seat stayed RUNNING with no events, no activity after creation, and no FINDINGS.md. Nothing from it was kept.
  • Command layout matches the intent, so those probes are not findings. Built /tmp/arena-interrogate/cronitor from c36328d. cronitor jobs exited 0. cronitor jobs not-a-command exited 1 with unknown command "not-a-command" for "cronitor jobs". Root sync, discover, list, shell, and dash each exited 1 with Cobra's unknown-command error. jobs discover --help, jobs sync --help, ping --help, and exec --help exited 0. Jobs/sync/discover help had no stale cronitor sync / discover / list / shell / dash usage.
  • TestInterrogate_OptInRewritesOldLine passed: a normal crontab path is written as cronitor jobs discover --auto ....
  • TestInterrogate_DefaultSyncRemovesOldDiscoverLine passed: default sync removes cronitor discover --auto and keeps echo hello.
  • TestInterrogate_UserSyncAutoJobLeftAlone passed: cronitor jobs sync --auto /tmp/mine stays.
  • docs/releases/*.md still names the old commands. The PR leaves those historical.
  • TestCompat_LogPresignAndUploadFromExec was not treated as a finding.
  • Substring deletes of -v and -i inside the generated command were not shown to be new, so they are not a finding.

FINDINGS

@cursor

cursor Bot commented Nov 12, 2026

Copy link
Copy Markdown

Follow-up to #95 (comment). The fan-out adversary returned after that comment was posted. Its three reports are the same two findings already there: cronitor.link and cron.daily are one Write() root cause, and --hostname sync before the subcommand is the other.

Re-ran its commands on the review worktree at c36328d:

cd /tmp/arena-interrogate/candidate-1 && go test -count=1 -run TestInterrogate_OptInRewriteDroppedWhenHostContainsCronitorLink ./lib/ -v

Exit 1. Write() still prints 15 * * * * cronitor discover --auto /etc/crontab while CommandToRun is cronitor jobs discover --auto ... --ping-api-host eu.cronitor.link ... and monitorable=false.

cd /tmp/arena-interrogate/candidate-1 && go test -count=1 -run TestInterrogate_OptInRewriteDroppedWhenCommandLooksMeta ./lib/ -v

Exit 1. Same discard. The path ends in cron.daily, monitorable=false, and Write() keeps cronitor discover --auto /etc/crontab.

cd /tmp/arena-interrogate/candidate-1 && go test -count=1 -run TestInterrogate_HostnameValueSyncBeforeSubcommand ./lib/ -v

Exit 1. Written line is still cronitor jobs --hostname discover --auto sync --no-auto-discover=false ....

cd /tmp/arena-interrogate/candidate-1 && go test -count=1 -run TestRepro_BrokenHostnameLineDoesNotParse ./cmd/ -v

Exit 0. The test passes by recording err=unknown flag: --auto for jobs --hostname discover --auto sync --help. That confirms finding 2. It is not a new failure.

No new verified finding. Verdict stays FINDINGS.

Write() saved the original discover --auto line when the rewritten
command looked like meta-cron or a cronitor.link host. The jobs
subcommand scan also treated a flag value of sync or discover as
the subcommand.

Co-authored-by: August Flanagan <aflanagan@users.noreply.github.com>
@cursor

cursor Bot commented Nov 12, 2026

Copy link
Copy Markdown

Dev-only checks, not committed:

  • Interrogate repros (TestInterrogate_OptInRewriteDropped, TestInterrogate_HostnameValueSyncBeforeSubcommand) pass. A cron.daily path and --ping-api-host eu.cronitor.link are written as jobs discover --auto. jobs --hostname sync sync is written as jobs --hostname sync discover --auto.
  • --verbose between jobs and sync still selects the subcommand. Removing --verbose leaves the existing double space. --hostname sync before jobs, and --hostname=sync, stay flag values. A normal path is rewritten. Default sync still drops the old line.
  • cronitor jobs --hostname sync discover --auto --no-auto-discover=false --dry-run <file> gets past flag parsing and stops at the API key check. cronitor jobs --hostname discover --auto sync ... still exits 1 with unknown flag: --auto.

@cursor

cursor Bot commented Nov 12, 2026

Copy link
Copy Markdown

VERDICT: APPROVE

Opus 5.5 Medium review of 85996ac (delta from c36328d, which I approved earlier). The delta only touches lib/crontab.go and lib/crontab_test.go. (I couldn't post this as a formal review because gh pr review returned "Resource not accessible by integration", so it's a comment instead.)

What I checked

  • Interrogate finding 1 is fixed. Write() falls back to FullLine when IsMonitorable() is false, which happens for cron.daily/run-parts paths or a cronitor.link ping host. Parse(false) now rebuilds FullLine from the cron expression, RunAs (system crontabs only), and the rewritten command, so the rewrite is kept on that path too. Monitorable lines still build their output from fields, so nothing changes for them.
  • Interrogate finding 2 is fixed. Once jobs has been seen, autoDiscoverCommand skips the value of any value-taking flag before matching sync/discover, so jobs --hostname sync sync ... now becomes jobs --hostname sync discover --auto .... The flag list matches every non-bool persistent flag in cmd/root.go and every string flag on discoverCmd. --flag=value and attached short values like -nsync correctly don't consume the next token.
  • The new test exercises both triggers (a cron.daily path and --ping-api-host eu.cronitor.link) together with the --hostname sync ordering, and checks that the old line is gone and echo hello is kept. os.Args is restored with t.Cleanup.
  • go test ./lib/ ./cmd/ -count=1 passes, and the targeted test passed 3/3 runs. The only go vet warnings are pre-existing ones in cmd/root.go, a file this PR doesn't touch.
  • Full diff: nothing blocking. The dockerfile change is just CMD ["cronitor", "jobs", "dash", "--port", "9000"], which matches the new layout. Root dash no longer exists, so the image would break without this change.

Notes

  1. (non-blocking) flagTakesValue hard-codes the flag names in lib, so the list can drift when a new string flag is added to root or sync. A comment pointing at cmd/root.go/cmd/discover.go, or a cmd-side test that walks the registered string flags and checks them against flagTakesValue, would catch that.
  2. (non-blocking) The rebuilt FullLine loses any original formatting of the old auto-discover line, such as tabs, leading env assignments, or quoting. That's fine because the command is being replaced anyway, and it matches how monitorable lines are written. Mentioning it only for completeness.
  3. (non-blocking, pre-existing) The -v/-i substring deletes in autoDiscoverCommand can still mangle paths or values that contain those characters. Out of scope here.

@aflanagan

Copy link
Copy Markdown
Contributor Author

Owner triage of the Opus 5.5 Medium notes on 85996ac (#95 (comment)). I'm skipping all three, with reasons:

  1. Hard-coded flag list in lib could drift. Skipped. It only matters on the hidden, deprecated --no-auto-discover=false path, and a cross-package drift test would be a non-critical test, which AGENTS.md says not to commit. If someone adds a new string flag, the worst case is the old misparse on that hidden path.
  2. Rebuilt line drops the original spacing. Skipped. The command is replaced anyway, so the line's whitespace doesn't matter.
  3. Plain-text -v/-i stripping. Skipped. It's pre-existing and out of scope for the namespace move; it's worth its own issue.

@cursor

cursor Bot commented Nov 12, 2026

Copy link
Copy Markdown

Interrogate (Grok 4.7 xhigh-fast)

Intent

This change puts sync, list, shell, and dash only under cronitor jobs for the Monocle major release. jobs discover is an alias of jobs sync. ping, exec, and the other root commands stay at the root. Old root names fail as unknown commands, cronitor jobs <unknown> fails the same way, and bare cronitor jobs prints help and exits 0. There is no compatibility shim.

Auto-discover stays off by default. A normal jobs sync removes a recognized discover --auto line and does not add one. The hidden opt-in --no-auto-discover=false is the only path that keeps or writes that line, and on that path the written command is jobs discover --auto (spelled discover so the existing matcher still sees it). A flag value of sync or discover stays a flag value. A user's own jobs sync --auto job is left alone. exec and ping lines are left alone. Help, docs in this repo, and the dockerfile use the new paths. Historical release notes staying on the old names is intended.

Scoped to 85996ac64cfcc1ef001a06a747ac08559da1e860.

Findings

1. A combined short flag still takes a sync value as the subcommand

cronitor jobs -vn sync sync is a legal persistent-flag order: -v is verbose, -n takes the next token as the hostname, and the second sync is the subcommand. The CLI reaches the API-key check. flagTakesValue returns false for any short cluster, so the hostname value sync is rewritten as the subcommand. The existing -v substring delete also turns -vn into n. The bytes cron would run are cronitor jobs n discover --auto sync ....

The intent requires that opt-in line to be jobs discover --auto with the hostname value sync kept.

Acceptance, ran twice, both exits 1, both stopped at the API-key check. Second run:

/tmp/arena-interrogate/cronitor jobs -vn sync sync --no-auto-discover=false --dry-run "$dir/crontab"
EXIT:1
Flag --no-auto-discover has been deprecated, the auto-discover feature has been removed

Add your API key before running sync.

Write and re-exec, review worktree at 85996ac, repro lib/interrogate_rereview_test.go (not part of the PR). Ran twice; both exits were 1 and the failure lines matched. Second run:

cd /tmp/arena-interrogate/verify && go test ./lib/ -count=1 -run 'TestInterrogate_Final$' -v
cluster-vn write: 15 * * * * cronitor jobs n discover --auto sync --no-auto-discover=false /tmp/TestInterrogate_Finalcluster2385402597/001/crontab
cluster-vn: flag value consumed as the subcommand
      15 * * * * cronitor jobs n discover --auto sync --no-auto-discover=false /tmp/TestInterrogate_Finalcluster2385402597/001/crontab
cluster-vn reexec err=exit status 1
    Error: unknown flag: --auto
    Usage:
      cronitor jobs [flags]
      cronitor jobs [command]
FAIL
FAIL	github.com/cronitorio/cronitor-cli/lib	0.043s
FAIL

Adversaries that found it: none. Verified by the two test runs and two CLI runs above.

2. A relative crontab path is spliced through jobs and --auto

autoDiscoverCommand joins the rewritten argv, then strings.Replaces crontab.Filename as a raw substring. On the opt-in path:

  • A file named job turns the subcommand jobs into <dir>/jobs. The written command is cronitor <dir>/jobs discover --auto ....
  • A file named jobs replaces the subcommand token with that file's absolute path.
  • A file named auto turns --auto into --<dir>/auto and --no-auto-discover=false into --no-<dir>/auto-discover=false.

A file named crontab is rewritten as cronitor jobs discover --auto. Re-executing the job and jobs lines fails with unknown command. Re-executing the auto line fails with unknown flag.

The intent requires the written command to be jobs discover --auto.

Same test command as finding 1, same two runs. Second run:

file-job write: 15 * * * * cronitor /tmp/TestInterrogate_Finalfilenames2035947738/001/jobs discover --auto --no-auto-discover=false /tmp/TestInterrogate_Finalfilenames2035947738/001/job
file-job: plumbing command is not cronitor jobs discover --auto
file-jobs write: 15 * * * * cronitor /tmp/TestInterrogate_Finalfilenames2035947738/002/jobs discover --auto --no-auto-discover=false /tmp/TestInterrogate_Finalfilenames2035947738/002/jobs
file-auto write: 15 * * * * cronitor jobs discover --/tmp/TestInterrogate_Finalfilenames2035947738/003/auto --no-/tmp/TestInterrogate_Finalfilenames2035947738/003/auto-discover=false /tmp/TestInterrogate_Finalfilenames2035947738/003/auto
file-job reexec err=exit status 1
    Error: unknown command "/tmp/TestInterrogate_Finalfilenames2035947738/001/jobs" for "cronitor"
file-jobs reexec err=exit status 1
    Error: unknown command "/tmp/TestInterrogate_Finalfilenames2035947738/002/jobs" for "cronitor"
file-auto reexec err=exit status 1
    Error: unknown flag: --/tmp/TestInterrogate_Finalfilenames2035947738/003/auto

Adversaries that found it: none. Verified by those two test runs.

Dropped

  • Adversary grok-4.7-xhigh-fast (bc-a480a6e5-7eb6-535d-8493-7f82c7afdb0c): 0 findings. No FINDINGS.md and no new files in its worktree.
  • Adversary grok-4.7-xhigh-fast (bc-451b20e3-24e4-5619-aac2-4d982091758c): 0 findings. No FINDINGS.md and no new files in its worktree. The user named one model; both seats ran on it after the previous single seat returned nothing.
  • The two bugs from the previous comment are fixed at this commit. TestInterrogate_PriorMetaAndLinkRewrites and TestInterrogate_PriorHostnameValue passed. A cron.daily path and --ping-api-host eu.cronitor.link are written as cronitor jobs discover --auto .... cronitor jobs --hostname sync sync is written as cronitor jobs --hostname sync discover --auto.
  • Separate -v -n sync is written as cronitor jobs -n sync discover --auto. Verbose is removed. The hostname value stays.
  • --api-version is still rewritten to --apiersion by the pre-existing -v substring delete. The new scan keeps a value of sync. Same class dropped last round.
  • www-data is kept on a system-style line (id -u www-data is 33). deploy is omitted (id -u deploy fails, so RunAs stays empty). The written command is still cronitor jobs discover --auto.
  • Default sync removes cronitor discover --auto and keeps echo hello. A user's cronitor jobs sync --auto line is left alone. cronitor exec and cronitor ping lines are left alone.
  • Layout matches the intent. cronitor jobs exits 0. cronitor jobs not-a-command exits 1 with unknown command. Root sync, discover, list, shell, and dash each exit 1 with an unknown-command error. jobs discover --help, jobs sync --help, ping --help, and exec --help exit 0.
  • cd web && npm ci && npm run build succeeded. go build ./... and go test ./... succeeded. TestCompat_LogPresignAndUploadFromExec did not fail.
  • docs/releases/*.md still names the old commands. The PR leaves those historical.

FINDINGS

@cursor

cursor Bot commented Nov 12, 2026

Copy link
Copy Markdown

Interrogate (Grok 4.7 xhigh-fast)

This replaces #95 (comment). Adversary bc-451b20e3-24e4-5619-aac2-4d982091758c finished after that comment was posted and was counted there as empty.

Intent

This change puts sync, list, shell, and dash only under cronitor jobs for the Monocle major release. jobs discover is an alias of jobs sync. ping, exec, and the other root commands stay at the root. Old root names fail as unknown commands, cronitor jobs <unknown> fails the same way, and bare cronitor jobs prints help and exits 0. There is no compatibility shim.

Auto-discover stays off by default. A normal jobs sync removes a recognized discover --auto line and does not add one. The hidden opt-in --no-auto-discover=false is the only path that keeps or writes that line, and on that path the written command is jobs discover --auto (spelled discover so the existing matcher still sees it). A flag value of sync or discover stays a flag value. A user's own jobs sync --auto job is left alone. exec and ping lines are left alone. Help, docs in this repo, and the dockerfile use the new paths. Historical release notes staying on the old names is intended.

Scoped to 85996ac64cfcc1ef001a06a747ac08559da1e860.

Findings

1. A combined short flag still takes a sync value as the subcommand

cronitor jobs -vn sync sync is a legal persistent-flag order: -v is verbose, -n takes the next token as the hostname, and the second sync is the subcommand. The CLI reaches the API-key check. flagTakesValue returns false for any short cluster, so the hostname value sync is rewritten as the subcommand. The existing -v substring delete also turns -vn into n. The bytes cron would run are cronitor jobs n discover --auto sync ....

The intent requires that opt-in line to be jobs discover --auto with the hostname value sync kept.

Acceptance, ran twice, both exits 1, both stopped at the API-key check. Second run:

/tmp/arena-interrogate/cronitor jobs -vn sync sync --no-auto-discover=false --dry-run "$dir/crontab"
EXIT:1
Flag --no-auto-discover has been deprecated, the auto-discover feature has been removed

Add your API key before running sync.

Write and re-exec, review worktree at 85996ac, repro lib/interrogate_rereview_test.go (not part of the PR). Ran twice; both exits were 1 and the failure lines matched. Second run:

cd /tmp/arena-interrogate/verify && go test ./lib/ -count=1 -run 'TestInterrogate_Final$' -v
cluster-vn write: 15 * * * * cronitor jobs n discover --auto sync --no-auto-discover=false /tmp/TestInterrogate_Finalcluster2385402597/001/crontab
cluster-vn: flag value consumed as the subcommand
      15 * * * * cronitor jobs n discover --auto sync --no-auto-discover=false /tmp/TestInterrogate_Finalcluster2385402597/001/crontab
cluster-vn reexec err=exit status 1
    Error: unknown flag: --auto
    Usage:
      cronitor jobs [flags]
      cronitor jobs [command]
FAIL
FAIL	github.com/cronitorio/cronitor-cli/lib	0.043s
FAIL

Adversary that found it: grok-4.7-xhigh-fast (bc-451b20e3-24e4-5619-aac2-4d982091758c). Also verified by the two test runs and two CLI runs above.

2. A relative crontab path is spliced through jobs and --auto

autoDiscoverCommand joins the rewritten argv, then strings.Replaces crontab.Filename as a raw substring. On the opt-in path:

  • A file named job turns the subcommand jobs into <dir>/jobs. The written command is cronitor <dir>/jobs discover --auto ....
  • A file named jobs replaces the subcommand token with that file's absolute path.
  • A file named auto turns --auto into --<dir>/auto and --no-auto-discover=false into --no-<dir>/auto-discover=false. Master b5e7bac re-inserts discover --auto after the filename replace, so this --auto destruction is new. The corrupted line no longer matches IsAutoDiscoverCommand, and the next opt-in parse appends a second copy.

A file named crontab is rewritten as cronitor jobs discover --auto. Re-executing the job and jobs lines fails with unknown command. Re-executing the auto line fails with unknown flag.

The intent requires the written command to be jobs discover --auto, once.

Same test command as finding 1, same two runs. Second run:

file-job write: 15 * * * * cronitor /tmp/TestInterrogate_Finalfilenames2035947738/001/jobs discover --auto --no-auto-discover=false /tmp/TestInterrogate_Finalfilenames2035947738/001/job
file-job: plumbing command is not cronitor jobs discover --auto
file-jobs write: 15 * * * * cronitor /tmp/TestInterrogate_Finalfilenames2035947738/002/jobs discover --auto --no-auto-discover=false /tmp/TestInterrogate_Finalfilenames2035947738/002/jobs
file-auto write: 15 * * * * cronitor jobs discover --/tmp/TestInterrogate_Finalfilenames2035947738/003/auto --no-/tmp/TestInterrogate_Finalfilenames2035947738/003/auto-discover=false /tmp/TestInterrogate_Finalfilenames2035947738/003/auto
file-job reexec err=exit status 1
    Error: unknown command "/tmp/TestInterrogate_Finalfilenames2035947738/001/jobs" for "cronitor"
file-jobs reexec err=exit status 1
    Error: unknown command "/tmp/TestInterrogate_Finalfilenames2035947738/002/jobs" for "cronitor"
file-auto reexec err=exit status 1
    Error: unknown flag: --/tmp/TestInterrogate_Finalfilenames2035947738/003/auto

Second opt-in parse of the auto file, adversary repro lib/interrogate_repro_test.go in /tmp/arena-interrogate/candidate-2. Ran twice; both second writes contained two copies. Second run:

cd /tmp/arena-interrogate/candidate-2 && go test ./lib/ -count=1 -run 'TestInterrogate_RelativeAutoName$' -v
FIRST WRITE:
    15 * * * * cronitor jobs discover --/tmp/TestInterrogate_RelativeAutoName1301370695/001/auto --no-/tmp/TestInterrogate_RelativeAutoName1301370695/001/auto-discover=false /tmp/TestInterrogate_RelativeAutoName1301370695/001/auto
    0 * * * * echo hello
SECOND WRITE:
    15 * * * * cronitor jobs discover --/tmp/TestInterrogate_RelativeAutoName1301370695/001/auto --no-/tmp/TestInterrogate_RelativeAutoName1301370695/001/auto-discover=false /tmp/TestInterrogate_RelativeAutoName1301370695/001/auto
    0 * * * * echo hello

    15 * * * * cronitor jobs discover --/tmp/TestInterrogate_RelativeAutoName1301370695/001/auto --no-/tmp/TestInterrogate_RelativeAutoName1301370695/001/auto-discover=false /tmp/TestInterrogate_RelativeAutoName1301370695/001/auto

Adversary that found it: grok-4.7-xhigh-fast (bc-451b20e3-24e4-5619-aac2-4d982091758c), for the auto filename and the second copy. The job / jobs filenames were verified in the two TestInterrogate_Final runs above.

3. The opt-in rewrite drops a system-crontab user when id does not resolve it

On a system crontab the sixth field is the user. The new rewrite keeps that field only when id -u succeeds. When it does not, the user word is still the first word of the old command, and replacing the command deletes it. The saved sixth field is cronitor. Cron then runs jobs ..., and /bin/sh is dash, where jobs is a shell builtin.

Master b5e7bac does not rewrite an existing auto line, so the user stays. Second run:

cd /tmp/arena-interrogate/master && go test ./lib/ -count=1 -run 'TestMaster_SystemUser$' -v
EXISTING UNKNOWN USER:
    15 * * * * batchjob cronitor discover --auto /etc/crontab
    0 * * * * www-data echo hello
EXISTING ROOT:
    15 * * * * root cronitor discover --auto /etc/crontab

HEAD, same inputs, second run. batchjob is not a user (id -u batchjob exits 1). root is dropped when PATH has no id. With id on PATH, root is kept:

cd /tmp/arena-interrogate/candidate-2 && go test ./lib/ -count=1 -run 'TestInterrogate_SystemUserMonitorableAndNoID$' -v
MONITORABLE UNKNOWN USER:
    15 * * * * cronitor jobs discover --auto --no-auto-discover=false --ping-api-host eu.cronitor.link /tmp/TestInterrogate_SystemUserMonitorableAndNoID1090808572/001/crontab
    0 * * * * echo hello
ROOT WITH ID HIDDEN:
    15 * * * * cronitor jobs discover --auto --no-auto-discover=false /tmp/TestInterrogate_SystemUserMonitorableAndNoID1090808572/001/root-tab
    0 * * * * echo hello
ROOT WITH ID PRESENT:
    15 * * * * root cronitor jobs discover --auto --no-auto-discover=false /tmp/TestInterrogate_SystemUserMonitorableAndNoID1090808572/001/root-tab
    0 * * * * echo hello

The command field of the dropped-user line, ran twice. Both exits were 2 and the text matched. Second run:

/bin/sh -c 'jobs discover --auto --no-auto-discover=false /tmp/vn-tab'
/bin/sh: 1: jobs: No such job: discover
EXIT:2

/bin/sh is dash. id -u cronitor exits 1, so cron also has no such user to run that line as.

A line appended because the file has no auto line yet has the same shape. createAutoDiscoverLine never writes a user field. Second run of TestInterrogate_SystemUser:

52 * * * * cronitor jobs discover --auto --no-auto-discover=false --ping-api-host eu.cronitor.link /tmp/TestInterrogate_SystemUser636819265/001/cron.hourly
AUTO FIELDS: ["52", "*", "*", "*", "*", "cronitor", "jobs", "discover", "--auto", ...]

Master's appended line is cronitor discover --auto ... with no user field either. This commit is what places jobs in the command field.

The intent requires the opt-in line to run cronitor jobs discover --auto. Required for the existing root line: 15 * * * * root cronitor jobs discover --auto ....

Adversary that found it: grok-4.7-xhigh-fast (bc-451b20e3-24e4-5619-aac2-4d982091758c).

Dropped

  • Adversary grok-4.7-xhigh-fast (bc-a480a6e5-7eb6-535d-8493-7f82c7afdb0c): 0 findings. No FINDINGS.md and no new files in its worktree.
  • Adversary grok-4.7-xhigh-fast (bc-451b20e3-24e4-5619-aac2-4d982091758c): 2 dropped, 3 merged above.
    • -v / -i substring deletes (--api-version to --apiersion, --verbose=true to =true, web-internal to webnternal, backup-v2 to backup2). Master b5e7bac already writes that on a new auto line: cronitor discover --auto --apiersion 2025-11-28 =true --hostname webnternal ... backup2. Same class dropped on the previous round. Not a new failure.
    • --exclude-from-name '> /dev/null' is written unquoted, and a shell redirect eats --no-auto-discover=false. Master already writes cronitor discover --auto --exclude-from-name > /dev/null --no-auto-discover=false .... Not a new failure.
    • A relative file named cron rewrites cronitor and eu.cronitor.link. Master already writes /tmp/.../cronitor discover --auto and eu./tmp/.../cronitor.link. That example was not added. The new job, jobs, and auto collisions are finding 2.
  • The two bugs from the previous comment are fixed at this commit. TestInterrogate_PriorMetaAndLinkRewrites and TestInterrogate_PriorHostnameValue passed. A cron.daily path and --ping-api-host eu.cronitor.link are written as cronitor jobs discover --auto .... cronitor jobs --hostname sync sync is written as cronitor jobs --hostname sync discover --auto.
  • Separate -v -n sync is written as cronitor jobs -n sync discover --auto. Verbose is removed. The hostname value stays. root and www-data stay when id -u succeeds.
  • Default sync removes cronitor discover --auto and keeps echo hello. A user's cronitor jobs sync --auto line is left alone. cronitor exec and cronitor ping lines are left alone.
  • Layout matches the intent. cronitor jobs exits 0. cronitor jobs not-a-command exits 1 with unknown command. Root sync, discover, list, shell, and dash each exit 1 with an unknown-command error. jobs discover --help, jobs sync --help, ping --help, and exec --help exit 0.
  • cd web && npm ci && npm run build succeeded. go build ./... and go test ./... succeeded. TestCompat_LogPresignAndUploadFromExec did not fail.
  • docs/releases/*.md still names the old commands. The PR leaves those historical.

FINDINGS

@cursor

cursor Bot commented Nov 12, 2026

Copy link
Copy Markdown

Addendum to #95 (comment). Adversary bc-a480a6e5-7eb6-535d-8493-7f82c7afdb0c returned after that comment and was counted there as empty. No change to the verdict. Scoped to 85996ac.

Its five reports:

  • -vn web1 and -vk <key> after the subcommand become n web1 and k <key>. Master b5e7bac already writes cronitor discover --auto n web1 and cronitor discover --auto k 0123456789abcdef. Same -v deletion already under Dropped.
  • --api-version / my-instance / staging-internal are the same -v and -i deletions, already dropped.
  • jobs -vn sync sync and jobs -ve discover sync are finding 1. Separate -v -n sync still stays jobs -n sync discover --auto.
  • Files named jobs and auto are finding 2. Files named sync and discover already do this on master: --hostname /tmp/.../sync, and cronitor /tmp/.../discover --no-auto-/tmp/.../discover=false.
  • User app dropped while www-data is kept is finding 3. The commented root line stays commented and keeps root.

FINDINGS

The hidden --no-auto-discover=false path was scanning the old line's tokens.
Short clusters, flag values named sync, and a crontab path named job, jobs,
or auto each broke that scan. Remove the recognized line and emit one
shell-quoted jobs discover --auto line from the resolved path and flags
this sync already parsed.

Co-authored-by: August Flanagan <aflanagan@users.noreply.github.com>
@cursor

cursor Bot commented Nov 12, 2026

Copy link
Copy Markdown

VERDICT: REQUEST CHANGES

Opus 5.5 Medium review of f436533 (delta from 85996ac, plus a pass over the full diff from b5e7bac).

Dropping the argv token rewrite fixes both bugs from the earlier interrogate round. Flags now come from parsed values, not argv positions, so --hostname sync, -vn sync, and relative files named job, jobs, or auto can no longer corrupt the subcommand. The new line is quoted with shellquote, and a path containing a space comes out as '.../my tab'. The line is idempotent: a second opt-in parse wrote byte-identical output in every case I tried. The first legacy line's schedule is kept, including six-field schedules, and later duplicates are dropped. --file, --dry-run, and --with-monitored are correctly left out of the carried-over flags. go test ./lib/ ./cmd/ passes. Two problems remain on the opt-in path.

I tested with a scratch test that I did not commit. It calls Parse(false, "--no-auto-discover=false") on a system (non-user) crontab as root, then calls Write(), then parses and writes a second time.

Blocking

  1. The opt-in path turns a commented-out auto line back on. Input:

    #15 * * * * root cronitor discover --auto /etc/crontab
    

    Output:

    15 * * * * root <bin> jobs discover --auto --no-auto-discover=false '<path>'
    

    Parse turns a commented cron line into a Line with IsComment=true. That line matches IsAutoDiscoverCommand, and the new branch drops it and emits a fresh, uncommented line. createAutoDiscoverLine never carries IsComment over. Both b5e7bac and 85996ac kept this line commented. A job the user had disabled now runs as root every hour. Fix: when the first matched line is a comment, keep IsComment on the emitted line (or keep the commented line as it is), and add this input to TestOptInAutoDiscoverLine.

  2. Interrogate finding 3 is still open: the run-as user is dropped when id -u cannot resolve it. Input:

    15 * * * * batchjob cronitor discover --auto /etc/crontab
    

    Output:

    15 * * * * <bin> jobs discover --auto ...
    

    keptRunAs is filled only from line.RunAs, which is empty when id -u batchjob fails, or when id is not on PATH. In that case the user word is still the first word of CommandToRun, and the fresh line throws it away. Cron then reads the binary path (cronitor, or os.Args[0]) as the user field and jobs as the command. Master keeps the user here, because it never rewrites an existing auto line. With a resolvable user (root) the user is kept. Fix: when RunAs is empty on a system crontab, take the words before the cronitor/discover token in CommandToRun as the run-as field.

Non-blocking

  1. An appended auto line in a system crontab still has no user field. It is written as N * * * * <bin> jobs discover --auto ... '<path>', so cron reads <bin> as the user. Master has the same flaw with cronitor discover --auto, so this is not a regression. Writing root (or the current user) when !IsUserCrontab would fix it.
  2. % is not escaped. shellquote.Join does not escape %, and cron treats an unescaped % as a newline even inside quotes. --exclude-from-name 'date +%Y' is written as is and cuts the command off. This existed before the PR.
  3. A wrapped legacy line loses its monitor key. cronitor exec abc123 cronitor discover --auto ... matches and is replaced by a bare line, so the exec abc123 wrapper and its key are gone. Edge case.
  4. A # Name: (or # cronitor: ignore) comment above the auto line is lost. The fresh line has no Name or Ignored. Minor.
  5. Dockerfile CMD (cronitor jobs dash --port 9000) matches jobsCmd.AddCommand(dashCmd) and its --port flag. Root dash has no forwarder, so any docker run ... cronitor dash override will exit 1. That is the intended break, but call it out in the release notes.

@cursor

cursor Bot commented Nov 12, 2026

Copy link
Copy Markdown

Interrogate (Grok 4.7 xhigh-fast)

Intent

At f436533 this branch moves sync, list, shell, and dash under cronitor jobs with no root alias. jobs discover is jobs sync. ping and exec stay at the root. A normal jobs sync removes a recognized discover --auto line and does not add one. The hidden --no-auto-discover=false path drops that line and writes one fresh shell-quoted jobs discover --auto line from the flags this run parsed and the resolved crontab path, keeping the old schedule and run-as user.

Findings

Bare % in the opt-in line is left for cron to cut

autoDiscoverCommand joins the binary, flags, and path with shellquote.Join. That quotes for the shell and does not emit \%. Cron ends the command at the first unescaped % and sends the rest as stdin (lib/crontab_wrap.go splitCronStdin documents the same rule). A path or a carried flag value containing % is written through, so the crontab path after the % never reaches the next run.

Command (written twice, file identical both times):

/tmp/arena-interrogate/cronitor jobs sync --auto --no-auto-discover=false /tmp/repro-cron.daily-100%/crontab

Output, file after both writes (cat -A):

15 * * * * /tmp/arena-interrogate/cronitor jobs discover --auto --no-auto-discover=false /tmp/repro-cron.daily-100%/crontab$

Cron's command is then /tmp/.../cronitor jobs discover --auto --no-auto-discover=false /tmp/repro-100 with stdin done/crontab. Running that argv twice:

/tmp/repro-100 does not exist
EXIT:1

Same cut for a flag value. Dry-run twice:

/tmp/arena-interrogate/cronitor jobs sync --auto --dry-run --no-auto-discover=false --exclude-from-name '100%' /tmp/tmp.KPtboz7cgn
15 * * * * /tmp/arena-interrogate/cronitor jobs discover --auto --no-auto-discover=false --exclude-from-name 100% /tmp/tmp.KPtboz7cgn

The shell words of the command up to the % are --exclude-from-name 100. The crontab path is stdin, not an argument.

Intent requires one crontab command whose shell arguments are jobs discover --auto plus the full path /tmp/repro-cron.daily-100%/crontab (a % in a crontab command has to be written as \%, which this repo already does for cronitor exec lines).

A newline in a carried flag splits the record, and every later sync appends another tail

--exclude-from-name $'foo\nbar' is wrapped in single quotes. Cron splits records on newline before the shell sees those quotes. The tail is not part of the discover line, so the next sync keeps it and writes the broken line again.

Command, run four times against /tmp/repro-cron.daily-nl/crontab:

/tmp/arena-interrogate/cronitor jobs sync --auto --no-auto-discover=false --exclude-from-name $'foo\nbar' /tmp/repro-cron.daily-nl/crontab

File after the 4th write (cat -A), exit 0 each time:

15 * * * * /tmp/arena-interrogate/cronitor jobs discover --auto --no-auto-discover=false --exclude-from-name 'foo$
bar' /tmp/repro-cron.daily-nl/crontab$
bar' /tmp/repro-cron.daily-nl/crontab$
bar' /tmp/repro-cron.daily-nl/crontab$
bar' /tmp/repro-cron.daily-nl/crontab$

After write 1 the file is the first two physical lines. Writes 2, 3, and 4 each add one more bar' ... line.

Intent requires one physical crontab line, stable across a second sync.

--format exec is written ahead of later flags, and that line does not parse on the next run

main.go (unchanged on this branch) treats the first argv token exec as the exec command and, when at least three tokens follow it, inserts -- two slots later. An invocation that puts --format exec last still parses. autoDiscoverFlagArgs then emits --format before --exclude-from-name and the path, which is the order that trips the injector.

Command (dry-run, twice, exit 0 both times):

/tmp/arena-interrogate/cronitor jobs sync --auto --dry-run --no-auto-discover=false --exclude-from-name foo --format exec /tmp/tmp.KPtboz7cgn

Written command:

15 * * * * /tmp/arena-interrogate/cronitor jobs discover --auto --no-auto-discover=false --format exec --exclude-from-name foo /tmp/tmp.KPtboz7cgn

Re-running that command twice (schedule stripped, same binary):

foo does not exist
EXIT:1

Intent requires the next run to open /tmp/tmp.KPtboz7cgn again, with exclude text foo.

Dropped

  • The four earlier bugs stay fixed. Re-ran twice here and twice in a second worktree. Dry-run lines:
    • cron.daily path and --ping-api-host eu.cronitor.link: jobs discover --auto --no-auto-discover=false --ping-api-host eu.cronitor.link <abs>/cron.daily
    • jobs --hostname sync sync: --hostname sync, subcommand stays jobs discover --auto
    • jobs -vn sync sync: --hostname sync --verbose
    • relative crontab named jobs: path argument is the absolute .../jobs path, not spliced into the subcommand
  • Spaces and apostrophes in the crontab path and in argv[0] round-trip as one shell word. Re-exec of those lines reaches sync.
  • Schedule is kept for 13 14 * * 2, @daily, and a 6-field expression. A 5-field discover line stays 5-field when the file also has a 6-field job. Run-as root and www-data are kept on the system line.
  • A user's cronitor jobs sync --auto line, a cronitor exec line, and a cronitor.io/ping line are left in place. One discover line is emitted. Default jobs sync (no --no-auto-discover=false) removes the discover line and does not add one.
  • An API key set only in the environment is not copied onto the line. --dry-run and --with-monitored are not copied. --silent is copied on a real write.
  • A normal opt-in line is idempotent across three real syncs (mock API): same schedule, root, monitor code, user jobs sync line, exec line, and ping line.
  • --format exec with nothing after the path does not hit the main.go injector. An invocation that already has three tokens after exec fails in main.go before this writer runs; that entrypoint behavior predates the branch (main.go is not in the diff) and is not a second finding.
  • cd web && npm ci && npm run build succeeded. go test ./... then passed (cmd and lib). TestCompat_LogPresignAndUploadFromExec did not flake on that run.

FINDINGS

Auto-discover has been off since 2020, and rewriting that legacy line
kept breaking. jobs sync still drops an active discover --auto line,
leaves a commented-out one unchanged, and says so once on stderr.

Co-authored-by: August Flanagan <aflanagan@users.noreply.github.com>
@cursor

cursor Bot commented Nov 12, 2026

Copy link
Copy Markdown

Addendum to #95 (comment)

Interrogate flags and sync reported more cases after that comment. Re-ran each one twice on the f436533 binary. Two are new failures. The name and ignore leak is the same behavior master already has.

Findings

--hostname #prod is written bare, so the shell comments out the rest of the line

shellquote.Join does not quote #. Cron hands the command to the shell, and # starts a comment there, so the hostname value and the crontab path are dropped.

Command (dry-run, twice, exit 0 both times):

/tmp/arena-interrogate/cronitor jobs sync --auto --dry-run --no-auto-discover=false --hostname '#prod' /tmp/repro-followup/hash

Written command, both times:

15 * * * * /tmp/arena-interrogate/cronitor jobs discover --auto --no-auto-discover=false --hostname #prod /tmp/repro-followup/hash

That command under sh -c, twice:

Error: flag needs an argument: --hostname
flag needs an argument: --hostname
EXIT:1

Intent requires the next run to receive hostname #prod and open /tmp/repro-followup/hash.

A relative argv0 is copied onto the line, and cron cannot run it from $HOME

The line uses os.Args[0]. Invoking the binary as ./cronitor writes that relative token. Cron runs the command with the working directory set to the user's home.

Command, from /tmp/repro-followup, twice, exit 0 both times:

./cronitor jobs sync --auto --dry-run --no-auto-discover=false relbin

Written command, both times:

15 * * * * ./cronitor jobs discover --auto --no-auto-discover=false /tmp/repro-followup/relbin

The same command from /home/ubuntu, twice:

sh: 1: ./cronitor: not found
EXIT:127

An absolute invocation of the same binary writes /tmp/repro-followup/cronitor, which does not depend on the working directory. Intent requires the program token on the line to be one cron can execute from /home/ubuntu.

Dropped

  • A # Name: comment or # cronitor: ignore directly above a removed discover --auto line is left attached to the next job. Re-ran twice: default jobs sync --auto --dry-run prints # Name: Nightly discover above 0 0 * * * echo backup, and the ignore marker above the same backup line. Master already continues out of that line before it clears name and ignored, so this is not a regression in f436533.

FINDINGS

@cursor

cursor Bot commented Nov 12, 2026

Copy link
Copy Markdown

VERDICT: REQUEST CHANGES

Opus 5.5 Medium review of 760790e (delta from f436533, plus a pass over the full diff from master).

Both blocking items from my last review are fixed, because the commit no longer writes an auto-discover line at all:

  • Commented line re-enabled: fixed. A commented-out #15 * * * * root cronitor discover --auto ... line is now written back byte for byte (verbatim), including a leading space and a # Name: comment above it. It is never re-activated.
  • Run-as user dropped: fixed. No line is rewritten, so the run-as user can no longer be lost. Other lines keep their schedule and user (0 1 * * * root echo hello round-trips in TestLegacyAutoDiscoverLine).

Last round's non-blocking items 3, 4, and 6 no longer apply. The Dockerfile CMD (cronitor jobs dash --port 9000) matches the command tree, and the PR description has the release-notes line saying a Docker CMD override of cronitor dash must become cronitor jobs dash. go build ./... and go test ./lib/ ./cmd/ pass.

The remaining problem is the one you asked me to check: the recognizer can remove user lines it shouldn't. I tested with a scratch test that calls Parse(true) and Write(). I did not commit it.

Blocking

  1. IsAutoDiscoverCommand deletes unrelated user jobs. The regex is .+discover[[:space:]]+--auto.*, matched against the lowercased command with no word boundaries. It does not require a cronitor binary. All of these active lines are deleted, and sync prints "Removed the old auto-discover line":

    0 * * * * /opt/acme/bin/discover --auto-scale
    0 * * * * ./rediscover --automatic --x
    0 * * * * echo 'run discover --auto later' >> /tmp/log
    

    Master uses the same regex, and its default (noAutoDiscover = true) already deletes these lines, so the bug itself is old. Two things in this commit make it blocking now. First, the commit removes the only opt-out, the hidden --no-auto-discover=false flag, so deletion is now unconditional. Second, the commit's stated contract is "remove only a recognized legacy line". In --auto pipelines a user's job disappears with only a stderr line. Fix: match only the shape that was actually installed. After an optional run-as user and an optional cronitor exec <key> wrapper, require a word whose basename is cronitor, then discover (optionally preceded by jobs), then a whole-word --auto. Add the three inputs above to TestLegacyAutoDiscoverLine as lines that must be kept.

  2. A # Name: or # cronitor: ignore comment above the removed line moves to the next job. The active-removal branch runs continue without resetting name and ignored. Input:

    # cronitor: ignore
    15 * * * * cronitor discover --auto /etc/crontab
    0 1 * * * echo next
    

    echo next is parsed with Ignored=true, so sync silently stops monitoring a real job. With # Name: Legacy auto, the next job is written and synced under that name. This is also old behavior on master, but it hits exactly the users this migration targets. Fix: reset name and ignored before the continue, the way the commented branch already does. Also drop the orphaned # Name: or ignore comment, so it is not written above the next job.

Non-blocking

  1. A wrapped legacy line loses its monitor. cronitor exec abc123 cronitor discover --auto /etc/crontab is removed. That is probably intended, but monitor abc123 stays in Cronitor with nothing pinging it. Consider naming the key in the stderr notice.
  2. The stderr notice is generic. It does not say which crontab or line was removed. When sync scans several crontabs, printing the filename and the removed line makes a false positive visible and recoverable.
  3. The dashboard's save paths also delete matched lines silently. cmd/dash.go calls Parse(true) and prints no notice. This is the same as master, and fixing item 1 covers it.
  4. The noAutoDiscover parameter is now always true. Every caller passes true. Drop the parameter, or document that false means "keep the line as is".

@cursor

cursor Bot commented Nov 12, 2026

Copy link
Copy Markdown

Interrogate (Grok 4.7 xhigh-fast)

Scoped to 760790e. Two adversaries, both Grok 4.7 xhigh-fast, each in its own worktree. Every finding below was re-run here; the second run matched the first.

Intent

sync, list, shell, and dash live only under cronitor jobs. discover is an alias of jobs sync. Bare cronitor jobs prints help and exits 0. An unknown jobs subcommand fails. ping, exec, and the other root commands stay at the root.

The hidden --no-auto-discover opt-in is gone on purpose, and sync no longer rewrites or installs a replacement auto-discover line. jobs sync deletes an active crontab line only when that line is the old Cronitor auto-discover plumbing (cronitor discover --auto ..., including the argv0 form the old writer emitted). It prints one stderr notice when it does. A commented-out legacy line stays byte-for-byte, including the leading #. Every other line stays, including its schedule, run-as user, and command. A user job that merely contains discover or --auto stays. # Name: and # cronitor: ignore that belonged to a removed plumbing line are not rewritten onto the next job.

Findings

1. jobs sync deletes user jobs that only resemble discover --auto

IsAutoDiscoverCommand matches .+discover[[:space:]]+--auto against the lowercased command. That hits a user command that mentions those words, a binary whose name ends in discover, and a longer flag such as --auto-prune. Both adversaries found this.

Command (real binary built from this commit, real /usr/bin/id, no cronitor passwd entry), run twice:

d=$(mktemp -d)
printf '%s\n' '0 3 * * * echo discover --auto' > "$d/c"
env -i PATH="/usr/bin:/bin" HOME="$HOME" CRONITOR_API_KEY=1234567890 \
  /tmp/arena-interrogate/candidate-1/repro/cronitor \
  --config /tmp/arena-interrogate/candidate-1/repro/empty.json \
  jobs sync --auto "$d/c"

Both runs: exit 0. Stdout was a single newline. Stderr:

Removed the old auto-discover line. Auto-discover is no longer supported.

The crontab file was 0 bytes.

Intent requires stdout and the file to still contain 0 3 * * * echo discover --auto, and stderr to stay empty.

Same matcher, go test re-run twice with identical normalized output (exit 1 both times):

cd /tmp/arena-interrogate/candidate-2 && go test -count=1 -timeout 120s -run 'TestInterrogateLegacyRecognizer' -v ./lib/
--- FAIL: TestInterrogateLegacyRecognizer/user_echo_discover_--auto_must_stay (0.00s)
    repro_interrogate_test.go:117: removed=true want false
        got:
        "# keep-this-byte-for-byte\n"
        want:
        "0 4 * * * echo discover --auto please\n# keep-this-byte-for-byte\n"
--- FAIL: TestInterrogateLegacyRecognizer/user_rediscover_--auto_with_run-as_must_stay (0.00s)
    repro_interrogate_test.go:117: removed=true want false
        got:
        ""
        want:
        "0 4 * * * ubuntu /opt/backup/rediscover --auto /var/data\n"

jobs sync itself, re-run twice (exit 1 both times; temp paths differed, failure text matched):

cd /tmp/arena-interrogate/candidate-2/cmd && PATH="/tmp/arena-interrogate/candidate-2/repro/bin:$PATH" id -u cronitor && go test -count=1 -timeout 180s -run 'TestInterrogateJobsSync' -v .
=== RUN   TestInterrogateJobsSync/user_discover_--auto-prune
    repro_interrogate_test.go:57: exit=0
        stderr="Removed the old auto-discover line. Auto-discover is no longer supported.\n"
        stdout="\n"
        disk=""
    repro_interrogate_test.go:59: user job was treated as auto-discover plumbing

Input for that subtest was 0 4 * * * echo discover --auto-prune /var/cache. Intent requires that line to remain and stderr to stay empty.

Adversaries: both.

2. Removing a plumbing line writes its # Name: and # cronitor: ignore onto the next job

The active-line removal continues without clearing name and ignored. The next line inherits both, and writeUsing emits the ignore comment, then the name. Both adversaries found this.

Command, run twice (same input, same output, exit 0 both times):

d=$(mktemp -d)
printf '%s\n' \
  '# Name: Auto discover' \
  '# cronitor: ignore' \
  '15 * * * * /usr/local/bin/cronitor discover --auto /etc/crontab' \
  '0 1 * * * root echo hello' > "$d/c"
env -i PATH="/usr/bin:/bin" HOME="$HOME" CRONITOR_API_KEY=1234567890 \
  /tmp/arena-interrogate/candidate-1/repro/cronitor \
  --config /tmp/arena-interrogate/candidate-1/repro/empty.json \
  jobs sync --auto "$d/c"

Stderr, once:

Removed the old auto-discover line. Auto-discover is no longer supported.

Stdout and the file, both runs:

# cronitor: ignore
# Name: Auto discover
0 1 * * * root echo hello

Intent requires the plumbing line to be gone, the notice once, and the neighbor to remain:

0 1 * * * root echo hello

The schedule and run-as user on that neighbor survived. The two comments that belonged to the removed line were rewritten above it, in swapped order.

The same bytes come from Parse/Write with no API. Both runs of TestInterrogateLegacyRecognizer/name_and_ignore_must_not_move_onto_the_next_line printed:

got:
"# cronitor: ignore\n# Name: Auto discover\n0 1 * * * ubuntu /usr/local/bin/echo hello-from-user\n"
want:
"0 1 * * * ubuntu /usr/local/bin/echo hello-from-user\n"

Adversaries: both.

3. A passwd entry named cronitor hides the bare cronitor discover --auto line, and a commented copy is rewritten

File crontabs (and root's user crontab) treat the first command token as a run-as user when id -u succeeds. The old writer joined os.Args, so a normal invocation installed cronitor discover --auto .... After cronitor is stripped, the command is discover --auto .... The recognizer requires a character before discover, so the line is left active. A commented-out copy misses the verbatim path and is rewritten with a space after #. Both adversaries found this. It is conditional: with no such passwd entry, the same active line is removed and the same commented line is kept.

Precondition, then removed afterward (id -u cronitor is now absent):

sudo -n useradd --badname -M -s /usr/sbin/nologin cronitor
id -u cronitor
1001
cronitor:x:1001:1001::/home/cronitor:/usr/sbin/nologin

Command, run twice while that account existed. Output was identical (exit 1):

cd /agent/repos/cronitor-cli && go test -count=1 -timeout 60s -run TestLegacyAutoDiscoverLine ./lib/
--- FAIL: TestLegacyAutoDiscoverLine (0.00s)
    crontab_wrap_test.go:394: got:
        15 * * * * cronitor discover --auto /etc/crontab
         #15 * * * * batchjob cronitor discover --auto /etc/crontab
        0 1 * * * root echo hello

        want:
         #15 * * * * batchjob cronitor discover --auto /etc/crontab
        0 1 * * * root echo hello
FAIL

Intent requires that test to pass: the active line is removed, and the commented batchjob line and 0 1 * * * root echo hello stay.

jobs sync then sends the bare line as a new monitor. Command, run twice (exit 1, stdout, stderr, and the file matched):

printf '%s\n' '17 * * * * cronitor discover --auto /etc/crontab' > "$d/c"
env -i PATH="/usr/bin:/bin" HOME="$HOME" CRONITOR_API_KEY=1234567890 \
  /tmp/arena-interrogate/candidate-1/repro/cronitor \
  --config /tmp/arena-interrogate/candidate-1/repro/empty.json \
  jobs sync --auto "$d/c"

Stdout and the file:

17 * * * * cronitor discover --auto /etc/crontab

Stderr:

Error from https://cronitor.io/api/monitors?auto-discover=1: {"detail":"Invalid api key"}

Intent requires exit 0, the line deleted, and stderr exactly Removed the old auto-discover line. Auto-discover is no longer supported.

Commented form, same account, go test re-run twice with identical normalized output:

cd /tmp/arena-interrogate/candidate-2 && go test -count=1 -timeout 60s -run 'TestInterrogateLegacyRecognizer/(writer_bare|commented_writer_line_stays|commented_writer_line_with|commented_path|path_form)' -v ./lib/
--- FAIL: TestInterrogateLegacyRecognizer/commented_writer_line_stays_byte-for-byte
    got:
    "# 42 * * * * cronitor discover --auto  /etc/crontab\n"
    want:
    "#42 * * * * cronitor discover --auto  /etc/crontab\n"
--- FAIL: TestInterrogateLegacyRecognizer/commented_writer_line_with_leading_space_stays_byte-for-byte
    got:
    "# 42 * * * * cronitor discover --auto  /etc/crontab\n"
    want:
    " #42 * * * * cronitor discover --auto  /etc/crontab\n"

Intent requires those commented lines to stay byte-for-byte. A leading space before # was dropped, and a space was inserted after #.

After sudo -n userdel cronitor, TestLegacyAutoDiscoverLine passed (ok github.com/cronitorio/cronitor-cli/lib).

Adversaries: both.

Dropped

  • Adversary 1: 0 reports dropped. Its commented-line report is finding 3, same root cause as the bare-line miss.
  • Adversary 2: 0 reports dropped. Its commented-line report is finding 3. It also ran a command-tree check (bare jobs, unknown subcommand, root sync/discover/list/shell/dash, jobs dash --mcp / --mcp-instance, sync flags). It reported no failure there. I did not re-run that check, so it is not a finding.
  • Removing --no-auto-discover and not installing a replacement line is the intended break.
  • These probes passed on re-run and are not findings: a command that only contains discover, a command that only contains --auto, --auto appearing before discover, /usr/local/bin/cronitor discover --auto removed (including while the cronitor account existed), cronitor --hostname db1 discover --auto removed while that account existed, and the bare cronitor discover --auto line removed when that account does not exist.
  • cd web && npm ci && npm run build, then go build ./... and go test ./..., exited 0. TestCompat_LogPresignAndUploadFromExec did not fail on this run.

FINDINGS

The substring check deleted user jobs that merely mentioned
discover and --auto. Recognize the old CLI line by tokens:
an optional cronitor exec wrapper, a cronitor binary, optional
global flags, an optional jobs, then discover and the word --auto.
A pending name or ignore comment is cleared when that line is removed.

Co-authored-by: August Flanagan <aflanagan@users.noreply.github.com>
@cursor

cursor Bot commented Nov 12, 2026

Copy link
Copy Markdown

Opus 5.5 Medium review (delta)

SHA: 65ace4b7c94539a003989a324558ca3a02b7046c (delta 760790e..65ace4b, merge-base with master b5e7bac)
Verdict: APPROVE

Previous blockers (comment 6831997131): fixed

  • The regex matched user jobs. The substring regex is replaced by isLegacyAutoDiscoverCommand, which works on tokens: [cronitor exec <key>] <cronitor binary> [global flags] [jobs] discover --auto. Each token must match exactly, and the binary is matched by basename. I parsed these lines at HEAD and Write() keeps every one of them byte-for-byte: echo discover --auto, rediscover --auto, discover --auto-prune, /opt/acme/bin/discover --auto-scale, cronitor exec abc echo discover --auto, and cronitor exec abc /opt/acme/discover --auto-scale.
  • Pending # Name: and # cronitor: ignore comments leaked onto the next job. The removal branch now runs name, ignored = "", false. I added a # Name: X comment above an exec-wrapped legacy line, and the next job came out clean. The new subtest covers the plain case.

Legacy forms still removed (probe at HEAD)

cronitor discover --auto /etc/crontab > /dev/null 2>&1, cronitor -k abc discover --auto, cronitor --api-key=abc discover --auto, cronitor exec --no-stdout abc cronitor discover --auto, cronitor --no-stdout exec abc cronitor ..., the six-field and @hourly forms, a bare cronitor discover --auto, /usr/local/bin/cronitor ..., and root cronitor .... The value and boolean flag tables match RootCmd.PersistentFlags() exactly.

Blockers

None.

Non-blocking notes

  1. A renamed binary is not recognized. The old installer took the binary from os.Args[0], so a binary installed under another name wrote that name (for example 15 * * * * /usr/local/bin/cronitor-cli discover --auto /etc/crontab). That line is now kept as an ordinary job, and it fails hourly because root discover is gone (unknown command "discover"). Master recognized it. This is narrow, because official installs name the binary cronitor. The PR's "Breaking change" section already covers old discover --auto lines that no longer run.
  2. Some user jobs change key. On master, a user job such as echo discover --auto was misread as the auto-discover line, so it got the key "auto discover <path>" and the name "Auto discover …". At HEAD it gets an ordinary command-based key and name. A line already wrapped with cronitor exec <key> keeps its code, so only unwrapped lines like this would create a new monitor on the next sync. This corrects master's misreading, so it is not a blocker.
  3. Test edit in cmd/discover_test.go. The fixtures cronitor d3x0c1 cronitor discover --auto (a key with no exec) were changed to cronitor exec d3x0c1 .... The old shape was never written by any CLI version, so the change is fine.

Dropped (pre-existing)

  • On master, --no-auto-discover also deleted every regex match, including echo discover --auto, and leaked a pending name/ignore onto the next job. The PR's earlier commits made deletion the default path, which made this a regression in the previous round. This delta fixes it.

Verification

  • cd web && npm ci && npm run build: OK.
  • go build ./...: OK.
  • go test ./... at HEAD: all green (cmd and lib).
  • Edge cases were checked with a throwaway parse test (parseContent(...).Write()) and then removed.
  • Root discover --auto behavior was compared using binaries built from HEAD and from master.

@cursor

cursor Bot commented Nov 12, 2026

Copy link
Copy Markdown

Interrogate (Grok 4.7 xhigh-fast)

Reviewed 65ace4b7c94539a003989a324558ca3a02b7046c (git rev-parse HEAD matches). Merge-base with origin/master is b5e7bac38f9ec7b36f3dd7376769a24fa4cc1f30. Compared only against that master. go test ./... on this SHA passed (cmd 17.6s, lib 0.7s). TestCompat_LogPresignAndUploadFromExec did not fail this run.

Verdict: FINDINGS

Three passes: Parse/Write of 172 crontab cases against master; the same set with a passwd user named cronitor (uid 1001); then the master binary itself (createAutoDiscoverLine) installing lines, followed by jobs sync on this SHA and sync on master. The master binary was copied to /tmp/cronitor-bin/cronitor so argv[0]'s basename is cronitor. Config was a temp {} .json file. CRONITOR_API_KEY=1234567890. Each crontab started as # only a comment.

Findings

1. jobs sync keeps an auto-discover line the current master writer installs when a discover-local flag is before discover

Master's createAutoDiscoverLine joins os.Args and only rewrites the substring discover to discover --auto. Cobra 1.2 accepts discover-local flags before the subcommand, and the writer leaves them there. The new recognizer skips only global flags (lib/crontab_wrap.go skipCronitorFlags), so --no-auto-discover and -e / --exclude-from-name stop the match. Sync then treats the plumbing line as a job and calls the monitors API. Master deletes the line and does not call the API.

The usual order, flag after the subcommand, is removed by both. This is only the before-subcommand order.

A. --no-auto-discover=false before discover

Install command (master binary):

/tmp/cronitor-bin/cronitor --config /tmp/tmp.F3vBaCMwqG.json --no-auto-discover=false discover --auto --silent /tmp/tmp.qWluaRWDus/in

Installed line (cat -A):

22 * * * * /tmp/cronitor-bin/cronitor --config /tmp/tmp.F3vBaCMwqG.json --no-auto-discover=false discover --auto   --silent /tmp/tmp.qWluaRWDus/in$

HEAD jobs sync --auto on a copy: exit 1. stderr:

Error from https://cronitor.io/api/monitors?auto-discover=1: {"detail":"Invalid api key"}

File unchanged (line still present).

Master sync --auto on a copy: exit 0, stderr empty, file is only

# only a comment$
$

B. -e before discover

Install command:

/tmp/cronitor-bin/cronitor --config /tmp/tmp.F3vBaCMwqG.json -e secret discover --no-auto-discover=false --auto --silent /tmp/tmp.rv86Xa6twJ/in

Installed line:

26 * * * * /tmp/cronitor-bin/cronitor --config /tmp/tmp.F3vBaCMwqG.json -e secret discover --auto  --no-auto-discover=false  --silent /tmp/tmp.rv86Xa6twJ/in$

HEAD: exit 1, same invalid-api-key stderr, file unchanged. Master: exit 0, stderr empty, line removed (comment plus blank line remain).

Same Parse/Write result for the long flag, input 15 * * * * cronitor --exclude-from-name secret discover --auto /etc/crontab: HEAD writes the line back, master writes nothing.

Control (removed by both). Install:

/tmp/cronitor-bin/cronitor --config /tmp/tmp.F3vBaCMwqG.json discover --no-auto-discover=false --auto --silent /tmp/tmp.7QNH2CxPI3/in

Installed:

16 * * * * /tmp/cronitor-bin/cronitor --config /tmp/tmp.F3vBaCMwqG.json discover --auto  --no-auto-discover=false  --silent /tmp/tmp.7QNH2CxPI3/in$

HEAD: exit 0, stderr Removed the old auto-discover line. Auto-discover is no longer supported., line gone. Master: exit 0, line gone.

2. A line the master writer corrupts from --api-version to --apiersion is also kept

createAutoDiscoverLine does an unanchored strings.Replace(..., "-v", "", -1), so --api-version becomes --apiersion. That token is not in the global-flag map, even though api-version is. The corruption is pre-existing. The regression is that the next sync no longer deletes the line.

Install command:

/tmp/cronitor-bin/cronitor --config /tmp/tmp.F3vBaCMwqG.json --api-version 2020-01-01 discover --no-auto-discover=false --auto --silent /tmp/tmp.vX5fI0NUzu/in

Installed line:

26 * * * * /tmp/cronitor-bin/cronitor --config /tmp/tmp.F3vBaCMwqG.json --apiersion 2020-01-01 discover --auto  --no-auto-discover=false  --silent /tmp/tmp.vX5fI0NUzu/in$

HEAD jobs sync --auto: exit 1, stderr Error from https://cronitor.io/api/monitors?auto-discover=1: {"detail":"Invalid api key"}, file unchanged. Master sync --auto: exit 0, stderr empty, line removed.

Dropped (pre-existing / unproven)

  • Master substring deletions (echo discover --auto, rediscover --auto, /opt/acme/bin/discover --auto-scale, quoted echoes, notcronitor, cronitor-helper, cronitor.backup, nice / sh -c prefixes, --log discover where discover is the log path) are kept on HEAD; that is the false-positive fix.
  • # Name / # cronitor: ignore above a removed auto line leak onto the next job on master and are cleared on HEAD.
  • Commented auto lines are deleted or rewritten (#15 → # 15, CR dropped) on master and kept byte-for-byte on HEAD.
  • With passwd user cronitor, master misses 15 * * * * cronitor discover --auto /etc/crontab (parsed as run-as) and HEAD removes it; that is the requested fix. A user job with extra tokens (cronitor echo discover --auto) stays.
  • Unresolvable run-as nosuchuserzz cronitor discover --auto is kept on HEAD and deleted on master; it is not an installed run-as, and a commented form stays commented.
  • Per-command env prefixes (CRONITOR_API_KEY=x, FOO=bar) are kept on HEAD and deleted on master; the writer never emitted them. A following bare cronitor discover --auto after MAILTO= / SHELL= is still removed.
  • cronitor sync --no-auto-discover=false installs cronitor … sync … with no discover --auto. Both binaries keep it and hit the API (exit 1, invalid key, file unchanged). Root sync failing is the intended break.
  • --silent before the subcommand does not install a line (master exit 1, unknown command "<file>").
  • -vn db1 before the subcommand errors (unknown command "db1") and installs nothing. The probe line cronitor n db1 discover --auto is that failed shape after the -v strip.
  • cronitor.exe and C:\Program\cronitor.exe are kept on HEAD and deleted on master. Windows sync uses Task Scheduler, not this crontab writer, and path.Base does not split \.
  • cronitor exec KEY discover --auto with no second cronitor binary is kept by both.
  • cronitor jobs sync --auto is kept by both; the writer only inserts --auto after discover.
  • --auto=true, --auto=false, --auto-scale, and --auto&& are kept on HEAD; they are not the whole word --auto.
  • CRONITOR / Discover / quoted "…/cronitor" are kept on HEAD. The installed basename is cronitor.
  • docs/releases/*.md still say cronitor sync / cronitor dash (historical, left unchanged). Dockerfile CMD, README, MCP docs, Docs.js, bats, and CI scripts in the repo use jobs.
  • Dashboard Parse(true) drops a recognized line without the removal notice; the notice is only printed after a successful non-dry-run save, same class as master's silent removal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants