Skip to content

fix(persist-postgres): address Greptile review feedback and CI failures - #2

Closed
supmo668 with Copilot wants to merge 9 commits into
feature/session-timestamp-filteringfrom
copilot/create-prd-for-pr-feedback
Closed

supmo668 with Copilot wants to merge 9 commits into
feature/session-timestamp-filteringfrom
copilot/create-prd-for-pr-feedback

Conversation

Copilot AI commented Feb 14, 2026 •

Copy link
Copy Markdown

Upstream PR openclaw/openclaw#15424 received a 2/5 confidence score from Greptile and fails CI with 7 TypeScript errors. This PR implements all 7 actionable fixes and includes a PRD documenting each issue.

Greptile review fixes

  • Plugin config ignored — Now reads api.pluginConfig.databaseUrl first, falls back to process.env.DATABASE_URL
  • Duplicate persistence — Removed message_received/message_sent hooks; only before_agent_start (user) and agent_end (assistant) persist as the canonical path
  • Inflated message_count — Moved increment from upsert ON CONFLICT into insertMessage() so count only increases when a message is actually persisted
  • gen_random_uuid() portability — Replaced with app-side crypto.randomUUID(), removing Postgres <13 / pgcrypto dependency
  • Integration test blocks CI — All tests gated behind describe.skipIf(!shouldRun) where shouldRun = !!process.env.DATABASE_URL; removed hardcoded localhost fallback

CI TypeScript error fixes

  • db.ts — Typed values array as (string | number)[]; cast metadata as postgres.JSONValue
  • index.ts — Added AgentMessage type and proper type narrowing for event.messages (unknown[] in plugin SDK)
  • auth-choice-options.ts — Pre-existing upstream "vllm" type error (not in scope)

Verification

  • pnpm check passes (format + typecheck + lint — 0 errors, 0 warnings)
  • 39/39 session-utils unit tests pass
  • 16 integration tests properly skip without DATABASE_URL

PRD location

docs/refactor/persist-postgres-pr-fixes.md — includes per-issue fix proposals, acceptance criteria, and a P0–P3 priority matrix with status tracking.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

supmo668 and others added 7 commits February 13, 2026 04:40
Add `createdAt` timestamp to SessionEntry, preserve it across merges,
and expose four new list-sessions filters (updatedAfter, updatedBefore,
createdAfter, createdBefore) for querying sessions by absolute time
range. This is foundational for external persistence backends (e.g.
PostgreSQL) that need incremental sync by timestamp.

Includes 10 new tests covering all filter combinations and edge cases.
…d messages

Add persist-postgres extension plugin that persists conversations and
messages to PostgreSQL via agent lifecycle hooks (before_agent_start,
agent_end) and channel hooks (message_received, message_sent).

Plugin boundary: owns lp_conversations and lp_messages tables only.
No user table — user identity is outside this plugin's scope.
Schema auto-created on first use with proper indexes.

Files:
- db.ts: connection pooling, schema DDL, upsert/insert/query, row mapping
- index.ts: plugin registration with lifecycle and channel hooks
- integration.test.ts: 16 tests (CRUD, date-range SQL filtering,
  listSessionsFromStore round-trip with PG-sourced data)
…sations

The first filter (createdAfter) hardcoded $1 instead of using
$${values.length + 1}, which would break if filters are reordered.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Adds lockfile entries for the persist-postgres workspace package
so CI frozen-lockfile install succeeds.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Copilot AI changed the title [WIP] Create PRD to address PR feedback and git action issues docs: PRD for persist-postgres PR feedback and CI failures Feb 14, 2026
Copilot AI requested a review from supmo668 February 14, 2026 00:16

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

Proceed to address the feedbacks and comments from the Greptile bot, feedbacks from the PR from openclaw (origin) reviewer upon push

Copilot AI commented Feb 14, 2026

Copy link
Copy Markdown
Author

Proceed to address the feedbacks and comments from the Greptile bot, feedbacks from the PR from openclaw (origin) reviewer upon push

All 7 Greptile review issues and CI TypeScript errors have been implemented in commit 214e2b2:

Plugin fixes (index.ts):

  • Reads api.pluginConfig.databaseUrl first, falls back to process.env.DATABASE_URL
  • Removed duplicate message_received/message_sent hooks; only before_agent_start/agent_end persist now
  • Added AgentMessage type narrowing for event.messages (fixes TS2769/TS2339 errors)
  • upsertConversation only called when a message will actually be inserted

Database fixes (db.ts):

  • Replaced DEFAULT gen_random_uuid() with app-side crypto.randomUUID() for Postgres <13 compatibility
  • Moved message_count increment from upsert conflict into insertMessage()
  • Fixed JSONValue and ParameterOrJSON type errors

Test fixes (integration.test.ts):

  • All tests gated behind describe.skipIf(!shouldRun) where shouldRun = !!process.env.DATABASE_URL
  • Removed hardcoded localhost fallback
  • All 39 session-utils tests pass; 16 integration tests properly skip without DATABASE_URL

pnpm check (format + typecheck + lint) passes with 0 errors. Issue 8 (upstream "vllm" type error) is not in scope.

Copilot AI changed the title docs: PRD for persist-postgres PR feedback and CI failures fix(persist-postgres): address Greptile review feedback and CI failures Feb 14, 2026
Copilot AI requested a review from supmo668 February 14, 2026 00:38
@supmo668
supmo668 force-pushed the feature/session-timestamp-filtering branch from 9558d21 to 3ffecf3 Compare February 14, 2026 08:38
@supmo668 supmo668 closed this Feb 14, 2026
supmo668 added a commit that referenced this pull request Jul 22, 2026
…he pass; non-empty = FAIL-ESCALATE (CTO openclaw#4367)

shrinemobile proved the original scenario-3 input (a fresh token for the signed-out session) is UNOBTAINABLE: a real sign-out revokes the session at Clerk, so the FAPI re-mint FAILS at the mint step (empty). Feeding an empty token and scoring its 401 as a pass would be VACUOUS (rejected nothing). Corrected, and stronger: PASS = (a) the re-mint returns EMPTY (Clerk refused to mint for the revoked session — the threat closed at the SOURCE) AND (b) the pre-sign-out captured token → 401 at the validator. A NON-EMPTY re-mint is the real finding → FAIL-ESCALATE (Clerk did not revoke), never scored green. This cleanly distinguishes #3 (a fresh token cannot be obtained) from #2 (the existing token is rejected).

Stage: tests
Generated-With: Claude Code
Co-Authored-By: openclaw <[email protected]>
Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants