Skip to content

feat(config): add GOCLAW_CRON_JOB_TIMEOUT env var for cron timeout - #1099

Merged
mrgoonie merged 1 commit into
nextlevelbuilder:devfrom
hoakhongmau98:feat/cron-job-timeout-env-var
Jun 22, 2026
Merged

feat(config): add GOCLAW_CRON_JOB_TIMEOUT env var for cron timeout#1099
mrgoonie merged 1 commit into
nextlevelbuilder:devfrom
hoakhongmau98:feat/cron-job-timeout-env-var

Conversation

@hoakhongmau98

Copy link
Copy Markdown
Contributor

Summary

  • Adds GOCLAW_CRON_JOB_TIMEOUT env var mapping in applyEnvOverrides(), completing the GOCLAW_* env var pattern for CronConfig.JobTimeout.
  • Lets operators override cron job timeout without editing the JSON config file — useful for deployments running multi-turn LLM agents with large contexts where 10m default is too short.
  • Zero breaking change: unset/invalid values fall through to the existing DefaultJobTimeout (10m) behavior via the existing JobTimeoutDuration() helper, which already handles parse errors with slog.Warn.

Closes #1098

Changes

internal/config/config_load.go — one new section in the operational-config block (next to Browser):

// Cron job execution
envStr("GOCLAW_CRON_JOB_TIMEOUT", &c.Cron.JobTimeout)

internal/config/config_load_test.go — 4 new test cases:

  • TestLoad_CronJobTimeout_EnvVarGOCLAW_CRON_JOB_TIMEOUT=1h1h
  • TestLoad_CronJobTimeout_Invalid_FallsBackToDefault — invalid value → 10m (logs warn)
  • TestLoad_CronJobTimeout_Unset_UsesDefault — unset → 10m
  • TestLoad_CronJobTimeout_EnvOverridesFile — file 5m + env 30m30m (env wins)

Test plan

  • go build ./... (PG build)
  • go build -tags sqliteonly ./... (Desktop/SQLite build)
  • go vet ./...
  • go test ./internal/config/ — 4 new + all existing tests pass
  • Manual: run gateway with GOCLAW_CRON_JOB_TIMEOUT=1h and confirm a long cron job is no longer killed at 10m

Notes for reviewers

  • Placement chosen near the operational-config block (Sandbox/Browser) rather than the secrets block at the top, since cron timeout is a runtime parameter, not a credential.
  • No new error handling needed — CronConfig.JobTimeoutDuration() already validates and falls back. This was confirmed by the existing TestCronConfig_JobTimeoutDuration_Invalid test.
  • No changes to default behavior; existing deployments without the env var see no difference.

Allow overriding the cron job execution timeout via env var, matching
the existing GOCLAW_* env var pattern used throughout the codebase.

Falls back to the existing default (10m) when unset or invalid, since
CronConfig.JobTimeoutDuration() already handles parse errors with a
slog.Warn and the DefaultJobTimeout constant.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mrgoonie

Copy link
Copy Markdown
Contributor

Backlog triage note: this overlaps with #1114 for GOCLAW_CRON_JOB_TIMEOUT / #1098. This PR still has useful config_load_test.go coverage, so I am not closing it automatically. Recommended consolidation: keep the clean implementation path from #1114, but port or preserve these tests before closing this PR.

@mrgoonie mrgoonie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary: This is the cleaner merge target for #1098: it adds the same one-line GOCLAW_CRON_JOB_TIMEOUT env mapping as duplicate PR #1114, but also includes focused config-load regression tests for env override, invalid fallback, unset default, and env-over-file precedence.

Risk level: Low

Mandatory gates:

  • Duplicate/prior implementation: overlap found with #1114. This PR is the better consolidation target because it includes the missing tests; #1114 can be closed after this lands.
  • Project standards: passed — env override is placed in config loading and covered by tests.
  • Strategic necessity: clear value for operators running long cron jobs.
  • CI/checks: no GitHub checks reported on this branch, but the touched code is narrow and test coverage is included.

Findings:

  • Critical: none
  • Important: none
  • Suggestion: after merge, close #1114 as duplicate/superseded by this PR.

Verdict: APPROVE

@mrgoonie
mrgoonie merged commit 6d742d4 into nextlevelbuilder:dev Jun 22, 2026
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.

feat(config): add GOCLAW_CRON_JOB_TIMEOUT env var for configurable cron timeout

3 participants