Skip to content

chore(office): delete unwired GC and fix stale scheduler doc - #3478

Open
nova28 wants to merge 1 commit into
kdlbs:mainfrom
nova28:chore/wo-26-delete-office-gc
Open

chore(office): delete unwired GC and fix stale scheduler doc#3478
nova28 wants to merge 1 commit into
kdlbs:mainfrom
nova28:chore/wo-26-delete-office-gc

Conversation

@nova28

@nova28 nova28 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Tip

PR walkthrough: Open the visual walkthrough

Summary

  • office/infra/gc.go's GarbageCollector was never constructed in production — office.Services.GC was always nil, and its only construction site was gc_test.go. The wired, scheduled internal/system/storage subsystem already does both sweeps (containers, worktrees) with strictly stronger guards (canonical terminal-state check via models.IsTerminalTaskState, archived_at, live env/executor rows, and quarantine-with-retention instead of os.RemoveAll). Deleted gc.go and gc_test.go, moved the infra package doc onto reconcile.go.
  • office/scheduler/run.go's package comment claimed a tick loop, event subscribers, and idle-timeout management it does not own (idle-timeout management was removed package-wide; the tick loop lives in office/service/scheduler_integration.go; the scheduler only publishes to the event bus, it does not subscribe). Corrected to describe what it actually owns: run processing, dispatch/tier routing, retry logic, reactivity, and mentions.

No runtime/behavior change — the deleted GC never ran, and the doc comment was not user-visible.

Test plan

  • go build -tags fts5 ./...
  • go test -tags fts5 ./internal/office/... — all packages pass
  • go test -tags fts5 ./internal/backendapp/... — confirms office.Services construction site still compiles/works without the removed field
  • gofmt -l on touched files — clean
  • golangci-lint run ./internal/office/... --new-from-rev=cd7823631 — 0 issues
  • go vet -tags fts5 ./internal/office/... — clean
  • go test -tags fts5 ./internal/worktree/... has ~30 pre-existing failures on this host (macOS temp-dir/symlink issues), confirmed identical against the unmodified base commit — unrelated to this change, which never touches internal/worktree.

Follow-up filed for worktree.Manager.ListActiveWorktreePaths / SQLiteStore.ListActiveWorktreePaths, which have zero production callers after this delete (out of scope here — needs an interface change and touches 3 test files).

Review in cubic

Preview Environment

URL https://kandev-pr-3478-bwo7.sprites.app
Commit 369881a
Agent Mock agent

Updates automatically on each push. Destroyed when the PR is closed.

gc.go's GarbageCollector was never constructed in production (office.Services.GC
was always nil); the same container/worktree reclamation is already handled by
the wired, scheduled internal/system/storage subsystem with stronger guards
(canonical terminal-state check, archived_at, live env/executor rows, and
quarantine-with-retention instead of os.RemoveAll). Delete gc.go and gc_test.go
and move the infra package doc onto reconcile.go.

Also corrects the scheduler package comment, which claimed a tick loop, event
subscribers, and idle-timeout management it does not own (idle-timeout
management was removed package-wide; the tick loop lives in
office/service/scheduler_integration.go; the scheduler only publishes to the
event bus, it does not subscribe).
@nova28
nova28 temporarily deployed to opencode-review-trusted September 7, 2026 15:26 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Claude finished @nova28's task in 3m 51s —— View job


Findings

Suggestion (recommended, doesn't block)

  1. Package doc wording is stale after GC removalapps/backend/internal/office/infra/reconcile.go:1
    • Issue: The package doc ("infrastructure-level background jobs") was moved verbatim from gc.go, where it described the whole package including the scheduled GarbageCollector. After deletion, only Reconciler remains — and it runs once synchronously at startup, not on a loop.
    • Fix: inline comment left on the file with a concrete suggestion.

Summary

Severity Count
Blocker 0
Suggestion 1

Verdict: Ready to merge

The deletion is clean and well-justified:

  • No production path ever constructed GarbageCollector (confirmed: no remaining GarbageCollector symbol in the tree, no GC field remaining in office.Services or its construction site in backendapp/main.go).
  • The infra import in services.go remains valid via the still-present Reconciler field.
  • reconcile_test.go covers the surviving Reconciler; the GarbageCollector's 596-line test file was appropriately co-deleted.
  • The scheduler doc correction in scheduler/run.go is accurate: the tick loop lives in service/scheduler_integration.go, not the scheduler package, and idle-timeout management was correctly noted as removed.
  • The stale // Used by the office GC comments in internal/worktree/ are pre-existing on unchanged lines; the PR description correctly scopes the follow-up as a separate interface-change task.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: QUIET

Plan: Team

Run ID: 7d78d55a-c556-4b1f-bc84-23e6f5383167

📥 Commits

Reviewing files that changed from the base of the PR and between 52948cd and 369881a.

📒 Files selected for processing (5)
  • apps/backend/internal/office/infra/gc.go
  • apps/backend/internal/office/infra/gc_test.go
  • apps/backend/internal/office/infra/reconcile.go
  • apps/backend/internal/office/scheduler/run.go
  • apps/backend/internal/office/services.go
💤 Files with no reviewable changes (3)
  • apps/backend/internal/office/infra/gc_test.go
  • apps/backend/internal/office/services.go
  • apps/backend/internal/office/infra/gc.go

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Changes

    • Removed automatic cleanup of unused worktrees and containers.
    • Removed related cleanup reporting and configuration.
  • Documentation

    • Updated package descriptions to better reflect current run processing, routing, retries, reactivity, and mentions.
    • Added documentation for infrastructure package responsibilities.

Walkthrough

The office garbage collector implementation and tests were deleted. The Services struct no longer exposes garbage collection. Infrastructure and scheduler package comments were updated.

Changes

Office garbage collector removal

Layer / File(s) Summary
Remove garbage collection and update package descriptions
apps/backend/internal/office/infra/gc.go, apps/backend/internal/office/infra/gc_test.go, apps/backend/internal/office/services.go, apps/backend/internal/office/infra/reconcile.go, apps/backend/internal/office/scheduler/run.go
The garbage collector implementation, tests, exported declarations, and Services.GC field were removed. The infra and scheduler package comments were updated.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 36988

This removes an unused office garbage collector and updates package descriptions without changing the retained scheduler or reconciler wiring. No current merge-readiness risk is identified.

Suggested reviewers: carlosflorencio

Poem

A rabbit finds the sweepers gone,
No worktree trails remain at dawn.
The service carries lighter gear,
While package words become more clear.
Hop by hop, the code moves on.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies both main changes: deleting the unused garbage collector and correcting the stale scheduler documentation.
Description check ✅ Passed The description explains the motivation, scope, runtime impact, and validation results. It is mostly complete, but it uses non-template headings, omits the required Checklist section, and retains an a…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 369881a1a5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Workspaces *officeservice.Service
Documents *taskservice.DocumentService
GC *infra.GarbageCollector
Reconciler *infra.Reconciler

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Amend ADR 0009's stale implementation references

After removing gc.go and gc_test.go, accepted ADR docs/decisions/0009-fail-closed-gc-semantics.md still identifies those deleted files as the implementation and regression tests (lines 51-52), and its consequences still claim the Office collector is wired (line 41). Maintainers following the accepted decision will therefore reach nonexistent code and an obsolete architecture; amend the ADR to record that internal/system/storage superseded this collector and point its implementation and test references at the replacement.

Useful? React with 👍 / 👎.

@@ -1,3 +1,4 @@
// Package infra provides infrastructure-level background jobs for the office domain.

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.

Nit: "background jobs" no longer fits — the GarbageCollector (a scheduled background job) was the only occupant matching that description. What remains is Reconciler, which runs once synchronously at startup. Consider:

Suggested change
// Package infra provides infrastructure-level background jobs for the office domain.
// Package infra provides infrastructure-level startup reconciliation for the office domain.

@greptile-apps

greptile-apps Bot commented Sep 7, 2026

Copy link
Copy Markdown

Greptile Summary

This PR removes an unwired Office garbage collector and its isolated tests, removes the unused service field, preserves the infra package documentation, and revises scheduler package documentation.

  • Production cleanup remains wired through the system storage scheduler.
  • No remaining production references to the deleted GC API were identified.
  • The scheduler documentation is substantially improved, but still overstates ownership of run processing.

Confidence Score: 4/5

The PR appears safe to merge; the remaining concern is a non-blocking documentation ownership inaccuracy.

The deleted collector has no production reachability and cleanup remains covered by the wired storage subsystem, while the only accepted issue is that the revised scheduler comment still points maintainers to the wrong owner for run processing.

Files Needing Attention: apps/backend/internal/office/scheduler/run.go

Important Files Changed

Filename Overview
apps/backend/internal/office/infra/gc.go Deletes a garbage collector with no production construction or lifecycle wiring; equivalent cleanup remains independently scheduled.
apps/backend/internal/office/infra/gc_test.go Removes tests dedicated solely to the deleted, unwired implementation.
apps/backend/internal/office/services.go Removes the unused GarbageCollector field without affecting observed production composition.
apps/backend/internal/office/infra/reconcile.go Adds the package comment to a surviving infra source file.
apps/backend/internal/office/scheduler/run.go Corrects several stale ownership claims, but still inaccurately attributes production run processing to this package.

Reviews (1): Last reviewed commit: "chore(office): delete unwired GC and fix..." | Re-trigger Greptile

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant