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
7 changes: 6 additions & 1 deletion docs/system-specs/modules/acp-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -5455,7 +5455,12 @@ the refusal names its cause on an offline host too and a spawn that asks again m
no network round trip. Which
version runs is the release's pin, not a file on disk: `acp/kas_pin.py` holds
`KAS_PIN_VERSION` and `KAS_PIN_MANIFEST_SHA256` (the sha256 of that version's
published `manifest.json`, which in turn pins every artifact), `kirocrew kas
published `manifest.json`, which in turn pins every artifact). The version is
an engine release, optionally followed by `-node<N>` when the same engine build
is republished with a different bundled Node runtime (a Node security fix is
never an overwrite of a published `kas/<version>/` key); `KAS_PIN_ENGINE_RELEASE`
is the part before the suffix, and anything comparing engine versions reads that,
never the directory name. `kirocrew kas
install` installs exactly that and refuses a manifest whose bytes do not hash to
the pin, and `installed_bundle()` looks up exactly that version's directory --
under the data home's `engines/kas` first, then under the desktop app's staged
Expand Down
14 changes: 11 additions & 3 deletions src/kiro_crew/acp/kas_pin.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import os

__all__ = [
"KAS_PIN_ENGINE_RELEASE",
"KAS_PIN_MANIFEST_SHA256",
"KAS_PIN_VERSION",
"KAS_SPEC_PERMISSIONS_MIN_ENGINE_VERSION",
Expand All @@ -45,11 +46,18 @@
"pinned_version",
]

#: Engine version this release runs.
KAS_PIN_VERSION = "0.66.117"
#: Engine version this release runs. A ``-node<N>`` suffix names a republish of
#: the same engine build with a different bundled Node runtime; the engine release
#: is the part before it.
KAS_PIN_VERSION = "0.66.117-node22.23.4"

#: The engine release the pin runs: :data:`KAS_PIN_VERSION` without its
#: ``-node<N>`` suffix. This is the version the engine reports about itself, so
#: anything comparing engine versions reads this, never the directory name.
KAS_PIN_ENGINE_RELEASE = KAS_PIN_VERSION.split("-node", 1)[0]

#: sha256 of ``<base>/kas/<KAS_PIN_VERSION>/manifest.json`` as published.
KAS_PIN_MANIFEST_SHA256 = "76957b7dbc1acbc6669f59e67bd43a0f92810f9ac8fc6d71981f8d842485b08a"
KAS_PIN_MANIFEST_SHA256 = "58600c49bdd758709982051b11043f0f91194b9fe0dfa1cfd34d086ea341d95e"

#: The engine and Node build keys the pinned manifest publishes, the matrix
#: ``scripts/kas_bundle_publish.py`` builds. Read without the network, so a host
Expand Down
26 changes: 22 additions & 4 deletions test/test_kas_pin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,27 @@

from kiro_crew.acp import kas_pin

_SEMVER = re.compile(r"^\d+\.\d+\.\d+$")
#: An engine release, optionally followed by the Node runtime a republish of that
#: same engine build bundles (``0.66.117-node22.23.4``).
_PIN_VERSION = re.compile(r"^\d+\.\d+\.\d+(?:-node\d+\.\d+\.\d+)?$")
_SHA256_HEX = re.compile(r"^[0-9a-f]{64}$")


def test_the_pinned_version_is_a_plain_semver() -> None:
def test_the_pinned_version_is_a_release_with_an_optional_node_suffix() -> None:
# The version is a directory name under ``<base>/kas/`` and under the data
# home's ``engines/kas/``; a prerelease suffix or a stray character there is a
# home's ``engines/kas/``; any other suffix or a stray character there is a
# path, not a release.
assert _SEMVER.match(kas_pin.KAS_PIN_VERSION), kas_pin.KAS_PIN_VERSION
assert _PIN_VERSION.match(kas_pin.KAS_PIN_VERSION), kas_pin.KAS_PIN_VERSION


@pytest.mark.parametrize("version", ["0.66.117", "0.66.117-node22.23.4"])
def test_the_pin_version_shape_accepts_a_release_and_a_node_republish(version: str) -> None:
assert _PIN_VERSION.match(version)


@pytest.mark.parametrize("version", ["0.66.117-rc.1", "0.66.117-node22", "v0.66.117", "0.66"])
def test_the_pin_version_shape_refuses_anything_else(version: str) -> None:
assert not _PIN_VERSION.match(version)


def test_the_manifest_digest_is_a_lowercase_sha256() -> None:
Expand All @@ -43,8 +55,14 @@ def test_pinned_version_is_the_pin_unless_the_gateway_env_overrides_it(
assert kas_pin.pinned_version() == "0.70.1"


def test_the_engine_release_is_the_pin_without_its_node_suffix() -> None:
assert re.fullmatch(r"\d+\.\d+\.\d+", kas_pin.KAS_PIN_ENGINE_RELEASE)
assert kas_pin.KAS_PIN_VERSION.startswith(kas_pin.KAS_PIN_ENGINE_RELEASE)


def test_the_public_surface_is_exactly_the_pin_and_the_engine_gate() -> None:
assert sorted(kas_pin.__all__) == [
"KAS_PIN_ENGINE_RELEASE",
"KAS_PIN_MANIFEST_SHA256",
"KAS_PIN_VERSION",
"KAS_SPEC_PERMISSIONS_MIN_ENGINE_VERSION",
Expand Down
14 changes: 7 additions & 7 deletions test/test_real_adapter_fixture_pins.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
)

from kiro_crew.acp.client_turn_control import KIRO_CLI_TESTED_RANGE
from kiro_crew.acp.kas_pin import KAS_PIN_VERSION
from kiro_crew.acp.kas_pin import KAS_PIN_ENGINE_RELEASE
from kiro_crew.agent_sdk.backends_launch import COPILOT_VERIFIED_VERSION
from kiro_crew.kiro_cli import (
MANDATORY_MCPS_DROP_MIN_VERSION,
Expand Down Expand Up @@ -254,7 +254,7 @@ def _release(version: str) -> tuple[int, ...] | None:
#: name the kiro-cli they ran under are held to the kiro-cli floor too.
#:
#: A KAS capture marked ``route: kas-bundle`` ran Crew's own pinned engine, so it is
#: held to ``KAS_PIN_VERSION`` (``_KAS_BUNDLE_ROUTE``). Every other KAS capture ran
#: held to ``KAS_PIN_ENGINE_RELEASE`` (``_KAS_BUNDLE_ROUTE``). Every other KAS capture ran
#: through kiro-cli's relay, which runs the engine kiro-cli ships rather than the
#: pin, so a pin bump cannot move it; it is held to ``_KAS_RELAY_ENGINE_FLOOR``,
#: which rises only by re-capturing on a newer kiro-cli.
Expand All @@ -270,7 +270,7 @@ def _release(version: str) -> tuple[int, ...] | None:
def _floor_for(directory: str, meta: dict, header: str, floor: str) -> str:
"""*floor*, or the bundle pin for a KAS capture made off Crew's own engine."""
if directory == "kas" and header == "agent_version" and meta.get("route") == _KAS_BUNDLE_ROUTE:
return KAS_PIN_VERSION
return KAS_PIN_ENGINE_RELEASE
return floor


Expand Down Expand Up @@ -372,7 +372,7 @@ def test_the_floor_reds_on_each_drift(version, allowed, expected) -> None:
def test_a_kas_capture_under_an_old_kiro_cli_reds(tmp_path) -> None:
"""A KAS header's ``kiro_cli_version`` is held to the kiro-cli floor, not only the engine."""
(tmp_path / "kas").mkdir()
meta = {"backend": "kas", "recorded": "live", "agent_version": KAS_PIN_VERSION}
meta = {"backend": "kas", "recorded": "live", "agent_version": KAS_PIN_ENGINE_RELEASE}
(tmp_path / "kas" / "a-live.jsonl").write_text(
json.dumps({"_meta": dict(meta, kiro_cli_version="2.20.0")}) + "\n"
)
Expand All @@ -384,7 +384,7 @@ def test_a_kas_capture_under_an_old_kiro_cli_reds(tmp_path) -> None:
@pytest.mark.parametrize(
("route", "version", "floor"),
[
(_KAS_BUNDLE_ROUTE, "0.66.33", KAS_PIN_VERSION),
(_KAS_BUNDLE_ROUTE, "0.66.33", KAS_PIN_ENGINE_RELEASE),
(None, "0.66.32", _KAS_RELAY_ENGINE_FLOOR),
],
ids=["bundle-held-to-pin", "relay-held-to-relay-floor"],
Expand Down Expand Up @@ -449,7 +449,7 @@ def test_a_capture_on_the_next_kiro_cli_major_reds(tmp_path) -> None:

def test_the_relay_floor_never_passes_the_pin() -> None:
"""The relay floor is a floor for engines older than the pin, never above it."""
assert _release(_KAS_RELAY_ENGINE_FLOOR) <= _release(KAS_PIN_VERSION)
assert _release(_KAS_RELAY_ENGINE_FLOOR) <= _release(KAS_PIN_ENGINE_RELEASE)


def test_another_adapters_capture_in_copilot_reds(monkeypatch, tmp_path) -> None:
Expand Down Expand Up @@ -657,7 +657,7 @@ def test_a_new_stale_synthesized_fixture_reds(tmp_path) -> None:

def test_a_kas_note_is_held_on_both_headers(tmp_path) -> None:
"""A KAS note naming an old kiro-cli reds on that header even with a current engine."""
note = f"KAS {KAS_PIN_VERSION} under kiro-cli 2.20.0"
note = f"KAS {KAS_PIN_ENGINE_RELEASE} under kiro-cli 2.20.0"
_write_synthesized(tmp_path, "kas", "a.jsonl", agent_version="unmeasured", note=note)
problems = synthesized_behind(_synthesized_versions(tmp_path), {})
assert [p.split(" ", 1)[0] for p in problems] == ["kas/a.jsonl:kiro_cli_version"]
Expand Down
Loading