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
39 changes: 39 additions & 0 deletions docs/adr/0001_research_domain_storage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ADR 0001 — Shared logical domain views; deployment placement decision pending

**Status** Proposed for the reference design. Deployment placement awaits owner review and representative evidence. Refs #10, #11, and epic #4.

**Decision owner** Pending. An authorized deployment and data owner must accept or replace this decision after the representative-input gate.

## Context

A research domain is mutable, multi-label search metadata. It is neither a tenant grant, a relation endpoint type, an ontology, nor a graph community. Identity, full graph constraints, accepted publication, immutable source/evidence provenance and historical audit remain graph-wide within one trust/transaction boundary. A source can change domains, belong to several domains, or remain unclassified. Required identity and refutation closure crosses topical labels.

The reference work provides versioned classification operations inside the existing publication transaction and rebuildable indexes over its accepted snapshots. The live initiative has not supplied a selected deployment backend/owner, representative independently labeled data, isolation requirements, or agreed workload/SLOs. The measured fixture run is explicitly synthetic, small and single-host. It is not evidence of a production capacity limit or of a distribution benefit.

## Provisional choice

**Retain one accepted graph authority per trust/transaction boundary and shared logical research-domain views in the reference implementation.** Keep the domain index disposable and derived; use stable source, evidence, entity, assertion, assignment and taxonomy identities independent of topical routing. Do not split databases by research-domain label. This choice preserves the specified semantics without presupposing a production database product or deployment readiness.

The deployment owner must later choose the physical implementation from the preregistered workload and hard isolation needs. This ADR does not convert SQLite-reference into the deployment backend.

## Alternatives and decision triggers

| Option | Current disposition | Evidence needed / consequence |
|---|---|---|
| Shared logical graph in one authority | Reference choice | Qualify the selected backend's consistent reads, ACL enforcement, journal, restore and source epochs on representative workloads. Measure full graph validation and index/audit costs, not just lookup latency. |
| Dedicated storage for a hard trust/residency boundary | Conditional; not selected | An actual legal, tenancy, administrative or residency requirement with an owner. Dedicated storage is keyed to that boundary, not topical labels. Explicitly govern any authorized cross-boundary references and evidence transfer. |
| Measured physical sharding | Deferred; no implementation issue justified | A reproducible representative bottleneck after reasonable query/index/cache work, a measured benefit, and explicit routing/consistency/transaction costs. Synthetic fixtures and arbitrary node/edge thresholds cannot satisfy this trigger. |

Revisit when the backend and owner are selected; hard isolation requirements change; measured SLO or resource-pressure failures occur on representative peak/high-degree/churn workloads; or the accepted workload materially changes. A numeric node-count threshold is intentionally absent.

## Requirements before any physical split

The separately scoped implementation issue must define stable globally resolvable IDs and unchanged immutable source/evidence hashes; authenticated provenance and cross-partition identity/refutation links; a versioned routing map and routing epoch; a consistent graph/classification snapshot identity; present source-epoch and revocation propagation before every returned result; fail-closed timeouts, cancellation and unavailable-history behavior; idempotent publication through one authority; atomic visibility of graph-wide constraints, journal and projections; and consistent backup/restore including journal, trust-enrollment and revocation state.

A participant-local success cannot be a graph-wide commit. A search index cannot become another authority. Do not weaken publication constraints to avoid cross-partition validation, silently drop contradictory evidence, reinterpret current ACLs on historical reads, or rewrite identities when moving labels. Specify the actual commit/recovery protocol and test partial failures, not just the desired behavior. Any proposed dedicated or sharded layout requires its own security and operational evidence.

## Evidence and limitations

`trace_gc.retrieval.workloads` and `docs/research_domain_workloads.md` define reproducible measurements: latency p50/p95/p99, cross-domain transitions and writes, degree skew, ACL/audit/index cost, cache churn, source withdrawal and paired retrieval quality. The reproducible reference command exercises measurement plumbing and concurrent compare-and-swap, not a representative workload. Low sample counts and fixture-authored labels prohibit production-performance or accuracy conclusions. No sharding implementation issue was created because the required justification is absent.

#10 remains open until benchmark inputs, representative results, owner/SLOs and an accepted ADR are available. #11 and #4 remain open until actual deployment acceptance passes independently of these reference tests.
40 changes: 40 additions & 0 deletions docs/research_domain_workloads.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Domain workload measurement protocol

Refs #10. This is instrumentation and a reproducible **synthetic reference smoke**, not representative data, an independent-label experiment, a deployment SLO result, or a sharding justification.

## Reproduce the reference run

```sh
python -m trace_gc domain-workload --output domain-workload.json --repetitions 3 --workers 2
python -m unittest discover -s tests -p 'test_research_domain_workloads.py' -v
```

The command runs eight paired in-memory query cases per worker/repetition, then an authored scope denial and a separate disposable SQLite-reference publication/read phase. Query cases cover lexical/vector contradiction retrieval, paths and communities in scoped and unscoped forms. The SQLite phase measures append-only migration, multi-label assignment/reclassification, idempotent retries, read-index validation, cache reuse/churn, current withdrawal on historical reads, and two competing connections at the same graph version. Exactly one concurrent writer must commit; the stale rejection is not counted as a graph write.

The in-memory workers are same-process threads over copies of one immutable reference snapshot. They are not deployment-like clients, distributed replicas, or independent accepted graph authorities. No private corpus, trained model, provider credential, application deployment trust root, or production database is used.

## Metrics and limitations

`WorkloadRecorder`, `QueryCase`, `run_query_workload`, `measure_query` and `measure_publication` are reusable with an application's representative inputs and existing trusted services. The recorder does **not** create ACL grants or approve a publication. The publication wrapper requires ordinary signed preflight/authorization receipts. It reserves bounded telemetry capacity before execution, so capacity exhaustion cannot happen only after a successful write.

The reusable scheduler continues through recorded retrieval exceptions. Factory and measurement failures, including recorder capacity exhaustion, still fail the schedule. The standalone query measurement records retrieval exceptions and raises them to the caller.

Latency uses `perf_counter_ns`; percentiles use nearest rank and always carry sample counts. Queries include consistent authority reads, ACL checks, candidate generation, canonical revalidation and cache handling. Write latency measures the trusted publish/commit call, excluding caller plan preparation/signing. Committed, replayed and rejected publication samples remain distinguishable. Wall-clock rates cover in-memory query attempts and completions during the worker schedule, including worker setup and excluding the separate denial. The SQLite mixed-phase rate counts signed committed plans from initialization plan preparation through closure of the second writer connection. Its elapsed time includes index work, queries, retries and withdrawal. The numerator excludes the source-status transaction, replayed plans and rejected attempts.

ACL calls are counted by guard; only outermost nested guard wall time is timed, preventing double accounting. Measurement contexts are isolated across threads and reset on exceptions. These are opt-in, process-local observations, not changes to scientific records, snapshot identity or permissions. Instrumentation itself has overhead; no measured production-speed claim is made.

Domain transitions count executed path/community/required-closure hops. A transition may change membership while retaining an overlapping domain; disjoint domain hops and unclassified hops are separate counters. Revalidation may repeat a transition. These are not unique graph edges, network messages, remote transactions, or cross-shard RPCs. A cross-domain write means the union of exact pre/post source assignments touched by a signed plan has multiple taxonomy/domain pairs; it is a metadata-workload observation, not proof that storage crossed a partition.

Topology reports incident active original-assertion degrees, quantiles, Gini, and top-one-percent degree share. A test compares equal-sized star and chain graphs to ensure node count alone does not erase high-degree skew. Those test graphs are not a representative performance workload. The default small corpus does not exercise a deployment's high-degree tail.

Index observations include serialized source-row bytes, elapsed time and counts of source and membership rows. The harness measures explicit index materialization and rebuild separately through the phase-owned adapter operations. Retrieval remains read-only and distinguishes projection-only reads from verification of a persisted index. Full authority-audit time and SQLite `dbstat` B-tree bytes are also recorded when available. Database/WAL byte counts are not working-set measurements. Linux RSS observations are process-wide snapshots including the harness and imported modules, not an isolated query's allocation or a deployment memory requirement.

Cache hits/misses, invalidated entries and capacity evictions are distinct. A deliberately small cache exercises churn, not a recommended production cache size. Paired quality compares only the same case ID with/without scope; unlabeled path/community quality is reported as unavailable, not perfect. The lexical/vector fixture contains an explicitly authored cross-domain refutation: preserving it is a conformance check, not evidence of real scientific retrieval accuracy. The report tracks whether a structured conflict item carries both assertion IDs separately from whether both evidence IDs were returned. The withdrawal check pins the most recent classification that matches the biology query, even when the final classification does not. The same historical query must return the source and evidence before withdrawal and exclude the source afterward. The positive control is reported separately from the measured query count.

## Representative-input gate

Before running a placement study, the actual owner must preregister corpus/snapshot hashes, reviewed taxonomy and assignments, independently produced evidence/contradiction labels, query/write mixture, tenant/ACL distribution, source churn, high-degree tail, cache working set, expected concurrency, hardware/backend version, isolation/residency requirements, and latency/availability/recovery SLOs. Use the same authority snapshots, current revocation rules and labeled cases for every candidate storage option. Report misses, timeouts and rejected writes; do not report only successes. Freeze the protocol and train/tune/test split before inspecting outcomes.

An input manifest may identify `REPRESENTATIVE_CANDIDATE`, but that string or an owner name cannot mint representativeness, independent labels, or an acceptance receipt. The harness deliberately reports `MEASURED_NOT_QUALIFIED` and leaves qualification to explicit external review and the deployment gates. Store operational telemetry behind administrator access controls: even aggregate graph cardinality, query categories and hashes can be sensitive. Do not publish a representative corpus or telemetry without its owner's authorization.

The command stores individual per-operation measurements in the requested path. Keep detailed receipts in approved operational storage and publish only authorized aggregates. The default run is expected to record 56 query observations and 10 publication attempts, including four idempotent replays and one stale-version rejection. The fixed timestamp for authored queries pins the reference protocol. Timings and ephemeral receipt hashes can differ between runs. The September synthetic diagnostic recorded on [#10](https://github.com/Jev-Engineering/jraphyte/issues/10) used a separate protocol. See [ADR 0001](adr/0001_research_domain_storage.md) for the proposed reference choice and external decision gate.
Loading
Loading