Skip to content

feat(rewrite): add Phase 3 cache foundation - #403

Open
mira-2026 wants to merge 2 commits into
mira/greenfield-rewrite-phase-three-jobs-browserfrom
mira/greenfield-rewrite-phase-three-cache
Open

feat(rewrite): add Phase 3 cache foundation#403
mira-2026 wants to merge 2 commits into
mira/greenfield-rewrite-phase-three-jobs-browserfrom
mira/greenfield-rewrite-phase-three-cache

Conversation

@mira-2026

@mira-2026 mira-2026 commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add the Phase 3 cache contract and durable cache_entries projection with separate last-attempt state and derived freshness
  • register the pure cache.refresh.system-host action and daily cache.system-host schedule, with worker-only execution and a strict system.host payload
  • commit cache state and realtime outbox events atomically behind exact job-claim, action, payload, owner, token, and lease fences
  • wire authenticated cache.getEntry, cache.getStatus, and cache.refreshEntry procedures through the production server/runtime composition
  • preserve caller-scoped idempotency replay ahead of mutable provider, action, and schedule lookups

Correctness and security

  • cache.getStatus returns at most 128 rows plus explicit totalCount, truncated, and one snapshot clock
  • cache persistence rejects non-cache actions, mismatched canonical payloads, stale claims, and expired leases at transaction admission time
  • synchronous executor construction/parse defects settle as redacted job failures without crashing the worker
  • cache:read / cache:write capabilities and exact cache.entries realtime identity are enforced end to end
  • the unpublished greenfield baseline migration, schema snapshot, manifest hashes, generated contract docs, parity inventory, and process docs move together

Behavior and regression coverage

  • cache.getStatus locks the 128-row response boundary, total count, truncation marker, one generated-at clock, and freshness consistency
  • repository tests prove that foreign actions, non-canonical payloads, stale claims, expired leases, and delayed write admission cannot commit cache state
  • worker tests prove that synchronous executor defects become redacted failed attempts and do not terminate the process
  • API, auth, realtime, migration, source-boundary, parity, generated-doc, and production-composition tests cover the complete slice

Verification

  • bun run build:release
  • bun run test:bun — 1573/1573
  • bun run test:browser — 219/219 across all browser partitions
  • bun run typecheck:bun
  • bun run typecheck:browser
  • bun run lint:bun
  • bun run lint:browser
  • bun run format:check
  • bun run docs:check
  • bun run db:checkok / no_changes
  • bun run check:boundaries
  • git diff --check

Stack and scope

  • stacked directly on feat(rewrite): add Phase 3 jobs browser #402 at c6ab45a186e6e795e216814ee83fd2e34ae27d90
  • exact reviewed head: 69bc9140fc5c0e0e0c99dff538adb6c91c6fdf25
  • intentionally leaves cache.getHeartbeat, OpenClaw cron integration, cache browser consumption, metrics, and overview for subsequent slices
  • no deploy, restart, config, secret, or published-migration operation
  • rollback before publication is removal of this two-commit stacked PR

Risk checklist

  • No secrets, tokens, environment files, database dumps, or runtime state committed
  • Authentication, capabilities, input/output validation, claim fencing, and realtime identity were reviewed explicitly
  • The schema change is confined to the unpublished greenfield baseline and has a clean drift check
  • Ordering, idempotency, lease expiry, recovery, and process-failure behavior have regression coverage
  • No UI surface changed in this slice

Deployment / operations

  • No deploy or restart needed
  • No config or secret changes needed
  • Rollback before baseline publication is removal of this two-commit stacked PR

Notes for reviewers

  • focus on the cache repository's transaction-time claim/action/payload/lease binding and on the worker's cache-only least-authority port
  • the next slices will consume this foundation; they are intentionally not folded into this review unit

@mira-2026
mira-2026 requested a review from rajohan as a code owner August 8, 2026 14:08
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added cache entry lookup, status reporting, and refresh operations.
    • Added the initial system host cache, including host, memory, uptime, and filesystem data.
    • Added cache freshness, failure tracking, expiration, and bounded status information.
    • Added realtime cache change notifications.
    • Added cache-specific read and write permissions.
  • Bug Fixes
    • Manual “Run now” is now hidden when unavailable.
    • Repeated manual requests are safely replayed or rejected for mismatched idempotency keys.
  • Documentation
    • Updated architecture, progress, and generated schema documentation.

Walkthrough

The PR adds a cache domain with validated contracts, durable SQLite storage, claim-fenced worker persistence, a system.host provider, authenticated tRPC procedures, realtime events, server composition, and frontend schedule handling.

Changes

Cache domain and worker integration

Layer / File(s) Summary
Cache contracts and durable storage
greenfield/src/contracts/*, greenfield/src/server/database/*, greenfield/migrations/*
Adds cache schemas, capabilities, realtime events, database persistence, validation checks, indexes, and migration metadata.
Job definitions and worker execution
greenfield/src/server/domains/jobs/*
Separates job definitions from executors, adds cache-attempt commits, schedules system.host, supports worker execution, and adds manual enqueue idempotency handling.
Cache repository, provider, and service
greenfield/src/server/domains/cache/*
Adds provider registration, system-host collection, claim-fenced cache commits, status projections, refresh enqueueing, error mapping, and cache procedures.
Server, router, and client integration
greenfield/src/app/*, greenfield/src/server/trpc/*, greenfield/src/browser/*
Wires CacheService through server composition and request context, registers tRPC routes, loads browser contracts, and gates manual runs with manualRunAvailable.
End-to-end validation
greenfield/src/**/\*.test.*, greenfield/src/test/parity/*, greenfield/docs/*
Adds contract, repository, service, worker, API, UI, migration, parity, and progress coverage for the cache implementation.

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

Sequence Diagram(s)

sequenceDiagram
  participant WorkerRuntime
  participant JobCoordinator
  participant SystemHostProvider
  participant CacheRepository
  participant RealtimeOutbox
  WorkerRuntime->>JobCoordinator: execute claimed system.host job
  JobCoordinator->>SystemHostProvider: collectSystemHostPayload()
  SystemHostProvider-->>JobCoordinator: validated host payload
  JobCoordinator->>CacheRepository: commitCacheAttempt()
  CacheRepository->>RealtimeOutbox: persist cache.entries event
  CacheRepository-->>JobCoordinator: committed or lost-claim
Loading

Possibly related PRs

Suggested labels: area: frontend

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely identifies the main change: adding the Phase 3 cache foundation.
Description check ✅ Passed The description covers the required summary, behavior, verification, risk, deployment, rollback, and reviewer-focus information.

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.

@mira-2026 mira-2026 added the status: needs-review Ready for human or agent review label Aug 8, 2026
@mira-2026 mira-2026 changed the title mira/greenfield rewrite phase three cache feat(rewrite): add Phase 3 cache foundation Aug 8, 2026
@mira-2026 mira-2026 added type: feature Adds user-visible functionality type: tests Adds or updates automated tests/coverage type: documentation Documentation, README, comments, and operational notes area: backend Backend API, server routes, services, and integrations area: database Database dashboard, Postgres, PgBouncer, or query views area: ops Operational actions, deploys, services, backups, and health labels Aug 8, 2026

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🧹 Nitpick comments (6)
greenfield/src/server/database/schema/cacheEntries.ts (1)

36-41: 🗄️ Data Integrity & Integration | 🔵 Trivial

Plan job-run retention around this RESTRICT foreign key.

last_attempt_run_id is NOT NULL and uses onDelete: "restrict". A job_runs row stays undeletable while any cache entry references it. Each cache key pins at most one run, so the set is bounded, but a job-run pruning or retention task must skip or resolve these referenced runs. Otherwise the delete fails with a foreign-key error.

Consider excluding referenced runs in the retention query, or documenting the constraint next to the retention logic.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@greenfield/src/server/database/schema/cacheEntries.ts` around lines 36 - 41,
The retention logic for job runs must account for the
`cacheEntries.lastAttemptRunId` foreign key, which restricts deletion of
referenced runs. Update the job-run pruning query or deletion flow to skip or
otherwise resolve runs referenced by cache entries, and document this constraint
next to the retention logic if appropriate.
greenfield/src/server/database/validation/cacheEntries.ts (1)

63-76: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Derive predicate inputs from the generated schemas.

CacheEntryRowLike duplicates the row shape instead of using v.InferOutput<typeof cacheEntrySelectSchema> in the select validator and v.InferOutput<typeof cacheEntryInsertSchema> in the insert validator. consecutiveFailures is required in the interface but Drizzle’s insert schema makes consecutive_failures optional because it has .default(0), so the predicate can drift across the SQL column definitions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@greenfield/src/server/database/validation/cacheEntries.ts` around lines 63 -
76, Remove the manually duplicated CacheEntryRowLike interface and derive
predicate input types from the generated schemas: use v.InferOutput<typeof
cacheEntrySelectSchema> for the select validator and v.InferOutput<typeof
cacheEntryInsertSchema> for the insert validator. Update the relevant predicate
signatures to consume those inferred types so schema defaults and SQL column
changes remain reflected automatically.
greenfield/src/server/domains/cache/systemHostProvider.ts (1)

56-87: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add an explicit return type to the exported collector.

collectSystemHostPayload has no declared return type. The type is inferred from v.parse. An explicit annotation keeps the public contract stable and improves declaration output.

Line 20 also references SystemHostFilesystemStats, which is not exported. Consumers that implement SystemHostAdapter cannot name that type. Export it for symmetry with SystemHostAdapter.

♻️ Proposed annotation
-interface SystemHostFilesystemStats {
+export interface SystemHostFilesystemStats {
 export async function collectSystemHostPayload(
     adapter: SystemHostAdapter = defaultSystemHostAdapter
-) {
+): Promise<v.InferOutput<typeof systemHostCachePayloadSchema>> {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@greenfield/src/server/domains/cache/systemHostProvider.ts` around lines 56 -
87, Export the SystemHostFilesystemStats type used by SystemHostAdapter, and add
an explicit return type to the exported collectSystemHostPayload function based
on the validated system host cache payload schema. Keep the existing payload
construction and validation behavior unchanged.
greenfield/src/server/domains/cache/systemHostProvider.test.ts (1)

35-52: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider covering the capacity-consistency rejection.

The tests cover unsafe bigint products and control characters in the hostname. The schema also enforces freeBytes <= totalBytes for disk and memory. Add one case where bavail exceeds blocks, and one where freeMemoryBytes exceeds totalMemoryBytes. These paths are the ones a real host adapter can hit under measurement skew.

The assertion style without await matches the repository convention for Bun matcher types.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@greenfield/src/server/domains/cache/systemHostProvider.test.ts` around lines
35 - 52, Extend the “rejects unsafe byte products and control-bearing host
strings” test to cover capacity consistency: add a rootFilesystem case where
bavail exceeds blocks and assert rejection, plus a memory case where
freeMemoryBytes exceeds totalMemoryBytes and assert rejection. Preserve the
existing non-awaited rejection assertion style and use the existing adapter and
collectSystemHostPayload helpers.

Source: Learnings

greenfield/src/server/domains/jobs/coordinator.ts (1)

660-690: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

manualExposure gates cache persistence; use a dedicated capability instead.

Line 665 allows cache writes only when registration.manualExposure === "cache-write". manualExposure describes who may trigger a manual run. It does not describe whether the action may write cache entries. The two concerns are now coupled. An action that must write cache entries but must not be manually triggered cannot express that state, and it fails at runtime with "Cache attempt persistence is unavailable".

Consider adding an explicit capability field, for example cacheWrite: boolean, to JobActionDefinition, and gate on that field.

♻️ Proposed gate change
                 commitCacheAttempt: async (outcome: JobCacheAttemptCommit) => {
                     if (
-                        registration.manualExposure !== "cache-write" ||
+                        !registration.cacheWrite ||
                         options.commitCacheAttempt === undefined
                     ) {
                         throw new Error("Cache attempt persistence is unavailable");
                     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@greenfield/src/server/domains/jobs/coordinator.ts` around lines 660 - 690,
Decouple cache persistence from manual-run exposure in the commitCacheAttempt
callback passed by the coordinator action: add an explicit cache-write
capability to JobActionDefinition and gate availability using that capability
instead of registration.manualExposure === "cache-write". Update the relevant
action definitions and type plumbing so actions can write cache entries without
being manually triggerable, while preserving the existing unavailable-error
behavior when the capability or commit callback is absent.
greenfield/src/server/domains/cache/repository.test.ts (1)

142-176: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the "updated" realtime operation.

The suite asserts operation: "created" for a first success and covers the failure path. No test commits a second success for an existing key. The existingByKey.get(key) === undefined branch at greenfield/src/server/domains/cache/repository.ts line 350 therefore never produces "updated" under test, and a regression that always emits "created" would pass.

Add one case that commits two successful attempts for system.host and asserts the second realtime row uses operation: "updated".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@greenfield/src/server/domains/cache/repository.test.ts` around lines 142 -
176, Add a repository test covering the existing-key success path by committing
two successful attempts for system.host through fixture.cache.commitAttempt,
then query the realtime event for the second commit and assert its operation is
"updated" while preserving the existing first-commit "created" coverage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@greenfield/migrations/20260804022252_dashboard-foundation/snapshot.json`:
- Line 4: Do not modify the existing 20260804022252_dashboard-foundation
migration or its snapshot id d65c13c5-1ce8-4595-9328-52c607378fa0. Revert the
in-place snapshot change and add a new migration for the schema update,
preserving the original migration checksum for already-deployed environments.

In `@greenfield/src/server/domains/cache/repository.ts`:
- Around line 278-282: Make CacheRepository.commitAttempt async so exceptions
from validateAttemptOutcome and cacheAttemptAuthority become Promise rejections
consistent with its declared return type. Update the corresponding duplicate-key
test in repository.test.ts to capture the returned promise and assert it with
expect(promise).rejects..., without awaiting the assertion.

---

Nitpick comments:
In `@greenfield/src/server/database/schema/cacheEntries.ts`:
- Around line 36-41: The retention logic for job runs must account for the
`cacheEntries.lastAttemptRunId` foreign key, which restricts deletion of
referenced runs. Update the job-run pruning query or deletion flow to skip or
otherwise resolve runs referenced by cache entries, and document this constraint
next to the retention logic if appropriate.

In `@greenfield/src/server/database/validation/cacheEntries.ts`:
- Around line 63-76: Remove the manually duplicated CacheEntryRowLike interface
and derive predicate input types from the generated schemas: use
v.InferOutput<typeof cacheEntrySelectSchema> for the select validator and
v.InferOutput<typeof cacheEntryInsertSchema> for the insert validator. Update
the relevant predicate signatures to consume those inferred types so schema
defaults and SQL column changes remain reflected automatically.

In `@greenfield/src/server/domains/cache/repository.test.ts`:
- Around line 142-176: Add a repository test covering the existing-key success
path by committing two successful attempts for system.host through
fixture.cache.commitAttempt, then query the realtime event for the second commit
and assert its operation is "updated" while preserving the existing first-commit
"created" coverage.

In `@greenfield/src/server/domains/cache/systemHostProvider.test.ts`:
- Around line 35-52: Extend the “rejects unsafe byte products and
control-bearing host strings” test to cover capacity consistency: add a
rootFilesystem case where bavail exceeds blocks and assert rejection, plus a
memory case where freeMemoryBytes exceeds totalMemoryBytes and assert rejection.
Preserve the existing non-awaited rejection assertion style and use the existing
adapter and collectSystemHostPayload helpers.

In `@greenfield/src/server/domains/cache/systemHostProvider.ts`:
- Around line 56-87: Export the SystemHostFilesystemStats type used by
SystemHostAdapter, and add an explicit return type to the exported
collectSystemHostPayload function based on the validated system host cache
payload schema. Keep the existing payload construction and validation behavior
unchanged.

In `@greenfield/src/server/domains/jobs/coordinator.ts`:
- Around line 660-690: Decouple cache persistence from manual-run exposure in
the commitCacheAttempt callback passed by the coordinator action: add an
explicit cache-write capability to JobActionDefinition and gate availability
using that capability instead of registration.manualExposure === "cache-write".
Update the relevant action definitions and type plumbing so actions can write
cache entries without being manually triggerable, while preserving the existing
unavailable-error behavior when the capability or commit callback is absent.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ea6d8e0a-e444-4862-932e-5fbc30acc64c

📥 Commits

Reviewing files that changed from the base of the PR and between c6ab45a and 58efc2b.

⛔ Files ignored due to path filters (21)
  • greenfield/docs/generated/procedures.md is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/realtime-events.md is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/schemas/automationSecurity.createPrincipal.input.schema.json is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/schemas/automationSecurity.createPrincipal.output.schema.json is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/schemas/automationSecurity.disablePrincipal.output.schema.json is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/schemas/automationSecurity.listPrincipals.output.schema.json is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/schemas/automationSecurity.replaceCapabilities.input.schema.json is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/schemas/automationSecurity.replaceCapabilities.output.schema.json is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/schemas/cache.entries.realtime.payload.schema.json is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/schemas/cache.getEntry.input.schema.json is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/schemas/cache.getEntry.output.schema.json is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/schemas/cache.getStatus.input.schema.json is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/schemas/cache.getStatus.output.schema.json is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/schemas/cache.refreshEntry.input.schema.json is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/schemas/cache.refreshEntry.output.schema.json is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/schemas/events.stream.input.schema.json is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/schemas/events.stream.output.schema.json is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/schemas/schedules.get.output.schema.json is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/schemas/schedules.list.output.schema.json is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/schemas/schedules.update.output.schema.json is excluded by !**/generated/** and included by **/*
  • greenfield/docs/generated/schemas/securityAudit.listEvents.output.schema.json is excluded by !**/generated/** and included by **/*
📒 Files selected for processing (77)
  • greenfield/docs/architecture/greenfield-rewrite/data-and-security.md
  • greenfield/docs/architecture/greenfield-rewrite/progress.md
  • greenfield/migrations/20260804022252_dashboard-foundation/migration.sql
  • greenfield/migrations/20260804022252_dashboard-foundation/snapshot.json
  • greenfield/scripts/documentation/artifacts.test.ts
  • greenfield/scripts/documentation/jsonSchema.test.ts
  • greenfield/scripts/documentation/jsonSchema.ts
  • greenfield/src/app/dashboardServer.test.ts
  • greenfield/src/app/dashboardServer.ts
  • greenfield/src/app/server.ts
  • greenfield/src/app/trpcHttpHandler.ts
  • greenfield/src/browser/api/trpcClient.test.ts
  • greenfield/src/browser/api/trpcClient.ts
  • greenfield/src/browser/jobs/JobsRoute.test.tsx
  • greenfield/src/browser/jobs/ScheduleDetail.tsx
  • greenfield/src/browser/jobs/ScheduleDetailStateReplay.test.tsx
  • greenfield/src/browser/jobs/ScheduleEditor.test.tsx
  • greenfield/src/browser/jobs/ScheduleTable.test.tsx
  • greenfield/src/browser/jobs/jobMutations.test.tsx
  • greenfield/src/browser/jobs/jobQueries.test.ts
  • greenfield/src/browser/jobs/scheduleEditorForm.test.ts
  • greenfield/src/browser/jobs/testSupport/ScheduleDetail.tsx
  • greenfield/src/contracts/cache.test.ts
  • greenfield/src/contracts/cache.ts
  • greenfield/src/contracts/cacheRealtime.test.ts
  • greenfield/src/contracts/cacheRealtime.ts
  • greenfield/src/contracts/contractRegistry.ts
  • greenfield/src/contracts/events.test.ts
  • greenfield/src/contracts/events.ts
  • greenfield/src/contracts/jobModel.test.ts
  • greenfield/src/contracts/jobModel.ts
  • greenfield/src/contracts/schedules.test.ts
  • greenfield/src/contracts/security.test.ts
  • greenfield/src/contracts/security.ts
  • greenfield/src/server/database/migrations/migrationGraph.test.ts
  • greenfield/src/server/database/schema/automationPrincipalCapabilities.ts
  • greenfield/src/server/database/schema/cacheEntries.test.ts
  • greenfield/src/server/database/schema/cacheEntries.ts
  • greenfield/src/server/database/schema/drizzleSchema.ts
  • greenfield/src/server/database/validation/cacheEntries.test.ts
  • greenfield/src/server/database/validation/cacheEntries.ts
  • greenfield/src/server/domains/cache/errors.ts
  • greenfield/src/server/domains/cache/procedures.test.ts
  • greenfield/src/server/domains/cache/procedures.ts
  • greenfield/src/server/domains/cache/providerRegistry.ts
  • greenfield/src/server/domains/cache/records.ts
  • greenfield/src/server/domains/cache/repository.test.ts
  • greenfield/src/server/domains/cache/repository.ts
  • greenfield/src/server/domains/cache/routes.ts
  • greenfield/src/server/domains/cache/service.test.ts
  • greenfield/src/server/domains/cache/service.ts
  • greenfield/src/server/domains/cache/systemHostProvider.test.ts
  • greenfield/src/server/domains/cache/systemHostProvider.ts
  • greenfield/src/server/domains/cache/testSupport/service.ts
  • greenfield/src/server/domains/jobs/actionExecutors.test.ts
  • greenfield/src/server/domains/jobs/actionExecutors.ts
  • greenfield/src/server/domains/jobs/actionRegistry.test.ts
  • greenfield/src/server/domains/jobs/actionRegistry.ts
  • greenfield/src/server/domains/jobs/coordinator.test.ts
  • greenfield/src/server/domains/jobs/coordinator.ts
  • greenfield/src/server/domains/jobs/manualEnqueue.ts
  • greenfield/src/server/domains/jobs/records.ts
  • greenfield/src/server/domains/jobs/registeredSchedule.ts
  • greenfield/src/server/domains/jobs/repository.ts
  • greenfield/src/server/domains/jobs/service.test.ts
  • greenfield/src/server/domains/jobs/service.ts
  • greenfield/src/server/domains/jobs/workerRuntime.test.ts
  • greenfield/src/server/domains/jobs/workerRuntime.ts
  • greenfield/src/server/domains/jobs/workerSystem.test.ts
  • greenfield/src/server/test/support/requestContext.ts
  • greenfield/src/server/trpc/appRouter.ts
  • greenfield/src/server/trpc/context.test.ts
  • greenfield/src/server/trpc/context.ts
  • greenfield/src/server/trpc/procedureErrorPolicy.ts
  • greenfield/src/shared/databaseMigrationManifest.ts
  • greenfield/src/test/parity/fixtures/greenfield-contracts.json
  • greenfield/src/test/parity/fixtures/legacy-endpoints.json
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: dashboard-checks
  • GitHub Check: Analyze JavaScript and TypeScript
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-08-07T17:05:36.638Z
Learnt from: mira-2026
Repo: rajohan/Mira-Dashboard PR: 397
File: greenfield/src/server/domains/agents/service.test.ts:225-239
Timestamp: 2026-08-07T17:05:36.638Z
Learning: In Bun test files, write rejection assertions as `expect(promise).rejects...` without `await`. The repository's installed matcher types return `void`, and ESLint's `typescript(await-thenable)` rule rejects awaiting these matcher assertions.

Applied to files:

  • greenfield/scripts/documentation/artifacts.test.ts
  • greenfield/src/browser/jobs/scheduleEditorForm.test.ts
  • greenfield/src/browser/api/trpcClient.test.ts
  • greenfield/src/contracts/cache.test.ts
  • greenfield/src/contracts/jobModel.test.ts
  • greenfield/src/contracts/events.test.ts
  • greenfield/src/server/database/schema/cacheEntries.test.ts
  • greenfield/src/app/dashboardServer.test.ts
  • greenfield/src/contracts/cacheRealtime.test.ts
  • greenfield/src/server/database/migrations/migrationGraph.test.ts
  • greenfield/src/browser/jobs/jobQueries.test.ts
  • greenfield/src/server/database/validation/cacheEntries.test.ts
  • greenfield/scripts/documentation/jsonSchema.test.ts
  • greenfield/src/server/domains/cache/procedures.test.ts
  • greenfield/src/server/domains/jobs/workerRuntime.test.ts
  • greenfield/src/server/domains/jobs/actionRegistry.test.ts
  • greenfield/src/contracts/schedules.test.ts
  • greenfield/src/server/domains/jobs/workerSystem.test.ts
  • greenfield/src/server/domains/jobs/actionExecutors.test.ts
  • greenfield/src/server/domains/jobs/service.test.ts
  • greenfield/src/server/domains/cache/service.test.ts
  • greenfield/src/server/domains/cache/repository.test.ts
  • greenfield/src/contracts/security.test.ts
  • greenfield/src/server/domains/cache/systemHostProvider.test.ts
  • greenfield/src/server/domains/jobs/coordinator.test.ts
  • greenfield/src/server/trpc/context.test.ts
📚 Learning: 2026-08-07T18:47:49.639Z
Learnt from: mira-2026
Repo: rajohan/Mira-Dashboard PR: 398
File: greenfield/src/server/domains/monitoring/catalogErrors.ts:3-3
Timestamp: 2026-08-07T18:47:49.639Z
Learning: In the greenfield TypeScript application, use the pinned Effect version 4.0.0-beta.104 API. Preserve `Schema.Literals` for readonly literal tuples and arrays, and do not replace it with variadic `Schema.Literal(...)` unless the replacement has been validated against the pinned Effect version.

Applied to files:

  • greenfield/scripts/documentation/artifacts.test.ts
  • greenfield/src/server/database/schema/automationPrincipalCapabilities.ts
  • greenfield/src/browser/jobs/scheduleEditorForm.test.ts
  • greenfield/src/server/database/schema/drizzleSchema.ts
  • greenfield/src/server/trpc/appRouter.ts
  • greenfield/src/browser/api/trpcClient.test.ts
  • greenfield/src/contracts/cache.test.ts
  • greenfield/src/server/domains/cache/testSupport/service.ts
  • greenfield/src/contracts/jobModel.test.ts
  • greenfield/src/server/domains/cache/procedures.ts
  • greenfield/src/contracts/events.test.ts
  • greenfield/src/server/database/schema/cacheEntries.test.ts
  • greenfield/src/app/dashboardServer.test.ts
  • greenfield/src/contracts/jobModel.ts
  • greenfield/src/server/trpc/context.ts
  • greenfield/src/server/domains/jobs/manualEnqueue.ts
  • greenfield/src/contracts/cacheRealtime.test.ts
  • greenfield/src/server/database/migrations/migrationGraph.test.ts
  • greenfield/src/browser/jobs/jobQueries.test.ts
  • greenfield/src/contracts/cacheRealtime.ts
  • greenfield/src/server/domains/cache/systemHostProvider.ts
  • greenfield/src/server/test/support/requestContext.ts
  • greenfield/src/server/database/validation/cacheEntries.test.ts
  • greenfield/scripts/documentation/jsonSchema.test.ts
  • greenfield/src/server/domains/cache/procedures.test.ts
  • greenfield/src/server/domains/jobs/records.ts
  • greenfield/src/app/server.ts
  • greenfield/src/contracts/security.ts
  • greenfield/src/server/domains/cache/records.ts
  • greenfield/src/server/database/validation/cacheEntries.ts
  • greenfield/src/server/domains/cache/routes.ts
  • greenfield/src/shared/databaseMigrationManifest.ts
  • greenfield/src/server/domains/jobs/workerRuntime.test.ts
  • greenfield/src/server/trpc/procedureErrorPolicy.ts
  • greenfield/src/server/domains/jobs/actionRegistry.test.ts
  • greenfield/scripts/documentation/jsonSchema.ts
  • greenfield/src/contracts/schedules.test.ts
  • greenfield/src/server/domains/jobs/workerSystem.test.ts
  • greenfield/src/server/domains/jobs/actionExecutors.test.ts
  • greenfield/src/browser/api/trpcClient.ts
  • greenfield/src/server/database/schema/cacheEntries.ts
  • greenfield/src/server/domains/cache/errors.ts
  • greenfield/src/server/domains/jobs/service.test.ts
  • greenfield/src/server/domains/cache/service.test.ts
  • greenfield/src/server/domains/jobs/workerRuntime.ts
  • greenfield/src/contracts/contractRegistry.ts
  • greenfield/src/app/trpcHttpHandler.ts
  • greenfield/src/server/domains/cache/repository.test.ts
  • greenfield/src/contracts/events.ts
  • greenfield/src/server/domains/cache/providerRegistry.ts
  • greenfield/src/app/dashboardServer.ts
  • greenfield/src/contracts/security.test.ts
  • greenfield/src/server/domains/jobs/actionExecutors.ts
  • greenfield/src/server/domains/cache/systemHostProvider.test.ts
  • greenfield/src/server/domains/jobs/repository.ts
  • greenfield/src/server/domains/jobs/coordinator.test.ts
  • greenfield/src/server/domains/cache/repository.ts
  • greenfield/src/server/domains/cache/service.ts
  • greenfield/src/server/domains/jobs/coordinator.ts
  • greenfield/src/server/domains/jobs/registeredSchedule.ts
  • greenfield/src/server/domains/jobs/service.ts
  • greenfield/src/server/trpc/context.test.ts
  • greenfield/src/contracts/cache.ts
  • greenfield/src/server/domains/jobs/actionRegistry.ts
🪛 Betterleaks (1.7.3)
greenfield/src/contracts/cache.test.ts

[high] 137-137: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


[high] 144-144: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🔇 Additional comments (88)
greenfield/src/server/domains/jobs/actionExecutors.test.ts (1)

1-117: LGTM!

greenfield/src/server/domains/jobs/actionRegistry.test.ts (1)

4-26: LGTM!

Also applies to: 39-39, 49-51, 64-75

greenfield/src/server/domains/jobs/coordinator.test.ts (1)

7-12: LGTM!

Also applies to: 445-452, 870-870, 1260-1260, 1473-1478, 1588-1588, 1618-1618, 1645-1645, 1678-1678, 1702-1782, 1823-1823, 1887-1887, 1936-1936

greenfield/src/server/trpc/context.test.ts (1)

4-4: LGTM!

Also applies to: 41-41, 70-70, 104-104, 136-136, 179-179

greenfield/docs/architecture/greenfield-rewrite/progress.md (1)

10-18: LGTM!

Also applies to: 972-999

greenfield/docs/architecture/greenfield-rewrite/data-and-security.md (1)

210-210: LGTM!

greenfield/migrations/20260804022252_dashboard-foundation/snapshot.json (1)

45-48: LGTM!

Also applies to: 965-1124, 3765-3779, 4095-4103, 4832-4853, 6163-6163, 6198-6287

greenfield/src/contracts/cache.ts (1)

20-120: LGTM!

Also applies to: 122-199, 203-263, 265-308, 310-350, 352-423

greenfield/src/contracts/cache.test.ts (1)

13-32: LGTM!

Also applies to: 34-84, 86-132, 134-173

greenfield/src/contracts/jobModel.test.ts (1)

311-311: LGTM!

greenfield/src/server/database/schema/cacheEntries.ts (1)

25-35: LGTM!

Also applies to: 42-51, 52-123

greenfield/src/server/database/schema/cacheEntries.test.ts (1)

9-61: LGTM!

greenfield/src/server/database/validation/cacheEntries.ts (2)

44-61: LGTM!

Also applies to: 82-117, 119-132


22-33: 🩺 Stability & Availability

No change needed.

parseJsonText already prevents JSON.parse failures from escaping the validation predicate by catching syntax errors and returning undefined.

			> Likely an incorrect or invalid review comment.
greenfield/src/contracts/jobModel.ts (1)

717-717: 🗄️ Data Integrity & Integration

No change needed: ScheduleSummary always sets manualRunAvailable.

toScheduleSummary() maps manualRunAvailable from registered schedule exposure state, so schedule producers pass it through before schema validation.

greenfield/migrations/20260804022252_dashboard-foundation/migration.sql (1)

142-142: LGTM!

Also applies to: 159-193, 416-416

greenfield/scripts/documentation/artifacts.test.ts (1)

196-196: LGTM!

greenfield/scripts/documentation/jsonSchema.ts (1)

40-49: LGTM!

Also applies to: 167-198

greenfield/src/contracts/cacheRealtime.test.ts (1)

1-53: LGTM!

greenfield/src/contracts/cacheRealtime.ts (1)

1-72: LGTM!

greenfield/src/contracts/contractRegistry.ts (1)

6-7: LGTM!

Also applies to: 34-34, 85-85

greenfield/src/contracts/events.test.ts (1)

5-5: LGTM!

Also applies to: 23-23, 96-124

greenfield/src/contracts/events.ts (1)

12-16: LGTM!

Also applies to: 39-39, 57-57, 67-67, 108-108

greenfield/scripts/documentation/jsonSchema.test.ts (1)

142-143: LGTM!

Also applies to: 155-155

greenfield/src/contracts/schedules.test.ts (1)

26-26: LGTM!

greenfield/src/contracts/security.test.ts (1)

21-22: LGTM!

greenfield/src/contracts/security.ts (1)

97-98: LGTM!

greenfield/src/server/database/migrations/migrationGraph.test.ts (1)

42-42: LGTM!

Also applies to: 199-199

greenfield/src/server/database/schema/automationPrincipalCapabilities.ts (1)

21-21: LGTM!

greenfield/src/server/database/schema/drizzleSchema.ts (1)

14-14: LGTM!

greenfield/src/server/database/validation/cacheEntries.test.ts (1)

1-76: LGTM!

greenfield/src/server/domains/jobs/actionRegistry.ts (4)

27-60: LGTM!

Also applies to: 79-93, 96-113


115-172: LGTM!


174-217: LGTM!


219-247: LGTM!

Also applies to: 255-257

greenfield/src/server/domains/jobs/actionExecutors.ts (4)

15-49: LGTM!


125-191: LGTM!


91-121: 🗄️ Data Integrity & Integration

No change needed for jobRunResultSchema shape.

jobRunResultSchema uses jsonObjectSchema, which accepts bounded JSON object fields, so { cacheKeys, completedAtMs } is not rejected by coordinator result validation.

			> Likely an incorrect or invalid review comment.

66-90: 🩺 Stability & Availability

No change needed for these failure-path cases.

Effect.catch is valid in effect 4.0.0-beta.104, and the coordinator handles JobClaimLostError from a lost commitCacheAttempt via the existing claim-lost settlement path.

greenfield/src/server/domains/jobs/coordinator.ts (2)

15-21: LGTM!

Also applies to: 101-120, 324-330, 528-539, 1021-1021, 1050-1052


164-167: 🎯 Functional Correctness

No prod callers omitted findAction and no other default resolver is needed.

greenfield/src/server/domains/jobs/workerRuntime.ts (1)

11-13: LGTM!

Also applies to: 44-57, 89-94, 231-239

greenfield/src/server/domains/jobs/workerSystem.test.ts (1)

3-14: LGTM!

Also applies to: 67-69, 159-263

greenfield/src/server/domains/cache/systemHostProvider.ts (1)

1-49: LGTM!

greenfield/src/server/domains/cache/systemHostProvider.test.ts (1)

1-33: LGTM!

greenfield/src/app/dashboardServer.test.ts (2)

9-9: LGTM!

Also applies to: 305-318


320-332: 🎯 Functional Correctness

No change needed. cache.getStatus accepts emptyInputSchema, which accepts { } via v.optional(v.strictObject({}), {}); { json: {} } parses through that optional wrapper, and cacheStatusBody contains result only once.

greenfield/src/test/parity/fixtures/greenfield-contracts.json (1)

173-184: LGTM!

greenfield/src/test/parity/fixtures/legacy-endpoints.json (1)

276-276: LGTM!

Also applies to: 302-302, 1416-1416

greenfield/src/shared/databaseMigrationManifest.ts (1)

15-18: 🗄️ Data Integrity & Integration

No action needed. The migration loader treats a manifest and migration artifact change as a checksum mismatch before runtime startup, so a database with the old checksum cannot proceed silently.

greenfield/src/server/domains/jobs/manualEnqueue.ts (1)

1-36: LGTM!

greenfield/src/server/domains/jobs/records.ts (1)

30-30: LGTM!

Also applies to: 204-206

greenfield/src/server/domains/jobs/registeredSchedule.ts (1)

1-1: LGTM!

Also applies to: 12-19

greenfield/src/server/domains/jobs/repository.ts (1)

425-429: LGTM!

Also applies to: 712-729, 1184-1184, 1332-1332, 2503-2514

greenfield/src/server/domains/jobs/service.test.ts (1)

219-238: LGTM!

greenfield/src/server/domains/jobs/service.ts (1)

38-49: LGTM!

Also applies to: 371-375, 477-503, 562-562, 879-880

greenfield/src/browser/jobs/JobsRoute.test.tsx (1)

145-145: LGTM!

greenfield/src/browser/jobs/ScheduleEditor.test.tsx (1)

20-20: LGTM!

greenfield/src/browser/jobs/ScheduleTable.test.tsx (1)

18-18: LGTM!

greenfield/src/browser/jobs/jobMutations.test.tsx (1)

147-147: LGTM!

greenfield/src/browser/jobs/jobQueries.test.ts (1)

74-74: LGTM!

greenfield/src/browser/jobs/scheduleEditorForm.test.ts (1)

45-45: LGTM!

greenfield/src/server/domains/jobs/workerRuntime.test.ts (1)

6-6: LGTM!

Also applies to: 78-87, 199-199

greenfield/src/server/domains/cache/providerRegistry.ts (1)

1-100: LGTM!

greenfield/src/server/domains/cache/records.ts (1)

1-74: LGTM!

greenfield/src/server/domains/cache/repository.ts (3)

362-390: LGTM!


89-116: 🗄️ Data Integrity & Integration

No change needed. The scheduled run payloadJson is already stored from schedule.actionPayloadJson, which is defined by JSON.stringify(registration.actionPayload) for cached schedules.


270-275: 🗄️ Data Integrity & Integration

Confirm the transaction config argument is honored, and narrow the double type assertion.

database.transaction.bind(database) as unknown as <T>(...) removes Drizzle’s own typings for both the callback and the config object. If SQLiteBunDatabase.transaction in drizzle-orm 1.0.0-rc.4 does not accept a second config argument, { behavior: "immediate" } is ignored at runtime and the claim-fence code runs in a deferred transaction. Use the narrowest cast that still compiles.

greenfield/src/server/domains/cache/repository.test.ts (1)

386-430: LGTM!

greenfield/src/server/trpc/appRouter.ts (1)

2-2: LGTM!

Also applies to: 50-50, 69-69

greenfield/src/server/trpc/procedureErrorPolicy.ts (1)

202-210: LGTM!

greenfield/src/browser/api/trpcClient.ts (1)

75-78: LGTM!

greenfield/src/browser/api/trpcClient.test.ts (1)

172-193: LGTM!

greenfield/src/browser/jobs/ScheduleDetail.tsx (1)

264-278: LGTM!

greenfield/src/browser/jobs/ScheduleDetailStateReplay.test.tsx (1)

15-21: LGTM!

greenfield/src/browser/jobs/testSupport/ScheduleDetail.tsx (1)

19-19: LGTM!

Also applies to: 53-53

greenfield/src/server/domains/cache/errors.ts (1)

1-17: LGTM!

greenfield/src/server/domains/cache/routes.ts (1)

1-56: LGTM!

greenfield/src/server/domains/cache/service.ts (1)

1-332: LGTM!

greenfield/src/server/domains/cache/testSupport/service.ts (1)

1-26: LGTM!

greenfield/src/server/domains/cache/procedures.ts (1)

1-8: LGTM!

greenfield/src/server/domains/cache/procedures.test.ts (1)

1-143: LGTM!

greenfield/src/server/domains/cache/service.test.ts (1)

1-199: LGTM!

greenfield/src/app/dashboardServer.ts (1)

8-9: LGTM!

Also applies to: 93-93, 297-302, 325-325

greenfield/src/app/server.ts (1)

6-6: LGTM!

Also applies to: 138-138, 188-188

greenfield/src/app/trpcHttpHandler.ts (1)

4-4: LGTM!

Also applies to: 42-42, 222-222

greenfield/src/server/test/support/requestContext.ts (1)

10-11: LGTM!

Also applies to: 399-399, 428-428, 520-520, 547-547

greenfield/src/server/trpc/context.ts (1)

3-3: LGTM!

Also applies to: 38-38, 60-60, 93-93

Comment thread greenfield/src/server/domains/cache/repository.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: backend Backend API, server routes, services, and integrations area: database Database dashboard, Postgres, PgBouncer, or query views area: ops Operational actions, deploys, services, backups, and health status: needs-review Ready for human or agent review type: documentation Documentation, README, comments, and operational notes type: feature Adds user-visible functionality type: tests Adds or updates automated tests/coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant