DBIO-PostgreSQL-Age

 view release on metacpan or  search on metacpan

.claude/skills/dbio-postgresql-age/SKILL.md  view on Meta::CPAN

  },
  ['ok'],
  { name => 'Alice', age => 30 },
);
```

Always parameterise user input — never interpolate.

## Edges

Match endpoints first, then create. Can combine create + create in one query.

```perl
$storage->cypher(
  'social',
  q{
    MATCH (a:Person {name: $from}), (b:Person {name: $to})
    CREATE (a)-[:KNOWS {since: $since}]->(b)
    RETURN 1
  },
  ['ok'],

misc/agent-context/.claude/skills/dbio-postgresql-age/SKILL.md  view on Meta::CPAN

  },
  ['ok'],
  { name => 'Alice', age => 30 },
);
```

Always parameterise user input — never interpolate.

## Edges

Match endpoints first, then create. Can combine create + create in one query.

```perl
$storage->cypher(
  'social',
  q{
    MATCH (a:Person {name: $from}), (b:Person {name: $to})
    CREATE (a)-[:KNOWS {since: $since}]->(b)
    RETURN 1
  },
  ['ok'],

misc/agent-context/.claude/skills/postgres-vector-graph/references/age/modeling-indexes-and-ingestion.md  view on Meta::CPAN

A B-tree over `(properties::jsonb ->> 'doc_id')` is not automatically equivalent
to the expression used by a Cypher integer property predicate. A mismatch can
make a plausible index useless. Inspect EXPLAIN and verify the plan on real
cardinalities. Never alter AGE's internal storage layout casually.

## Bulk ingestion and backfill

Batch ingestion with progress, bounded transactions and explicit commit points.
Treat server-side CSV/file loading as privileged file access; a client upload and
a server filesystem path are not the same operation. Validate encoding, types,
missing endpoints and duplicate edges before publication. Quarantine malformed
records rather than creating synthetic endpoints silently.

After loading, analyze the relevant relations, audit dangling business references,
compare counts and test a known path. Large path fan-out must be tested before
making graph expansion part of every user request.

## Sources

- [Apache AGE upstream repository](https://github.com/apache/age)
- [Apache AGE PG18 1.8.0 release](https://github.com/apache/age/releases/tag/PG18%2Fv1.8.0-rc0)
- [Apache AGE SQL and Cypher composition](https://age.apache.org/age-manual/master/advanced/advanced.html)

misc/agent-context/.claude/skills/postgres-vector-graph/references/age/security-and-rls.md  view on Meta::CPAN

configuration. The executable lab role script attaches policies to all existing
fixture labels. Production must also govern future labels and the trusted source
of tenant context. Application users must not create arbitrary labels/schemas.

## Tests that matter

Run labeled MATCH, unlabeled MATCH, direct label-table SQL, incoming/outgoing
edges, optional matches, bounded variable-length paths, writes, deletes, prepared
queries and reused connections as a non-owner/non-BYPASSRLS role. Put a
cross-tenant edge in a dedicated adversarial fixture; assert that neither the
foreign endpoint nor its identity/path evidence is disclosed.

The package includes basic role tests and a broader acceptance matrix. Basic
success is not certification of all traversal shapes. A provider-patched build
needs the same tests. Never make a SECURITY DEFINER/superuser escape hatch the
solution to a failing permission test.

## Sources

- [Apache AGE PG18 1.8.0 release](https://github.com/apache/age/releases/tag/PG18%2Fv1.8.0-rc0)
- [AGE security regression suite](https://github.com/apache/age/blob/fa109ef1ddb1c7a945a1c340195d650000e49713/regress/sql/security.sql)

misc/agent-context/.claude/skills/postgres-vector-graph/references/combinations/consistency-and-outbox.md  view on Meta::CPAN

use a relational identity registry, and test interleavings on the actual AGE
version. A graph property that looks unique is not a relational UNIQUE constraint.

## Versioned invariants

Define these conditions explicitly:

- Every published embedding has the intended space ID and current source version.
- Every projected vertex maps to a live authorized source key, unless a documented
  historical retention policy intentionally keeps it.
- Every relationship has source provenance and valid endpoints.
- A deletion tombstone is ordered after older create/update work and survives
  retries long enough to prevent resurrection.

An audit job compares source versions, missing/duplicate keys, orphaned edges,
and outbox lag. Repair jobs must be idempotent and reviewed, not automatic
whole-graph rebuilds against production.

## Tradeoff record

Choose synchronous atomic projection, asynchronous eventual projection, or a

misc/agent-context/.claude/skills/postgres-vector-graph/references/operations/backup-recovery-upgrades.md  view on Meta::CPAN

when an external embedding model changes.

## Restore drill

Provision a clean target with the approved PG18/extension builds. Restore using the
chosen logical or physical method according to PostgreSQL and extension guidance.
Do not casually pre-create extension-managed objects in conflict with the dump's
creation order. Preserve a restore log and investigate every error.

After restoration, verify relational counts and constraints, graph business-key
mappings and endpoint integrity, embedding dimensions/spaces, known-query results,
index validity, grants/policies, and no cross-tenant visibility. Run reads and
writes as the actual application role. Document recovery time and data-loss
window from measurements, not assumptions.

## Upgrade sequence

For a minor extension update or major PostgreSQL upgrade: read target release
notes, confirm the upgrade path, rehearse on a restored clone, run extension and
cross-model tests, compare plans/recall, and repeat role/restore tests. An installed
`extversion` is not proof that libraries on every replica match.

misc/agent-context/.claude/skills/postgres-vector-graph/references/operations/pooling-and-resource-budgets.md  view on Meta::CPAN


## Practical workload separation

Separate latency-sensitive search from bulk embedding writes, graph ingestion,
index builds, and vacuum/reindex work through schedules, connection pools, or
resource controls. Do not imply every workload needs a second database; first
measure interference and establish admission control.

Keep transactions short. Set statement and lock timeouts appropriate to the
operation; a bulk maintenance timeout should not silently become a request
endpoint's timeout. Bound result size, traversal depth, candidate count, and
batch size in addition to timeouts.

## Benchmark matrix

Include warm/cold cache, representative tenants, selective filters, skewed graph
degree, concurrent writes, connection churn, and overload. Record queue time
separately from database execution. Validate tenant-context reset across connection
reuse, cancellation, exceptions, and transaction rollback. Use database roles
without bypass privileges for isolation tests.

misc/agent-context/.claude/skills/postgres-vector-graph/references/postgres/security-and-rls.md  view on Meta::CPAN

# Relational authorization and RLS

## Separate the trusted API from arbitrary SQL access

An application setting such as `app.tenant_id` is a context carrier, not an
authentication mechanism. A caller that can run arbitrary SQL under the same
role may set that value themselves. Establish tenant identity in a trusted
service, verified database identity mapping, or another reviewed boundary before
using a setting in policies. Never expose the lab context-setting pattern as a
public SQL endpoint.

## Policy checklist

Enable RLS on every tenant-bearing relation and define both visibility (`USING`)
and mutation (`WITH CHECK`) behavior. Table owners, superusers and roles with
`BYPASSRLS` require special attention; testing solely as an owner is not a valid
application isolation test. Use `FORCE ROW LEVEL SECURITY` where appropriate,
while remembering that it does not remove the superuser/BYPASSRLS bypass.

The lab role script uses a non-login, non-owner role and `SET LOCAL ROLE` to

misc/agent-context/.claude/skills/postgres-vector-graph/references/testing/acceptance-matrix.md  view on Meta::CPAN

## Required acceptance checks

| Area | Check | Pass evidence |
|---|---|---|
| Compatibility | Exact PG major, extension binary/SQL versions, schemas, provider support | Fingerprint plus successful target initialization |
| Scalar boundary | Integer, string, NULL, JSONB conversion and prepared maps | Queries under deployed AGE/driver/pool versions |
| SQL + graph atomicity | Roll back a write in both layers | No record/vertex survives; repeat with induced failure |
| Replay/concurrency | Duplicate event, two writers, stale event, delete race | Unique stable identities and no resurrection |
| ANN | Compare same-space, same-filter/snapshot exact ground truth | Recall distribution and underfill counts |
| Rank fusion | Duplicates, weights, empty channels, deterministic order | Offline unit tests plus real-query relevance evaluation |
| Graph semantics | Direction/type/depth, cycles, hub truncation, missing endpoints | Known-fixture expected IDs and provenance |
| Tenant isolation | SQL/FTS/vector/graph/direct-label access and joins | Zero cross-tenant results as restricted non-owner roles |
| Pool isolation | Tenant changes, cancellation, errors, backend reassignment | No leaked context; preparation and AGE initialization work |
| Recovery | Clean restore and extension upgrade rehearsal | Structural, role, known-query and replay checks pass |
| Load | Representative selectivity, graph density, concurrency and writes | Resource/latency/recall results under stated conditions |

## Included tests and their limits

The SQL lab supplies deterministic synthetic fixtures, a cross-model rollback
check, and selected RLS assertions. It is opt-in and requires an approved disposable
PG18 database. Role setup changes cluster-level role state and is a separate

share/skills/dbio-postgresql-age/SKILL.md  view on Meta::CPAN

  },
  ['ok'],
  { name => 'Alice', age => 30 },
);
```

Always parameterise user input — never interpolate.

## Edges

Match endpoints first, then create. Can combine create + create in one query.

```perl
$storage->cypher(
  'social',
  q{
    MATCH (a:Person {name: $from}), (b:Person {name: $to})
    CREATE (a)-[:KNOWS {since: $since}]->(b)
    RETURN 1
  },
  ['ok'],



( run in 2.013 seconds using v1.01-cache-2.11-cpan-eb134014566 )