Skip to content

refactor: land god-file round 1 (cleanup, service, kiro) - #4495

Merged
lidge-jun merged 10 commits into
devfrom
codex/260913-godfile-round1-merge
Sep 13, 2026
Merged

lidge-jun merged 10 commits into
devfrom
codex/260913-godfile-round1-merge

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Sep 13, 2026 •

Copy link
Copy Markdown
Owner

God-file round 1 stack already merged with current dev. Facades for storage/cleanup, service, and kiro. Source-contract tests retargeted to owning leaves. Windows logon-trigger fix from #4425 lives in src/service/windows-taskxml.ts.

Summary

God-file round 1 stack, already merged with current dev. src/storage/cleanup.ts, src/service.ts, and src/adapters/kiro.ts stay as facades over cohesive leaves.

Verification

  • Local product suite, typecheck, and build were NOT RUN by operator instruction. Hosted CI on this head is the proof.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Summary by CodeRabbit

  • New Features

    • Added support for Kiro conversations, streaming responses, tool use, images, reasoning modes, and usage tracking.
    • Added archived-session cleanup with preview, quarantine or permanent deletion, resumable restore, and database consistency safeguards.
    • Added cross-platform service installation, repair, restart, status, and uninstall workflows for macOS, Windows, and Linux.
  • Bug Fixes

    • Improved service health checks, ownership validation, token protection, rollback handling, and failure reporting.
  • Documentation

    • Updated runtime documentation to reflect service and Kiro module organization.

Pure-move split of src/storage/cleanup.ts (3141 lines) into src/storage/cleanup/ leaves: types, paths, db, satellite, pending, reconcile, staging, preview, execute, restore. The original file remains a facade re-exporting every public name. No behavior change; no consumer edits.
Pure-move split of src/service.ts (5558 lines) into src/service/ leaves: state (paths/install-state), guards (ownership/auth/manager-command), health (port resolution + serving checks), launchd, systemd, windows-scheduler (schtasks + elevation finalize), windows-taskxml (task XML build/verify), windows-ops (Windows install/stop/uninstall + stage tracking), repair, orchestration (install/uninstall/stop dispatch), diagnostics, cli (arg parsing/dispatch). src/service.ts is now a facade re-exporting every original export. One semantic-preserving adjustment: import.meta.dir at the old file depth is carried by serviceSourceDir in state.ts.
…eaves [skip ci]

Hosted CI on the stack tip went red because source-contract tests still
read the 30-line facade at src/service.ts. Point each assertion at the
owning leaf so the existing oracles keep their original strings, slices,
and negative matches. Import-specifier depth is the only assertion text
that changed, because the leaves sit one directory lower.
… [skip ci]

Hosted CI shard 2/4 still read src/service.ts from launchd-repair.test.ts.
Point each slice at the owning leaf and keep the original assertion strings.
Pure-move split of the 2319-line kiro.ts god file into src/adapters/kiro/ leaves: wire.ts (wire identity/constants + message shapes), usage.ts (token estimation + message-text walkers), reasoning.ts (reasoning mode + thinking-tag injection), conversation.ts (capability + conversation-state validation), payload.ts (buildKiroPayload assembly), stream.ts (eventstream parsing + bounded fallback), adapter.ts (createKiroAdapter). kiro.ts is now a thin facade re-exporting the same public surface. Zero behavior change; no consumer edits.
The Kiro implementation now lives under src/adapters/kiro/, with
src/adapters/kiro.ts as the facade. Keep the structure map aligned so
structure:check still names a path inside the owned area.
dev landed #4425 on the old src/service.ts after this stack branched.
Carry the LogonTrigger UserId and the matching source-contract tests
into src/service/windows-taskxml.ts so a non-elevated install still
registers without asking for UAC.
Keep the service facade. The Windows logon-trigger fix from #4425 is
already in src/service/windows-taskxml.ts.
Merge the god-file round 1 stack: storage/cleanup, service, and kiro facades.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner September 13, 2026 09:01
@lidge-jun lidge-jun added the test-exception-approved Maintainer approved a non-automated regression-test exception label Sep 13, 2026
@coderabbitai

coderabbitai Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 2f58c08d-108f-4478-9532-266945dc8cfb

📥 Commits

Reviewing files that changed from the base of the PR and between 3f76ce4 and 0d3cd53.

📒 Files selected for processing (45)
  • devlog/_plan/260913_godfile_round1/000_plan.md
  • src/adapters/kiro.ts
  • src/adapters/kiro/adapter.ts
  • src/adapters/kiro/conversation.ts
  • src/adapters/kiro/payload.ts
  • src/adapters/kiro/reasoning.ts
  • src/adapters/kiro/stream.ts
  • src/adapters/kiro/usage.ts
  • src/adapters/kiro/wire.ts
  • src/service.ts
  • src/service/cli.ts
  • src/service/diagnostics.ts
  • src/service/guards.ts
  • src/service/health.ts
  • src/service/launchd.ts
  • src/service/orchestration.ts
  • src/service/repair.ts
  • src/service/state.ts
  • src/service/systemd.ts
  • src/service/windows-ops.ts
  • src/service/windows-scheduler.ts
  • src/service/windows-taskxml.ts
  • src/storage/cleanup.ts
  • src/storage/cleanup/db.ts
  • src/storage/cleanup/execute.ts
  • src/storage/cleanup/paths.ts
  • src/storage/cleanup/pending.ts
  • src/storage/cleanup/preview.ts
  • src/storage/cleanup/reconcile.ts
  • src/storage/cleanup/restore.ts
  • src/storage/cleanup/satellite.ts
  • src/storage/cleanup/staging.ts
  • src/storage/cleanup/types.ts
  • structure/INDEX.md
  • structure/manifest.json
  • structure/runtime.md
  • tests/cli/cli-ready.test.ts
  • tests/cli/uninstall.test.ts
  • tests/providers/xai/grok-lifecycle.test.ts
  • tests/server/startup-prompt.test.ts
  • tests/service/launchd-repair.test.ts
  • tests/service/service.test.ts
  • tests/service/systemd-install-cleanup-hardening.test.ts
  • tests/windows/windows-deploy-close-regressions.test.ts
  • tests/windows/windows-service-wrappers.test.ts

📝 Walkthrough

Walkthrough

The change splits Kiro, service, and storage-cleanup implementations into focused modules. It adds Kiro request and stream handling, cross-platform service management, archived-session cleanup and restore flows, structure documentation, and updated source-location tests.

Changes

Archived storage cleanup

Layer / File(s) Summary
Cleanup contracts and filesystem primitives
src/storage/cleanup/types.ts, src/storage/cleanup/paths.ts, src/storage/cleanup/staging.ts, src/storage/cleanup/pending.ts
Adds cleanup types, safe path handling, atomic file operations, staging, rollback, and durable restore-pending markers.
Cleanup preview and database access
src/storage/cleanup/preview.ts, src/storage/cleanup/db.ts
Adds candidate discovery, digest validation, pinned and pending-restore filtering, SQLite discovery, writable probes, and row utilities.
Cleanup execution and reconciliation
src/storage/cleanup/execute.ts, src/storage/cleanup/reconcile.ts
Adds quarantine and permanent cleanup execution, manifest handling, staged-file processing, thread reconciliation, and rollback results.
Quarantine restore and satellite recovery
src/storage/cleanup/restore.ts, src/storage/cleanup/satellite.ts
Adds trash listing, resumable file restoration, database reconstruction, satellite backups, transaction locks, completeness checks, and stage finalization.

Cross-platform service management

Layer / File(s) Summary
Service state and platform backends
src/service/state.ts, src/service/launchd.ts, src/service/systemd.ts, src/service/windows-taskxml.ts, src/service/windows-scheduler.ts, src/service/windows-ops.ts
Adds service state records, launchd and systemd operations, Windows task XML and scheduler handling, WinSW operations, verification, rollback, and uninstall behavior.
Service guards and health checks
src/service/guards.ts, src/service/health.ts
Adds ownership and authentication checks, token provisioning, mutation guards, port resolution, proxy environment handling, and serving checks.
Service orchestration and repair
src/service/orchestration.ts, src/service/repair.ts
Adds installation preparation, proxy cleanup, platform dispatch, Windows registration recovery, lifecycle outcomes, and repair/restart flows.
Service CLI, diagnostics, and validation
src/service/cli.ts, src/service/diagnostics.ts, tests/service/*, tests/cli/*, tests/providers/xai/grok-lifecycle.test.ts, tests/server/startup-prompt.test.ts, tests/windows/*, structure/*
Adds command planning and dispatch, diagnostic reporting, updated source assertions, and structure documentation for the split service modules.

Kiro provider adapter

Layer / File(s) Summary
Kiro wire, conversation, and reasoning contracts
src/adapters/kiro/wire.ts, src/adapters/kiro/conversation.ts, src/adapters/kiro/reasoning.ts
Adds Kiro wire types and metadata, endpoint normalization, capability validation, conversation-state validation, completion detection, and reasoning modes.
Kiro payload and usage construction
src/adapters/kiro/payload.ts, src/adapters/kiro/usage.ts
Adds message and tool translation, completion handling, bounded instruction injection, image and token estimation, wire adjustments, and context-window lookup.
Kiro stream translation
src/adapters/kiro/stream.ts
Adds event-stream decoding, event translation, budget accounting, terminal classification, usage merging, and bounded fallback attempts.
Kiro adapter wiring
src/adapters/kiro/adapter.ts, structure/runtime.md
Adds request construction, CLI/IDE wire selection, calibration, fallback request creation, duplicate-final suppression, response parsing, and Kiro module documentation.

Estimated code review effort: 5 (Critical) | ~120 minutes

Change: Refactor

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/260913-godfile-round1-merge

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.

@lidge-jun
lidge-jun merged commit 6aaab49 into dev Sep 13, 2026
3 of 5 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-09-13T09:03:39.238615Z 0d3cd53 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). label Sep 13, 2026
@lidge-jun
lidge-jun deleted the codex/260913-godfile-round1-merge branch September 14, 2026 11:30
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
…-round1-merge

refactor: land god-file round 1 (cleanup, service, kiro)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). test-exception-approved Maintainer approved a non-automated regression-test exception

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant