Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
}
},
"devDependencies": {
"@constructive-io/graphql-codegen": "4.28.0",
"@constructive-io/graphql-codegen": "4.30.0",
"@types/jest": "^30.0.0",
"@types/node": "^25.0.3",
"@typescript-eslint/eslint-plugin": "^8.58.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/agentic-db-services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
},
"keywords": [],
"dependencies": {
"@pgpm/metaschema-modules": "^0.20.2",
"@pgpm/metaschema-schema": "^0.20.2",
"@pgpm/metaschema-modules": "^0.21.0",
"@pgpm/metaschema-schema": "^0.21.0",
"@pgpm/services": "^0.20.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/agentic-db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@pgpm/database-jobs": "^0.20.2",
"@pgpm/inflection": "^0.20.1",
"@pgpm/jwt-claims": "^0.20.0",
"@pgpm/metaschema-schema": "^0.20.2",
"@pgpm/metaschema-schema": "^0.21.0",
"@pgpm/stamps": "^0.20.0",
"@pgpm/totp": "^0.20.0",
"@pgpm/types": "^0.20.0",
Expand Down
36 changes: 36 additions & 0 deletions packages/integration-tests/__fixtures__/seed/spatial-relations.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
-- spatial-relations.sql — Bakes @spatialRelation smart tags into column
-- comments so the graphile-postgis PostgisSpatialRelationsPlugin can
-- register cross-table spatial filters on the owner tables.
--
-- These comments match the metadata that would be emitted by
-- `metaschema_modules_public.provision_spatial_relation` running at
-- blueprint-construction time (see packages/provision/src/schemas/
-- spatial-relations.ts for the production path). We set them directly
-- here so ORM integration tests can exercise the GraphQL filter shape
-- without requiring a live Constructive platform to run the blueprint.
--
-- Tag format (parsed by graphile-postgis):
-- @spatialRelation <name> <target_table.col> <operator> [<param>]
--
-- Five entries, one per pair:
-- 1. memories.location_geo -> places.location_geo (nearbyPlaces, st_dwithin 5 km)
-- 2. memories.location_geo -> contacts.location_geo (nearbyContacts, st_dwithin 2 km)
-- 3. trips.destination_geo -> venues.location (nearbyVenues, st_dwithin 1 km)
-- 4. events.location_geo -> venues.location (nearbyVenues, st_dwithin 500 m)
-- 5. memories.location_geo -> memories.location_geo (nearbyMemories, st_dwithin 1 km, self)
--
-- Relation names are camelCase so the generated GraphQL filter fields
-- match PostGraphile's inflection for every other field in the schema.
-- Note: a column can carry multiple @spatialRelation tags — one per line.
-- The smart-tag parser reads repeated-key values as an array.

COMMENT ON COLUMN agentic_db_app_public.memories.location_geo IS
E'@spatialRelation nearbyPlaces places.location_geo st_dwithin distance\n'
'@spatialRelation nearbyContacts contacts.location_geo st_dwithin distance\n'
'@spatialRelation nearbyMemories memories.location_geo st_dwithin distance';

COMMENT ON COLUMN agentic_db_app_public.trips.destination_geo IS
E'@spatialRelation nearbyVenues venues.location st_dwithin distance';

COMMENT ON COLUMN agentic_db_app_public.events.location_geo IS
E'@spatialRelation nearbyVenues venues.location st_dwithin distance';
145 changes: 145 additions & 0 deletions packages/integration-tests/__fixtures__/seed/test-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ VALUES

-- Memories with PostGIS Point locations for spatial-filter tests.
-- SF and Oakland are in the Bay Area bbox; NYC is the negative control.
-- Coordinates are chosen so SF <-> Oakland is ~13 km apart (outside 5 km
-- radius of each other) and NYC is ~4100 km from SF.
INSERT INTO "agentic_db_app_public".memories (id, agent_id, title, content, location, location_geo)
VALUES
(
Expand All @@ -51,4 +53,147 @@ VALUES
'Agent-infra meetup in Manhattan.',
'New York, NY',
ST_SetSRID(ST_MakePoint(-74.0060, 40.7128), 4326)::geography
),
-- Fourth memory ~260 m from the SF memory, so the self-referential
-- `nearby_memories` relation has a matching "other" row for the
-- "within 1 km of MEMORY_SF" test (the plugin excludes the owner row
-- itself from self-relations). Coordinates are intentionally close to
-- SF memory (-122.4194, 37.7749) and NOT the same as the Ferry Building
-- Marketplace place (-122.3937, 37.7956), which is ~3.2 km away.
(
'eeeeeeee-eeee-eeee-eeee-eeeeeeee0004',
'cccccccc-cccc-cccc-cccc-cccccccccccc',
'Quick walk nearby',
'Short walk a few blocks from the coffee spot.',
'San Francisco, CA',
ST_SetSRID(ST_MakePoint(-122.4180, 37.7770), 4326)::geography
);

-- -----------------------------------------------------------------------
-- Seed data for the RelationSpatial tests
--
-- Places: one next to the SF memory (~200 m), one next to NYC (~300 m),
-- one in Tokyo (negative control). The SF place is ~13 km from Oakland,
-- so "memories within 5 km of places" should pick up SF memory only for
-- the first place, Oakland for none, and NYC for the NYC place.
-- -----------------------------------------------------------------------
INSERT INTO "agentic_db_app_public".places (id, name, address, category, location_geo)
VALUES
(
'dddddddd-dddd-dddd-dddd-dddddddd0001',
'Ferry Building Marketplace',
'1 Ferry Building, San Francisco, CA',
'market',
ST_SetSRID(ST_MakePoint(-122.3937, 37.7956), 4326)::geography
),
(
'dddddddd-dddd-dddd-dddd-dddddddd0002',
'Bryant Park',
'NYC, NY',
'park',
ST_SetSRID(ST_MakePoint(-73.9832, 40.7536), 4326)::geography
),
(
'dddddddd-dddd-dddd-dddd-dddddddd0003',
'Shibuya Crossing',
'Tokyo, Japan',
'landmark',
ST_SetSRID(ST_MakePoint(139.7005, 35.6595), 4326)::geography
);

-- Update the two seeded contacts with location_geo so the
-- memories.nearby_contacts relation has something to match.
-- Alice near the SF memory (~250 m), Bob in NYC (~400 m).
UPDATE "agentic_db_app_public".contacts
SET location = 'San Francisco, CA',
location_geo = ST_SetSRID(ST_MakePoint(-122.4214, 37.7775), 4326)::geography
WHERE id = '11111111-1111-1111-1111-111111111111';

UPDATE "agentic_db_app_public".contacts
SET location = 'New York, NY',
location_geo = ST_SetSRID(ST_MakePoint(-74.0021, 40.7105), 4326)::geography
WHERE id = '22222222-2222-2222-2222-222222222222';

-- Venues: Bay Area SoMa (~1 km from SF memory), NYC (~350 m from NYC
-- memory), London (negative control).
INSERT INTO "agentic_db_app_public".venues (id, name, address, neighborhood, category, location)
VALUES
(
'ffffffff-ffff-ffff-ffff-ffffffff0001',
'SoMa Coffee Bar',
'500 Howard St, San Francisco, CA',
'SoMa',
'cafe',
ST_SetSRID(ST_MakePoint(-122.3985, 37.7879), 4326)::geography
),
(
'ffffffff-ffff-ffff-ffff-ffffffff0002',
'Times Square Diner',
'1500 Broadway, New York, NY',
'Midtown',
'restaurant',
ST_SetSRID(ST_MakePoint(-73.9855, 40.7580), 4326)::geography
),
(
'ffffffff-ffff-ffff-ffff-ffffffff0003',
'London Bridge Pub',
'Tooley St, London',
'London Bridge',
'bar',
ST_SetSRID(ST_MakePoint(-0.0877, 51.5045), 4326)::geography
);

-- Trips: one destined SF (near SoMa venue), one destined NYC, one
-- destined Paris (negative control).
INSERT INTO "agentic_db_app_public".trips (id, name, destination, description, destination_geo)
VALUES
(
'99999999-9999-9999-9999-999999990001',
'SF Retrieval Summit',
'San Francisco, CA',
'Week-long onsite with the retrieval team.',
ST_SetSRID(ST_MakePoint(-122.3990, 37.7880), 4326)::geography
),
(
'99999999-9999-9999-9999-999999990002',
'NYC AI Conf',
'New York, NY',
'Speaker slot at AI Conf.',
ST_SetSRID(ST_MakePoint(-73.9860, 40.7585), 4326)::geography
),
(
'99999999-9999-9999-9999-999999990003',
'Paris Offsite',
'Paris, France',
'Engineering offsite.',
ST_SetSRID(ST_MakePoint(2.3522, 48.8566), 4326)::geography
);

-- Events: one right at the NYC venue (~50 m), one in SF far from SoMa
-- (~2 km away, outside 500 m), one in Berlin (negative control).
INSERT INTO "agentic_db_app_public".events (id, name, event_type, location, city, location_geo)
VALUES
(
'88888888-8888-8888-8888-888888880001',
'AI Conf Welcome Reception',
'conference',
'Times Square',
'New York',
ST_SetSRID(ST_MakePoint(-73.9853, 40.7582), 4326)::geography
),
(
'88888888-8888-8888-8888-888888880002',
'SF Ferry Building Mixer',
'meetup',
'Ferry Building',
'San Francisco',
ST_SetSRID(ST_MakePoint(-122.3937, 37.7956), 4326)::geography
),
(
'88888888-8888-8888-8888-888888880003',
'Berlin Hackathon',
'hackathon',
'Kreuzberg',
'Berlin',
ST_SetSRID(ST_MakePoint(13.4050, 52.5200), 4326)::geography
);
Loading
Loading