feat(scope): portable app-scope + function-resolution modules#101
Merged
Conversation
Port the portable scope-chain resolution modules into the standalone
workspace:
- app-scope: ordered scope frames + platform database lookup. Reusable
primitive, SELECT-only dynamic SQL (format('%I') + EXECUTE ... USING),
no AST/deparser runtime.
- function-resolution: cross-scope function-definition resolution and
resolver-aware enqueue, built on app-scope; delegates the physical
insert to app_jobs.add_job.
Required dependency delta (previously unpushed upstream):
- database-jobs: add_job gains function_definition_id / definition_scope
params and the jobs table gains the matching nullable columns so
function_resolution.enqueue can stamp the resolved definition.
- jwt-claims: add current_graph_execution_id() JWT-claim getter.
Docs + CI: list both modules in README.md / MODULES.md and add them to
the CI test matrix.
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two portable pgpm modules for scope-chain resolution, plus the small upstream deltas they depend on. Everything is SELECT-only dynamic SQL (
format('%I')+EXECUTE ... USING) — no AST/deparser runtime and no core-metaschema resolver functions — so the closure installs into any provisioned database whose metaschema catalog is populated.New modules
@pgpm/app-scope(schemaapp_scope) — the reusable primitive. Given(database_id, execution_scope, entity_id)it returns ordered scope frames(scope, lookup_database_id, key_value), most-specific first, for a nearest-wins lookup. Each database climbs its ownentity → … → org → app, then falls through to the platform database'sdatabase → org → app → platform. The platform database is not a special case — it climbs the identical shape withplatformas the terminal global frame.databaseis a synthetic frame keyed bydatabase_id, bridged to its owning org viametaschema_public.database.owner_id. NULL execution scope raises.@pgpm/function-resolution(schemafunction_resolution, built onapp-scope) —resolve,probe,routing,definitions_location,resolve_invocation, and the resolver-awareenqueue.enqueueresolves (or trusts a supplied) definition, stamps(function_definition_id, definition_scope)+ queue routing, then delegates the physical insert toapp_jobs.add_job.app_jobsstays the generic, resolver-free queue primitive one layer below.Required upstream deltas (previously unpushed)
database-jobs:app_jobs.add_jobgainsfunction_definition_id/definition_scopeparams andapp_jobs.jobsgains the matching nullable columns (+ all-or-nothing CHECK), sofunction_resolution.enqueuecan stamp the resolved definition. Purely additive; the existing scheduled-jobs test is unchanged (snapshot only grows the two newnullcolumns).jwt-claims: addsjwt_private.current_graph_execution_id(), a trivial JWT-claim getter matching the existingcurrent_database_idpattern.Conventions / housekeeping
versionon the current0.32.xline,pgpmdevDep^4.28.7, extension/control/Makefile/sql/bundle at the module's extension version (app-scope/function-resolution→0.15.5). README files follow the sibling badge/overview/usage/testing format.README.md,MODULES.md, and the CI test matrix in.github/workflows/ci.yml.deploy/**/*.sqlhas matchingverify/andrevert/files.Tests (local,
pgsql-test)app-scope7/7 ·function-resolution22/22 (incl. portability test asserting AST/deparser + oldmetaschema_privateresolvers are absent) ·database-jobs4/4 ·jwt-claims1/1.Drift audit (not included here — needs a decision)
While checking for unpushed work, the standalone repo is generally ahead of the ConstructiveDB embedded copies (e.g.
inflection0.30.0,metaschema-schema0.31.0). One entangled item remains:metaschema-modulesis bidirectionally diverged — upstream hasagent_module/db_preset_module/etc. that ConstructiveDB lacks, while ConstructiveDB hashttp_route_module. That is too intertwined to auto-sync and is left out pending a decision.Link to Devin session: https://app.devin.ai/sessions/5ce15e7e50b3454496cf8e613b53280e
Requested by: @pyramation