Skip to content

fix(reviews): share monitor evaluation results - #8664

Open
iscekic wants to merge 10 commits into
mainfrom
drain/review-monitor-refresh
Open

iscekic wants to merge 10 commits into
mainfrom
drain/review-monitor-refresh

Conversation

@iscekic

@iscekic iscekic commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Evidence

Evidence: demonstrated — a local Next.js application against an isolated local PostgreSQL instance, exercised at this head: requests with no credential and with a wrong credential returned the rejected shape, the configured credential returned the healthy shape, a second authorized call inside the shared interval returned the identical evaluation timestamp with no database statements logged for it (a control statement confirmed logging was live), and a fresh evaluation after the interval returned the alert result for seeded recent reviews. The regenerated migration applied on a fresh database and the detector window query planned as an index scan on the new index.

Changes

  • Define the monitor credential through the existing server environment configuration.
  • Share a 60-second evaluation result per application instance, including its response status and timestamp.
  • Add a concurrent index for the detector time window while retaining timestamp fallback semantics and alert thresholds.
  • Document owner-operated configuration, deployment, and rotation.

Verification

At the current head:

  • The branch migration is generated at the next free sequence position after the merged default branch (0302_regular_maverick), its generated DDL is unchanged, and a subsequent drizzle-kit generate reports no schema drift.
  • That migration applied on top of the merged default-branch migration chain on a fresh database, and the bootstrap check passed; the resulting index exists with the expected definition and is valid and ready.
  • Detector window query plan on the merged tree: with sequential scans disabled on the local instance, the planner resolves the window predicate through a bitmap index scan on the new index, which confirms the index predicate matches the detector filter. This is a usability check, not a cost comparison against production data.
  • Database package suite: 50 tests passed. Focused route and detector suites: 41 tests passed.
  • Running web application against that database:
    • No credential and a wrong credential each returned the rejected shape with status 401.
    • The configured credential returned status 200 with the healthy shape.
    • The first evaluation in the interval logged six detector statements; a second authorized call two seconds later returned the same evaluation timestamp and logged none, while a control statement was recorded on the same connection log.
    • After the interval elapsed, a fresh evaluation ran and returned status 503 with the alert result for the seeded recent reviews.
  • Carried over from the earlier head whose index DDL is identical (this head only renumbered the migration): over a large synthetic history the index resolved the recent rows by bitmap index scan in a few milliseconds; not re-measured at this head.
  • No visual surface changed. Production monitor configuration was not exercised or modified.

Production prerequisites

Apply packages/db/src/migrations/0302_regular_maverick.sql (the detector window index) before application deployment. The owner must run pnpm web:env set CODE_REVIEW_HEALTH_SECRET and coordinate the application deployment with the external monitor's bearer header update. See ENVIRONMENT.md.

Proxy answers

The owner's proxy gave these answers in the owner's place.

  1. Question: Monitor contract: Plan decision: use a dedicated CODE_REVIEW_HEALTH_SECRET with Authorization: Bearer, preserve detector policy, add a 60-second per-instance shared evaluation, and document an operator-coordinated provisioning/deploy/monitor update. The monitor configuration is outside this repository, and this session will not change production. Which transport and rollout contract should this PR adopt?
    Answer: Bearer header; coordinated cutover
    Confidence: 0.60 · Precedent: Replace old paths instead of keeping them alongside: session ad6a3f589364, "alongside? why not instead?"; record any real external gap in the PR: session 55c9c80332a7
  2. Question: Review recovery: The merge commit has green CI and no current-head Kilo Code Review check; the prior head's review was approved, and its generated detector migration matches byte-for-byte after index regeneration. How should I resolve the missing current-head review?
    Answer: Retry on review page
    Confidence: 0.85 · Precedent: Never accept "blocked" or "failed" as an end state: session 55c9c80332a7, "blocked is not an acceptable end state"; Do the least work possible: session 00eb2a1d3e4b, "do not redo work that was already done"
  3. Question: Review fallback: The review page redirects this VM to sign-in, so I cannot use its retry action. The merge commit adds main plus the regenerated migration; its DDL is byte-identical to the reviewed migration, and the prior review summary is clean. How should I proceed?
    Answer: Use prior clean review
    Confidence: 0.80 · Precedent: Regrade only after meaningful changes: session 55c9c80332a7, "regrading should only happen if there were meaningful changes". A main merge with byte-identical migration DDL is not meaningful. Also, blocked is not an acceptable end state: "blocked is not an acceptable end state".

@iscekic iscekic added drain Work item from the findings drain janitor:trust Janitor finding: trust boundary hardening labels Oct 22, 2026
@kilo-code-bot

kilo-code-bot Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The new delta renames the redundant code-review window index migration to 0302_regular_maverick after merged main's 0300/0301, with byte-identical DDL, an intact snapshot prevId chain, a unique journal index sequence, and an index name still matching the detector query.

Assumptions: [INFERENCE] Migration apply and drizzle-kit generate were not executed in this read-only review. The large incremental range includes merged main changes (device auth, contributor credits, mobile/i18n, etc.) that this PR did not author; only the migration renumbering and PR body update are new PR changes. Generated snapshot/journal contents were checked for chain and index consistency rather than line-reviewed. The external monitor bearer-header cutover and CODE_REVIEW_HEALTH_SECRET provisioning remain operational steps documented in ENVIRONMENT.md.

Verification

  • _journal.json indexes are contiguous 0..302 with 0302_regular_maverick appended after main's 0300/0301 and monotonically increasing when.
  • 0302_snapshot.json prevId equals 0301_snapshot.json id, and the snapshot carries both main's new columns and the new index.
  • idx_cloud_agent_code_reviews_started_at_effective appears only in 0302_regular_maverick.sql, its snapshot, and packages/db/src/schema.ts; no orphaned 0300_secret_the_phantom.sql remains.
  • The migration SQL is a 100% rename of the previously reviewed file, and its expression/predicate still matches startedReviewsCteSql in detectors.ts.
Files Reviewed (11 files)
  • .env.local.example
  • ENVIRONMENT.md
  • apps/web/src/app/api/code-reviews/up/route.ts
  • apps/web/src/app/api/code-reviews/up/route.test.ts
  • apps/web/src/lib/code-reviews/alerting/detectors.ts
  • apps/web/src/lib/code-reviews/alerting/detectors.test.ts
  • packages/db/src/migrations/0302_regular_maverick.sql
  • packages/db/src/migrations/meta/0302_snapshot.json
  • packages/db/src/migrations/meta/_journal.json
  • packages/db/src/schema.ts
  • packages/web-shared/src/lib/config.server.ts
Previous Review Summaries (3 snapshots, latest commit 59a98ef)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 59a98ef)

Status: No Issues Found | Recommendation: Merge

Executive Summary

The incremental delta regenerates the redundant code-review window index on the merged tree as migration 0300, after main's 0299_lame_mojo, with an intact snapshot prevId chain, no duplicate index name, and unchanged detector/route code that still matches the index expression.

Assumptions: [INFERENCE] Migration apply was not executed in this read-only review. The generated SQL is identical to the previously reviewed migration apart from the file name, the index name appears in exactly one migration plus packages/db/src/schema.ts, and the journal/snapshot files are generated artifacts excluded from review. The 0299/environment-table changes in the incremental range come from merged main, not this PR, and were not treated as PR findings. The external monitor bearer-header cutover and CODE_REVIEW_HEALTH_SECRET provisioning remain operational steps documented in ENVIRONMENT.md.

Files Reviewed (11 files)
  • .env.local.example
  • ENVIRONMENT.md
  • apps/web/src/app/api/code-reviews/up/route.ts
  • apps/web/src/app/api/code-reviews/up/route.test.ts
  • apps/web/src/lib/code-reviews/alerting/detectors.ts
  • apps/web/src/lib/code-reviews/alerting/detectors.test.ts
  • packages/db/src/migrations/0300_secret_the_phantom.sql
  • packages/db/src/migrations/meta/0300_snapshot.json
  • packages/db/src/migrations/meta/_journal.json
  • packages/db/src/schema.ts
  • packages/web-shared/src/lib/config.server.ts

Previous review (commit 1c18d66)

Status: No Issues Found | Recommendation: Merge

Executive Summary

The incremental delta renumbers the redundant code-review window index from migration 0296 to 0299 and it now matches the merged journal, schema definition, and existing COMMIT; CREATE INDEX CONCURRENTLY ...; BEGIN; pattern with no duplicate index name.

Assumptions: [INFERENCE] Migration apply was not executed in this read-only review; the SQL is byte-identical to the previously reviewed migration apart from the file name, the index name appears in exactly one migration, and the snapshot/journal files are generated artifacts excluded from review.

Files Reviewed (11 files)
  • .env.local.example
  • ENVIRONMENT.md
  • apps/web/src/app/api/code-reviews/up/route.ts
  • apps/web/src/app/api/code-reviews/up/route.test.ts
  • apps/web/src/lib/code-reviews/alerting/detectors.ts
  • apps/web/src/lib/code-reviews/alerting/detectors.test.ts
  • packages/db/src/migrations/0299_tidy_grey_gargoyle.sql
  • packages/db/src/migrations/meta/0299_snapshot.json
  • packages/db/src/migrations/meta/_journal.json
  • packages/db/src/schema.ts
  • packages/web-shared/src/lib/config.server.ts

Previous review (commit 347dd40)

Status: No Issues Found | Recommendation: Merge

Executive Summary

The monitor endpoint now uses a dedicated bearer secret with timing-safe comparison, a 60-second per-instance cache, and a matching partial expression index; the detector SQL rewrite preserves the prior window/fallback semantics.

Assumptions: [INFERENCE] The external monitor's bearer-header cutover and CODE_REVIEW_HEALTH_SECRET provisioning in production are operational steps outside the repository, as documented in ENVIRONMENT.md; stale monitor configuration would yield 401s. Migration execution was not run in this read-only review, but the COMMIT; CREATE INDEX CONCURRENTLY ...; BEGIN; pattern matches existing migrations (e.g. 0272, 0278), the snapshot diff is limited to the new index, and the index predicate/expression matches the detector query exactly. Promise.withResolvers used in tests is supported by the repo's Node >=24 engine.

Files Reviewed (11 files)
  • .env.local.example
  • ENVIRONMENT.md
  • apps/web/src/app/api/code-reviews/up/route.ts
  • apps/web/src/app/api/code-reviews/up/route.test.ts
  • apps/web/src/lib/code-reviews/alerting/detectors.ts
  • apps/web/src/lib/code-reviews/alerting/detectors.test.ts
  • packages/db/src/migrations/0296_jittery_sersi.sql
  • packages/db/src/migrations/meta/0296_snapshot.json
  • packages/db/src/migrations/meta/_journal.json
  • packages/db/src/schema.ts
  • packages/web-shared/src/lib/config.server.ts

Reviewed by deepseek-flash-latest · Input: 63.7K · Output: 6.6K · Cached: 557.6K

Review guidance: REVIEW.md from base branch main

@iscekic iscekic added merge:human Substantive functional risk requires human review. intent:ok Janitor change confirmed as a real bug fix, not intended behavior needs:prod-action Prod prerequisite (env var, secret, firewall rule, config) needed before merge labels Oct 22, 2026
…refresh

# Conflicts:
#	packages/db/src/migrations/meta/0296_snapshot.json
#	packages/db/src/migrations/meta/_journal.json
@iscekic iscekic added merge:human Substantive functional risk requires human review. merge:blocked:judge-unavailable Risk assessment unavailable merge:bot Bot-owned review; merge when ready once readiness passes and a review approves. and removed merge:human Substantive functional risk requires human review. merge:blocked:judge-unavailable Risk assessment unavailable merge:bot Bot-owned review; merge when ready once readiness passes and a review approves. labels Oct 23, 2026
…refresh

# Conflicts:
#	packages/db/src/migrations/meta/0297_snapshot.json
#	packages/db/src/migrations/meta/_journal.json
@iscekic iscekic added merge:human Substantive functional risk requires human review. do-not-merge Do not merge this PR (yet) and removed merge:human Substantive functional risk requires human review. labels Oct 24, 2026
@iscekic iscekic added merge:human Substantive functional risk requires human review. and removed merge:human Substantive functional risk requires human review. labels Oct 24, 2026
@iscekic iscekic added merge:human Substantive functional risk requires human review. and removed merge:human Substantive functional risk requires human review. labels Oct 24, 2026
The default branch appended its own migration at the sequence number the
branch had used, so the branch entry is regenerated at the next free index.
The generated DDL is unchanged; the migrator boundaries follow the shared
database conventions.
@iscekic iscekic added merge:blocked:kilobot-not-ready Review bot has not recommended merge at this head merge:human Substantive functional risk requires human review. and removed merge:human Substantive functional risk requires human review. merge:blocked:kilobot-not-ready Review bot has not recommended merge at this head labels Oct 24, 2026
@iscekic

iscekic commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator Author

Changes requested: the index migration is missing at the current head.

  • Merge commit bc04ca0 resolved the collision with 0299_lame_mojo by deleting 0299_tidy_grey_gargoyle.sql and its journal and snapshot entries.
  • packages/db/src/schema.ts still declares idx_cloud_agent_code_reviews_started_at_effective, but no migration or snapshot creates it. If merged, production never gets the index, and the next generated migration would pick up this index by accident.
  • Merge the latest main, then regenerate the index migration at the next free number after main's latest migration. Use the existing COMMIT; CREATE INDEX CONCURRENTLY ...; BEGIN; pattern.
  • Update the PR body's production prerequisites to name the new migration file.
  • Re-run the detector query plan check and the DB tests on the merged tree.

@iscekic iscekic added merge:human Substantive functional risk requires human review. and removed merge:human Substantive functional risk requires human review. labels Oct 24, 2026
@iscekic

iscekic commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator Author

Changes requested: renumber the migration again. It collides with main.

The default branch appended its own migration at the sequence number this
branch had reserved, so the branch entry is generated again at the next free
index. The generated DDL and index definition are unchanged; only the migrator
transaction boundaries follow the shared database conventions.
@iscekic iscekic removed the merge:human Substantive functional risk requires human review. label Oct 24, 2026
@iscekic

iscekic commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator Author

bot: Both requests are addressed at the current head.

  • Merged the latest default branch and kept its journal and snapshots; the branch migration is regenerated at the next free sequence position after it.
  • The generated index DDL is unchanged and a follow-up drizzle-kit generate reports no schema drift.
  • Applied the full migration chain on a fresh database and re-ran the bootstrap check; the index exists with the expected definition, valid and ready.
  • Re-ran the detector window query plan check: the planner selects the new index with a bitmap index scan over the window condition.
  • Database package suite and the focused route and detector suites pass.
  • The PR body's production prerequisites now name the migration file.

@iscekic iscekic added merge:blocked:kilobot-not-ready Review bot has not recommended merge at this head merge:human Substantive functional risk requires human review. and removed merge:blocked:kilobot-not-ready Review bot has not recommended merge at this head labels Oct 24, 2026

This branch has not been deployed

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

Labels

do-not-merge Do not merge this PR (yet) drain Work item from the findings drain intent:ok Janitor change confirmed as a real bug fix, not intended behavior janitor:trust Janitor finding: trust boundary hardening merge:human Substantive functional risk requires human review. needs:prod-action Prod prerequisite (env var, secret, firewall rule, config) needed before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants