Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): project updates reach folded settings #22827

Closedjuliusmarmingewants to merge 4 commits intomain fromfix/issue-14991opened View on GitHub

juliusmarmingecommented

t3_project_update saves scripts and project defaults on the project aggregate after settings have been folded, while Settings and runtime read project overrides. Fixes #14991.

Reproduced on 1688f96568: a Codex thread saved a setup action and model default; t3_project_read returned them, Settings showed no action and another default, and a new worktree skipped setup. Saving the same command through Settings made the next worktree run it.

Project service updates now merge these fields into project settings overrides under the existing settings write lock. Folded reads return the settings runtime consumes. Explicit overrides survive unrelated edits, and clearing the workspace default restores inheritance. Existing aggregate-only saves remain inactive after folding; re-saving through the tool applies them.

Validation: 154 focused tests pass across five suites; server typecheck and targeted formatting/lint pass (existing warnings only). Five regression cases failed on baseline. The retry follow-up passes 21 project-service tests plus 49 project-command/settings tests, one-shot server typecheck and targeted lint. The lock-order correction at f05e15112d passes 71 focused tests and targeted lint. Its SQL-reader regression fails against the prior implementation. Final Codex review: FIX_FIRST. A no-event command receipt writer in Orchestrator.ts bypasses the EventSink command-ID lock: a colliding thread.stop can win the receipt after project settings were written, leaving a rejected update with side effects. Needs shared receipt serialization and a Deferred-controlled collision regression. Both proof audits are INSUFFICIENT. Work stopped at dispatcher deadline; this PR is not merge-ready.

The settings-file write runs before the SQL transaction, after receipt checks, under a command-ID lock shared by project/thread receipt writers. A failed settings write leaves the command retryable; successful replay preserves later Settings edits. This avoids holding the SQL writer while waiting for the settings lock. This does not claim atomicity across a successful settings-file write followed by a later SQL commit failure.

Evidence: final focused checks, fixture matrix, baseline runtime transcript.

Before: Settings ignores the tool-written action and default

Evidence follow-up: runtime transcript at 1c79962060, 1440/390 light/dark capture index. These precede the final lock correction.

After at 1c79962060: Settings shows tool-written setup and model

Unverified: matched baseline captures and image diffs/thresholds; committed capture seed; remaining fixture-matrix branches; final lock-correction runtime; full production-settings concurrency interleaving and command-collision race; mobile settings and desktop. Proof pass 1 and pass 2: INSUFFICIENT. Do not treat this as evidence-complete.

Model: GPT-6.1-Sol. Harness: Codex in T3 Code.

    1. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB−7 B (−0.1%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB−7 B (−0.6%)2.0 KiB✅
      CodexLive turn WebSocket decoded20.9 KiB20.9 KiB0 B (0.0%)29.3 KiB✅
      CodexLive turn messages220 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
      ClaudeLive turn messages220 (0.0%)8✅

      Baseline: 1688f96 · PR result: f05e151 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    2. Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — This patch makes project updates persist and expose effective model, environment, auto-pull, and setup-script defaults after settings folding, with additional command-lock and cross-store persistence behavior. Because it changes customer-visible default behavior and its persistence path, the change merits human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Team
      • Run ID: 6378f6d0-fe58-4ed1-a76d-76f86a94fea1
      📥 Commits

      Reviewing files that changed from the base of the PR and between 1688f965682d331da16a8c39f049592361f69c8d and f05e15112d6e70ec9f9c8aa5c100e361411805a1.

      📒 Files selected for processing: 8
      • apps/server/src/device/DeviceService.test.ts
      • apps/server/src/orchestration-v2/EventSink.ts
      • apps/server/src/orchestration-v2/ThreadSettlementService.test.ts
      • apps/server/src/project/ProjectService.test.ts
      • apps/server/src/project/ProjectService.ts
      • apps/server/src/provider/ProviderRegistry.test.ts
      • apps/server/src/serverSettings.test.ts
      • apps/server/src/serverSettings.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

      📝 Walkthrough

      The server now accepts functional settings patches, serializes command commits by command ID, and resolves folded project settings during project reads and updates.

      Changes: Project settings flow

      Layer / File(s)Summary
      Functional settings patches
      apps/server/src/serverSettings.ts, apps/server/src/serverSettings.test.ts, apps/server/src/device/DeviceService.test.ts, apps/server/src/orchestration-v2/ThreadSettlementService.test.ts, apps/server/src/provider/ProviderRegistry.test.ts
      updateSettings accepts an object patch or a function that derives a patch from current settings. Implementations and test fixtures resolve functional patches before applying them. A concurrency test checks that independent project overrides are retained.
      Serialized command commits
      apps/server/src/orchestration-v2/EventSink.ts
      Project command commits check receipts before starting a transaction and can run an optional beforeCommit effect. Accepted and rejected thread and project command commits are serialized by command ID.
      Folded project settings
      apps/server/src/project/ProjectService.ts, apps/server/src/project/ProjectService.test.ts
      Hydration resolves folded project settings and scripts. Project metadata updates persist provided overrides before command commit. Tests cover settings-write failures, effective settings, reset behavior, replay, and read consistency.

      Priority: ⬇️ Low

      Estimated code review effort: 3 (Moderate) | ~25 minutes

      Change: Bug fix · Severity of issue fixed: Low

      Sequence Diagram(s)

      sequenceDiagram
        participant ProjectService
        participant EventSinkV2
        participant ServerSettingsService
        participant Database
        ProjectService->>EventSinkV2: Commit project command with beforeCommit
        EventSinkV2->>EventSinkV2: Check project receipt and command ID
        EventSinkV2->>ProjectService: Run beforeCommit effect
        ProjectService->>ServerSettingsService: Persist project settings overrides
        ServerSettingsService-->>ProjectService: Return update result
        EventSinkV2->>Database: Commit project command transaction

      Suggested reviewers: t3dotgg, yordis

      Merge Risk: ⚪ Minimal · up to f05e1

      No actionable merge-blocking issue remains from this review; the change is mergeable after normal checks.

      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe title clearly identifies the main change: making project updates reach folded settings. It is concise, specific, and uses the conventional commit format.
      Description checkPassedThe description explains the problem, implementation, linked issue, verification results, limitations, and remaining risks. It is substantially complete, although it does not explicitly document maint…
      Linked Issues checkPassedIssue #14991 is open and directly linked. ProjectService now reads folded settings and scripts through resolveProjectSettings and resolveProjectScripts. Project updates write `defaultProjectScri…
      Out of Scope Changes checkPassedThe changes stay within issue #14991. The functional updateSettings API supports safe merging of project overrides. EventSink command locks support settings-write ordering and retry behavior. The mo…
      Full details: Description check

      Explanation

      The description explains the problem, implementation, linked issue, verification results, limitations, and remaining risks. It is substantially complete, although it does not explicitly document maintainer approval or explain why approval is exempt under the Scope and approval requirements.

      Full details: Linked Issues check

      Explanation

      Issue #14991 is open and directly linked. ProjectService now reads folded settings and scripts through resolveProjectSettings and resolveProjectScripts. Project updates write defaultProjectScripts, defaultModelSelection, defaultThreadEnvMode, and defaultAutoPull into projectSettingsOverrides before the project command commit. Clearing defaultThreadEnvMode removes the override and restores inheritance. Settings-write failures map to ProjectOperationError with update-settings, so the update does not report success. ProjectService.test.ts covers folded reads, persistence failures, retries, resets, and preservation of later settings edits.

      Full details: Out of Scope Changes check

      Explanation

      The changes stay within issue #14991. The functional updateSettings API supports safe merging of project overrides. EventSink command locks support settings-write ordering and retry behavior. The modified test fixtures and added concurrency tests support these changes. No unrelated production feature or excluded-file change is present.

      ✨ Finishing Touches
      📝 Generate docstrings
      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    4. Note

      🤖 GPT-6.1 Terra [1m] responding on behalf of Theo

      Closing in favor of the contributor branch Julius took over, which uses folded settings for action/default writes and reads and prevents old retries from overwriting newer edits. #21224 #14991

Sign in to join this conversation.