Skip to content

Phase 1: deterministic pgpm/export timestamps and plan ordering#1363

Merged
pyramation merged 2 commits into
mainfrom
feat/phase1-deterministic-generation
Jul 12, 2026
Merged

Phase 1: deterministic pgpm/export timestamps and plan ordering#1363
pyramation merged 2 commits into
mainfrom
feat/phase1-deterministic-generation

Conversation

@pyramation

@pyramation pyramation commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Phase 1 non-determinism fixes for the code-generation pipeline.

pgpm/export now introspects information_schema.columns to detect timestamptz columns whose default expression is non-deterministic (now(), CURRENT_TIMESTAMP, clock_timestamp(), or now() + '...'::interval) and omits them from exported INSERT rows. The column's DDL DEFAULT supplies the value at deploy time, so generated migrations stop containing literal ISO timestamps. The same omission is applied in both the SQL (exportMeta) and GraphQL (exportGraphQLMeta) flows.

pgpm/core plan generator and writer now use a fixed epoch timestamp (2017-08-11T08:11:51Z) and sort plan dependency brackets deterministically, eliminating run-to-run timestamp and ordering drift. pgpm/core/src/core/class/pgpm.ts now imports the shared getNow from files/plan/generator instead of redefining it.

pgpm/export/src/meta-export-tables.json is synced with constructive-db to include integration_providers_module so the generated service migration set is consistent.

Example

export function getNow(): string {
  const frozen = process.env.PGPM_FROZEN_TIME;
  if (frozen) return getUTCTimestamp(new Date(frozen));
  return '2017-08-11T08:11:51Z';
}

Closes / related: https://github.com/constructive-io/constructive-planning/issues/1148

Verification

  • pnpm --filter @pgpmjs/core build:dev passed
  • pnpm --filter @pgpmjs/export build:dev passed
  • pnpm --filter pgpm build:dev passed
  • pgpm/core snapshots updated with jest -u to reflect deterministic dependency ordering
  • constructive-db pnpm run generate:constructive was run twice with these packages; services/constructive-services/deploy/migrate/database.sql, pgpm.plan files, and application/constructive/pgpm.plan were identical across runs and contained no literal ISO timestamps.

Blockers

  • @pgpmjs/export and @pgpmjs/core changes must be published before constructive-db can consume them. The deploy pipeline will handle the version bump; no package.json version changes are included in this PR.

Next steps

  • Merge and publish constructive pgpm packages.
  • Update constructive-db to use the published versions and regenerate to confirm.

Link to Devin session: https://app.devin.ai/sessions/866a2246ce1345918ec707e9a09e5b9b
Requested by: @pyramation

@pyramation pyramation self-assigned this Jul 12, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@blacksmith-sh

This comment has been minimized.

@devin-ai-integration devin-ai-integration Bot force-pushed the feat/phase1-deterministic-generation branch 3 times, most recently from 968d133 to 5f5dd54 Compare July 12, 2026 13:40
- Freeze pgpm plan timestamps to a fixed epoch (2017-08-11T08:11:51Z) with PGPM_FROZEN_TIME env override.
- Sort pgpm.plan dependency brackets by plan order (parent-first), preserving external dependencies' original order.
- Export omits timestamptz columns with non-deterministic defaults (now, CURRENT_TIMESTAMP, clock_timestamp, now() + interval) from generated INSERT rows.
- Expose timestamp-default columns in meta-export-tables.json so the GraphQL/API path can omit them without a DB pool.
- Sync meta-export-tables.json to include integration_providers_module.

Snapshots updated accordingly.

Ref: constructive-io/constructive-planning#1148
@devin-ai-integration devin-ai-integration Bot force-pushed the feat/phase1-deterministic-generation branch from 5f5dd54 to 99672e2 Compare July 12, 2026 14:12
Remove metaschema_public.partition from the generated manifest now that
it is excluded from the constructive-services meta export.

Ref: constructive-io/constructive-planning#1148
@pyramation pyramation merged commit 391d5ba into main Jul 12, 2026
37 checks passed
@pyramation pyramation deleted the feat/phase1-deterministic-generation branch July 12, 2026 18:18
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.

1 participant