Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
44486eb
refactor(store): read the command-pack activation slot in the native …
internet-dot Nov 22, 2026
eecc8f9
fix(store): refuse a non-text activation slot state
internet-dot Nov 22, 2026
4655765
fix(store): share the schema marker check between the authority write…
internet-dot Nov 22, 2026
e46f559
refactor(store): check the extension control schema marker in the nat…
internet-dot Nov 22, 2026
da4f585
refactor(store): name a refused activation slot's error code in the n…
internet-dot Nov 22, 2026
f21bbdd
Merge remote-tracking branch 'origin/feat/native-runtime-slice42' int…
internet-dot Nov 22, 2026
641ef32
chore(contracts): map the extension control schema reader in the owne…
internet-dot Nov 22, 2026
75d0b3c
refactor(store): read the committed extension control snapshot in the…
internet-dot Nov 22, 2026
a458375
refactor(store): resume transitions and read the upgrade's activation…
internet-dot Nov 22, 2026
da84eed
refactor(store): read the cache cleanup's activation records in the n…
internet-dot Nov 22, 2026
5b33acb
refactor(store): read the pack migration's legacy evidence in the nat…
internet-dot Nov 22, 2026
5fd5359
refactor(store): read the extension control head for recovery in the …
internet-dot Nov 22, 2026
e918ad2
test(store): expect the snapshot layers read on the snapshot route
internet-dot Nov 22, 2026
ec4ca4f
Merge branch 'feat/native-runtime-slice46' into feat/native-runtime-s…
internet-dot Nov 22, 2026
7591d83
Merge branch 'feat/native-runtime-slice47' into feat/native-runtime-s…
internet-dot Nov 22, 2026
7331033
test(store): expect the new native reads on the snapshot route
internet-dot Nov 22, 2026
534b718
Merge branch 'feat/native-runtime-slice48' into feat/native-runtime-s…
internet-dot Nov 22, 2026
b51fd89
test(store): expect the new native reads on the snapshot route
internet-dot Nov 22, 2026
612e982
test(store): expect the new native reads on the snapshot route
internet-dot Nov 22, 2026
65af8ba
refactor(store): read catalog migration events and the pack baseline …
internet-dot Nov 22, 2026
ca4fdab
Merge remote-tracking branch 'origin/main' into feat/native-runtime-s…
internet-dot Nov 22, 2026
5a772eb
fix(store): read the snapshot on the shared connection inside an MCP …
internet-dot Nov 22, 2026
95b5127
fix(store): read the extension control head on the shared connection …
internet-dot Nov 22, 2026
3205f81
Merge branch 'feat/native-runtime-slice46' into feat/native-runtime-s…
internet-dot Nov 22, 2026
91cd8c8
Merge branch 'feat/native-runtime-slice47' into feat/native-runtime-s…
internet-dot Nov 22, 2026
b21a067
Merge branch 'feat/native-runtime-slice48' into feat/native-runtime-s…
internet-dot Nov 22, 2026
a891ce5
Merge branch 'feat/native-runtime-slice49' into feat/native-runtime-s…
internet-dot Nov 22, 2026
651c53c
fix(store): budget legacy history pages on the encoded reply and stop…
internet-dot Nov 22, 2026
20295bf
fix(store): answer the scoped extension control head read as the nati…
internet-dot Nov 22, 2026
3e0f05e
Merge remote-tracking branch 'origin/feat/native-runtime-slice48' int…
internet-dot Nov 22, 2026
73bb6a0
Merge remote-tracking branch 'origin/feat/native-runtime-slice49' int…
internet-dot Nov 22, 2026
2864e9c
docs(guard): record the scoped extension control reads as a temporary…
internet-dot Nov 22, 2026
e3f414f
Merge remote-tracking branch 'origin/feat/native-runtime-slice49' int…
internet-dot Nov 22, 2026
6b624ed
fix(store): let an unusable anchor revision select no legacy pending row
internet-dot Nov 22, 2026
0297abf
Merge remote-tracking branch 'origin/feat/native-runtime-slice48' int…
internet-dot Nov 22, 2026
8ffd933
Merge remote-tracking branch 'origin/feat/native-runtime-slice49' int…
internet-dot Nov 22, 2026
667a34a
test(store): answer the pending-record list in the activation fixture…
internet-dot Nov 22, 2026
3ae77a5
Merge remote-tracking branch 'origin/feat/native-runtime-slice47' int…
internet-dot Nov 22, 2026
d199c1a
Merge remote-tracking branch 'origin/feat/native-runtime-slice48' int…
internet-dot Nov 22, 2026
b216d67
Merge remote-tracking branch 'origin/feat/native-runtime-slice49' int…
internet-dot Nov 22, 2026
1ec6934
Merge remote-tracking branch 'origin/main' into feat/native-runtime-s…
internet-dot Nov 22, 2026
6e1db5c
Merge remote-tracking branch 'origin/main' into feat/native-runtime-s…
internet-dot Nov 22, 2026
d673b1d
fix(store): page the pending command-pack records so cleanup reads ev…
internet-dot Nov 22, 2026
c6d2630
Merge remote-tracking branch 'origin/main' into feat/native-runtime-s…
internet-dot Nov 22, 2026
2a7b288
Merge branch 'feat/native-runtime-slice49' of https://github.com/hash…
internet-dot Nov 22, 2026
160c681
merge(main): resolve command pack slot conflicts
internet-dot Nov 22, 2026
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
Prev Previous commit
Next Next commit
fix(store): share the schema marker check between the authority write…
…r and the slot read
  • Loading branch information
internet-dot committed Nov 22, 2026
commit 4655765a18cabbd58962c7de7bef8051dea85ead
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ mod tests;
mod view;
mod writes;

pub(crate) use schema::{compatible_marker, FIRST_PACK_SCHEMA_VERSION};

use std::cell::RefCell;

use base64ct::{Base64UrlUnpadded, Encoding};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ const AUTHORITY_INPUT_TABLES: [(&str, Option<&str>); 8] = [
),
];

/// The first schema version with a command-pack activation slot.
pub(crate) const FIRST_PACK_SCHEMA_VERSION: i64 = PACK_SCHEMA_VERSIONS[0];

/// Whether a stored marker names a schema version this build knows and
/// carries that version's checksum. The writer and the native slot read both
/// ask this, so a schema bump changes one place.
pub(crate) fn compatible_marker(version: i64, found: &str) -> bool {
(1..=PACK_SCHEMA_VERSIONS[1]).contains(&version) && found == checksum(version)
}

fn checksum(version: i64) -> String {
hex::encode(Sha256::digest(
format!("hol-guard.extension-control-authority.schema.v{version}").as_bytes(),
Expand Down Expand Up @@ -182,9 +192,7 @@ pub(super) fn ensure_schema(connection: &Connection, wanted: i64) -> Res<()> {
)
.map_err(store_fault)?;
}
Some((Some(version), Some(found)))
if (1..=PACK_SCHEMA_VERSIONS[1]).contains(&version) && found == checksum(version) =>
{
Some((Some(version), Some(found))) if compatible_marker(version, &found) => {
packs |= PACK_SCHEMA_VERSIONS.contains(&version);
if version < wanted {
connection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@

use rusqlite::Connection;
use serde_json::{json, Map, Value};
use sha2::{Digest, Sha256};

use crate::extension_control_authority_op::{compatible_marker, FIRST_PACK_SCHEMA_VERSION};
use crate::guard_store_db::{query_one, StoreResult};
use crate::guard_store_local_cli_inventory::table_exists;

/// The first schema version with an activation slot.
const PACK_ACTIVATION_SCHEMA_VERSION: i64 = 5;
/// Every schema version a marker may name.
const KNOWN_VERSIONS: std::ops::RangeInclusive<i64> = 1..=6;
const SLOT_FIELDS: [&str; 5] = [
"revision",
"record_json",
Expand All @@ -47,7 +43,7 @@ pub(crate) fn read(connection: &Connection) -> StoreResult<Value> {
let Some(version) = marker.as_ref().and_then(compatible_version) else {
return Ok(state("schema_invalid"));
};
if version < PACK_ACTIVATION_SCHEMA_VERSION {
if version < FIRST_PACK_SCHEMA_VERSION {
return Ok(state("absent"));
}
let slot = query_one(
Expand Down Expand Up @@ -78,21 +74,11 @@ fn state(name: &str) -> Value {
}

/// The marker's version when it carries an integer version and the checksum
/// of that version's schema, as `extension_control_schema_marker_is_compatible`
/// required.
/// of that version's schema, the same test the authority writer applies.
fn compatible_version(marker: &crate::guard_store_db::Row) -> Option<i64> {
let version = marker.get("version").and_then(Value::as_i64)?;
let checksum = marker.get("checksum").and_then(Value::as_str)?;
if !KNOWN_VERSIONS.contains(&version) || checksum != schema_checksum(version) {
return None;
}
Some(version)
}

fn schema_checksum(version: i64) -> String {
hex::encode(Sha256::digest(
format!("hol-guard.extension-control-authority.schema.v{version}").as_bytes(),
))
compatible_marker(version, checksum).then_some(version)
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use rusqlite::{params, Connection};
use serde_json::json;

use super::{handles, read, schema_checksum};
use sha2::{Digest, Sha256};

use super::{handles, read};
use crate::guard_store_op_kind::{method_kind, Kind};

fn store() -> Connection {
Expand Down Expand Up @@ -112,3 +114,11 @@ fn a_filled_slot_comes_back_as_stored() {
}})
);
}

/// The marker checksum the authority writer stores, spelled out so a change
/// to its format fails here too.
fn schema_checksum(version: i64) -> String {
hex::encode(Sha256::digest(
format!("hol-guard.extension-control-authority.schema.v{version}").as_bytes(),
))
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def read_slot(store):
"""The stored activation slot, read by the native store, or None before the pack schema.

The row is returned unauthenticated; callers verify it with their key.
The native read decides the state. This only turns its four states into
the errors the Python callers already raise and refuses any other answer
shape, because the record it hands on gates which command packs run.
"""
method = "read_command_pack_activation"
answer = store._native_store_call(method, {})
Expand Down
1 change: 1 addition & 0 deletions tests/test_native_pack_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ def test_db_loss_and_missing_release_cannot_fall_back_to_legacy_controls(protect
from codex_plugin_scanner.guard.extension_controls import extension_control_prepared as candidates

protected._connect = lambda: sqlite3.connect(":memory:")
protected._native_store_call = activation_slot_call(protected._connect)
monkeypatch.setattr(candidates, "load_installed_bundle", lambda: None)
with pytest.raises(ValueError, match="pack_authority_unavailable"):
candidates.prepare_candidate(protected, None, None, ())
Expand Down
Loading