Skip to content

fix: make config constants env-configurable, fix deploy re-sync gap#1677

Draft
simple-agent-manager[bot] wants to merge 9 commits into
mainfrom
sam/execute-task-using-skill-r9861c
Draft

fix: make config constants env-configurable, fix deploy re-sync gap#1677
simple-agent-manager[bot] wants to merge 9 commits into
mainfrom
sam/execute-task-using-skill-r9861c

Conversation

@simple-agent-manager

@simple-agent-manager simple-agent-manager Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Make 3 documented-but-compile-time-only config constants genuinely env-configurable at runtime: NODE_LIFECYCLE_ALARM_RETRY_MS, WORKSPACE_IDLE_CHECK_INTERVAL_MS, MAX_NOTIFICATION_PAGE_SIZE
  • Fix deploy pipeline re-sync step missing 16 optional env vars (container/sandbox config) that the initial sync step forwards
  • Move CF container constants to shared package per codebase conventions
  • Rename constants to DEFAULT_* prefix per Constitution Principle XI

Changes

Deploy Pipeline

  • .github/workflows/deploy-reusable.yml: Add 16 missing env vars to re-sync step so first-deploy and subsequent deploys forward the same operator configuration

Runtime Config

  • apps/api/src/durable-objects/node-lifecycle.ts: Add getAlarmRetryMs() with env var resolution (same pattern as existing getWarmTimeoutMs())
  • apps/api/src/durable-objects/project-data/idle-cleanup.ts: Add env param to computeIdleAlarmTimes() for WORKSPACE_IDLE_CHECK_INTERVAL_MS resolution
  • apps/api/src/durable-objects/notification.ts: Align MAX_NOTIFICATION_PAGE_SIZE resolution with isFinite && > 0 guard pattern
  • apps/api/src/env.ts: Add 3 new optional env var fields to Worker Env type
  • DO-local Env types updated for NodeLifecycle and ProjectData and Notification

Shared Constants

  • packages/shared/src/constants/cf-container.ts: New file — CF container constants moved from DO file
  • packages/shared/src/constants/node-pooling.ts: Rename WORKSPACE_IDLE_CHECK_INTERVAL_MSDEFAULT_WORKSPACE_IDLE_CHECK_INTERVAL_MS
  • packages/shared/src/constants/notifications.ts: Rename MAX_NOTIFICATION_PAGE_SIZEDEFAULT_MAX_NOTIFICATION_PAGE_SIZE

Tests

  • config-env-resolution.test.ts: Default value assertions + real computeIdleAlarmTimes edge cases (NaN, zero, negative, valid override)
  • deploy-resync-env-parity.test.ts: Regression test parsing deploy YAML to ensure re-sync step forwards every env var from initial sync
  • node-lifecycle-do.test.ts: Behavioral DO test verifying alarm retry uses DEFAULT_NODE_LIFECYCLE_ALARM_RETRY_MS through real alarm handler

Docs

  • configuration.md: Add WORKSPACE_IDLE_CHECK_INTERVAL_MS to documented env vars
  • .env.example: Add example entries for new env vars

Backward Compatibility

All changes are backward-compatible:

  • Default values are identical to the previous compile-time constants
  • Renamed exports maintain the same values
  • New env vars are optional — existing deployments work unchanged
  • Deploy pipeline changes are additive (passing vars that were previously missing)

Agent Preflight (Required)

  • Preflight completed before code changes

Classification

  • external-api-change
  • cross-component-change
  • business-logic-change
  • public-surface-change
  • docs-sync-change
  • security-sensitive-change
  • ui-change
  • infra-change

External References

N/A: Internal config/deploy remediation only. Referenced existing codebase patterns (getWarmTimeoutMs in node-lifecycle.ts) and Constitution Principle XI from .specify/memory/constitution.md.

Codebase Impact Analysis

  • apps/api/src/durable-objects/ — NodeLifecycle, Notification, ProjectData DOs updated with env var resolution
  • apps/api/src/env.ts — 3 new optional env var fields added to Worker Env interface
  • packages/shared/src/constants/ — New cf-container.ts, renamed constants in node-pooling.ts and notifications.ts
  • .github/workflows/deploy-reusable.yml — 16 env vars added to re-sync step for deploy parity
  • apps/www/src/content/docs/docs/reference/configuration.md — New env var documented in operator reference
  • apps/api/.env.example — Added example entries for new configurable env vars

Documentation & Specs

  • apps/www/src/content/docs/docs/reference/configuration.md — Added WORKSPACE_IDLE_CHECK_INTERVAL_MS to Warm Node Pooling table
  • apps/api/.env.example — Added example entries for WORKSPACE_IDLE_CHECK_INTERVAL_MS and MAX_NOTIFICATION_PAGE_SIZE

Constitution & Risk Check

  • Principle XI (No Hardcoded Values): This PR exists to enforce it — 3 constants that were compile-time-only are now genuinely configurable via env vars with DEFAULT_* fallbacks
  • Risk: Low — all defaults are identical to previous values; changes are additive and backward-compatible

Specialist Review Evidence

Reviewer Status Notes
task-completion-validator ADDRESSED Lint errors fixed, tautological test replaced
cloudflare-specialist ADDRESSED Import sort + notification guard pattern fixed
env-validator ADDRESSED .env.example, prettier, guard pattern aligned
constitution-validator PASS Test discriminating quality improved
doc-sync-validator PASS No findings
test-engineer ADDRESSED Tautological resolveMs() replaced, DO behavioral test added

Staging Verification

Skipped — config/constants/deploy changes only, no runtime behavior or UI changes. Deploy pipeline regression is covered by deploy-resync-env-parity.test.ts.

Test Plan

  • pnpm lint passes (0 errors)
  • pnpm typecheck passes
  • pnpm test passes (6362+ tests)
  • pnpm build passes
  • New tests are discriminating (verified fail on pre-fix code)

⚠️ DRAFT — DO NOT MERGE per task constraints.

🤖 Generated with Claude Code

Task ID: 01KYC73DQFH22WH4AF09R9861C

raphaeltm and others added 7 commits July 25, 2026 09:06
- Fix deploy-reusable.yml re-sync step missing 16 optional env vars
  (container/sandbox overrides silently lost on first deploys)
- Make NODE_LIFECYCLE_ALARM_RETRY_MS env-configurable (was documented
  as configurable but was a compile-time constant)
- Make WORKSPACE_IDLE_CHECK_INTERVAL_MS env-configurable (all sibling
  constants had env overrides, this one did not)
- Make MAX_NOTIFICATION_PAGE_SIZE env-configurable (was documented as
  configurable but was a compile-time constant)
- Move CF container constants to packages/shared/src/constants/cf-container.ts
  (were defined locally in DO file, bypassing shared constants pattern)
- Update configuration.md to document WORKSPACE_IDLE_CHECK_INTERVAL_MS

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nc parity

- config-env-resolution: verifies DEFAULT_* constant values and
  parseInt-with-fallback env var resolution pattern including
  computeIdleAlarmTimes env override
- deploy-resync-env-parity: regression test ensuring the re-sync step
  in deploy-reusable.yml forwards every optional env var from the
  initial sync step (prevents the 16-var gap from recurring)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The Notification DO has its own local Env type separate from the
Worker Env. The new env var override was added to the Worker Env but
not the DO's local type, causing a typecheck failure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ating

Assert the exact resolved value (baseTime + envOverrideMs) instead of
just asserting non-null. This discriminates between the env override
(600000ms / 10min) and the default (300000ms / 5min).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- HIGH: add WORKSPACE_IDLE_CHECK_INTERVAL_MS and MAX_NOTIFICATION_PAGE_SIZE
  to .env.example (the documented 'complete list')
- MEDIUM: align MAX_NOTIFICATION_PAGE_SIZE resolution with the
  isFinite && > 0 guard pattern used by sibling resolvers
- LOW: fix Prettier table formatting in configuration.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ioral DO test

- Fix import sort lint errors in notification.ts and idle-cleanup.ts
- Replace tautological resolveMs() hand-copy test with real computeIdleAlarmTimes
  edge case tests (NaN, zero, negative, valid override) that exercise actual code
- Add NodeLifecycle DO integration test proving alarm retry interval uses
  DEFAULT_NODE_LIFECYCLE_ALARM_RETRY_MS through the real alarm handler

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codspeed-hq

codspeed-hq Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 6 untouched benchmarks


Comparing sam/execute-task-using-skill-r9861c (a73ef43) with main (44adc7e)

Open in CodSpeed

raphaeltm and others added 2 commits July 25, 2026 09:50
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant