Skip to content
Open
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ strip = "symbols"
async-stream = "0.3"
argon2 = "0.5"
axum = { version = "0.8", features = ["macros"] }
chrono = { version = "0.4", default-features = false, features = ["std"] }
futures-util = "0.3"
httpdate = "1"
jsonschema = { version = "0.48", default-features = false }
Expand Down
12 changes: 10 additions & 2 deletions docs/RUNTIME_ADAPTER.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ credential is not serializable and is redacted from debug output and upstream
errors. Configuration-file loading, scheduling, and storage are intentionally
outside this client boundary.

Accepted Compute observations can be persisted through the Enterprise Ledger.
PostgreSQL keeps immutable, identity-constrained snapshot history and the test
backend provides matching in-memory semantics. Exact retries are idempotent;
conflicting reuse of an adapter snapshot identity or observation timestamp is
rejected. The latest query derives `fresh`, `stale`, or `unavailable` from the
validated observation time, server time, and a bounded server-owned policy.
Derived state never changes the stored Runtime Adapter document.

## Capability Rules

Every document has `apiVersion: runtime.modelport.io/v1alpha1`,
Expand Down Expand Up @@ -100,8 +108,8 @@ reinterpreted across versions. Additive experimental data belongs in
`local-inference-stack` checker remains an explicitly selected compatibility
mode, not the source of this contract.

Configuration integration, collection policy, persistence, derived freshness,
admin APIs, and all writes remain deferred to reviewed Issues. Offline
Configuration integration, collection scheduling, retention, admin APIs, and
all writes remain deferred to reviewed Issues. Offline
validation cannot start a process, download a model, access a GPU, or call a
network endpoint; the collection client performs only the two advertised safe
reads requested by its caller.
25 changes: 25 additions & 0 deletions migrations/0014_runtime_compute_snapshots.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
CREATE TABLE modelport_runtime_compute_snapshots (
adapter_id TEXT NOT NULL,
snapshot_id TEXT NOT NULL,
observed_at TIMESTAMPTZ NOT NULL,
observed_at_key TEXT NOT NULL,
accepted_at TIMESTAMPTZ NOT NULL DEFAULT now(),
document JSONB NOT NULL,
PRIMARY KEY (adapter_id, snapshot_id),
CONSTRAINT modelport_runtime_compute_snapshots_observation_unique
UNIQUE (adapter_id, observed_at_key),
CONSTRAINT modelport_runtime_compute_snapshots_identity_check CHECK (
length(adapter_id) BETWEEN 1 AND 63
AND length(snapshot_id) BETWEEN 1 AND 160
AND length(observed_at_key) = 30
AND observed_at_key ~ '^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{9}Z$'
AND jsonb_typeof(document) = 'object'
AND document #>> '{metadata,adapterId}' = adapter_id
AND document #>> '{metadata,snapshotId}' = snapshot_id
AND observed_at = (document #>> '{metadata,observedAt}')::timestamptz
AND observed_at = observed_at_key::timestamptz
)
);

CREATE INDEX modelport_runtime_compute_snapshots_latest_idx
ON modelport_runtime_compute_snapshots (adapter_id, observed_at_key DESC, accepted_at DESC);
4 changes: 4 additions & 0 deletions src/enterprise_ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ use crate::{
usage::{current_period, quota_increment},
};

pub(crate) mod compute_inventory;

const DEFAULT_LEASE_TTL_SECS: u64 = 300;
const DEFAULT_RECONCILE_INTERVAL_SECS: u64 = 60;
const MIN_LEASE_TTL_SECS: u64 = 30;
Expand Down Expand Up @@ -76,6 +78,8 @@ struct MemoryLedger {
usage_reservations: HashMap<String, MemoryUsageReservation>,
budget_events: Vec<EnterpriseBudgetEvent>,
audit_events: Vec<EnterpriseAuditEvent>,
#[allow(dead_code)] // Used by the staged collection integration after this storage seam.
runtime_compute_snapshots: HashMap<(String, String), compute_inventory::MemoryComputeSnapshot>,
ops_incidents: BTreeMap<String, OpsIncidentDetail>,
ops_event_index: HashMap<String, String>,
ops_heartbeats: BTreeMap<String, OpsHeartbeat>,
Expand Down
Loading
Loading