Skip to content

sync: port default-bucket resolution and the parent-key node descent from constructive-db - #118

Merged
pyramation merged 1 commit into
mainfrom
feat/sync-default-bucket-and-node-descent
Aug 8, 2026
Merged

sync: port default-bucket resolution and the parent-key node descent from constructive-db#118
pyramation merged 1 commit into
mainfrom
feat/sync-default-bucket-and-node-descent

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

The trees drifted again after #115. A full re-diff of all 28 shared packages (excluding sql/) finds exactly two with real content drift, both with constructive-db ahead; this ports them upstream unchanged and regenerates the bundles.

function-resolution — server-side default bucket resolution

Three new triples plus a rewritten resolve_bucket, which now delegates the matching:

+ bucket_matches          [schema, frame_candidates]                        # buckets a selector matches in the nearest frame
  resolve_bucket          [schema, frame_candidates, bucket_matches]        # was: [schema, frame_candidates]
+ default_bucket_tag      [schema]                                         # reserved default-bucket tag vocabulary
+ resolve_default_bucket  [schema, bucket_matches, default_bucket_tag]      # the database's default bucket, or an explicit key

resolve_default_bucket raises through errors, so the control's requires and the package's dependencies gain it (@pgpm/errors, reflected in the lockfile importer).

object-storeinsert_nodes_at_paths, dirty-directory descent

The descent recursed on depth and matched with a path-prefix filter; it now joins a child to its parent on the parent's key, which every directory already carries:

-    JOIN dirs AS child ON child.depth = r.depth + 1
-      AND child.path[1:r.depth] = r.path
+    JOIN dirs AS child ON child.parent = r.node_key

A prefix filter is not a join condition, so every dirty directory was compared against every row of the level above — 9.6M filtered comparisons per level on a 22k-directory batch, each re-deriving the path from the key: 300s of a 307s pass, against 0.4s for the equijoin the planner can hash once per level. The root becomes the descent's seed rather than a child (under to_jsonb(path[1:0]) it is its own parent, so leaving it in the recursive side joins it to itself forever), and depth/path drop out of the CTE entirely since the name is enough to index into the parent's ktree.

Versions

Both trees stay at 0.39.0. The registry tops out at 0.36.0, so 0.39.0 is unpublished — no consumer can observe content changing under a fixed version, and the two trees agreeing on content under it is the point of the sync. Bumping would have forced a matching bump and repackage on the constructive-db side for no observable benefit.

What is not drift

Every other difference across the 28 packages is legitimately tree-specific, and deliberately left alone:

  • the test harness import — upstream pgsql-test, vendored constructive-test;
  • the pgpm devDependency pin — upstream ^5, vendored ^5.24.5;
  • the upstream-only defaults "schema public function grants" test (upstream hardening kept in sync all 28 modules to constructive-db's source, lockstep 0.39.0 #115). Ported into the vendored copy separately, in constructive-db.

Verification

  • function-resolution: 7 suites, 79 tests passed (includes the ported default-bucket.test.ts).
  • object-store: 6 suites, 28 tests passed.
  • pgpm package regenerated pgpm-function-resolution--0.39.0 and object-store--0.39.0 (.sql + bundle).

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

…from constructive-db

constructive-db's vendored copy moved ahead again in two packages. Ports the
newer side upstream, unchanged, and regenerates both bundles.

function-resolution: bucket_matches, default_bucket_tag and
resolve_default_bucket (new triples), a resolve_bucket rewritten on top of
bucket_matches, and the errors dependency the new code raises through.

object-store: insert_nodes_at_paths' dirty-directory descent now joins a child
to its parent on the parent's key instead of recursing on depth with a
path-prefix filter — a real equijoin the planner hashes once per level, where
the filter compared every dirty directory against every row of the level above
(300s of a 307s pass on a 22k-directory batch, against 0.4s).

Versions stay at 0.39.0 in both trees: the registry tops out at 0.36.0, so
0.39.0 is unpublished and the two trees agreeing on content under it is the
point. Everything else that still differs between the trees is tree-specific —
the pgsql-test/constructive-test harness import and the pgpm devDependency pin.
@pyramation pyramation self-assigned this Aug 8, 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

@pyramation
pyramation merged commit ef134d3 into main Aug 8, 2026
29 checks passed
@pyramation
pyramation deleted the feat/sync-default-bucket-and-node-descent branch August 8, 2026 01:19
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