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
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ jobs:
- name: Test installed package outside checkout
run: |
mkdir "$RUNNER_TEMP/qualification"
cp -R tests protocol "$RUNNER_TEMP/qualification/"
cp -R tests protocol scripts "$RUNNER_TEMP/qualification/"
cp pytest.ini "$RUNNER_TEMP/qualification/"
cd "$RUNNER_TEMP/qualification"
export EOA_VERIFIER_WHEEL="$(find "$GITHUB_WORKSPACE/dist" -name 'eoa_verifier-*.whl' -print -quit)"
anvil --version
"$RUNNER_TEMP/verifier-tests/bin/eoa-verifier" server start --help
"$RUNNER_TEMP/verifier-tests/bin/python" -m pytest -q tests
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,5 @@ its sole packaged schema, proof vectors, generator and conformance tests, plus
[verifier-api-v1](protocol/verifier-api-v1/README.md) and the shared signed
webhook/ACK profile. Oracle owns its selection/publication API; Comply owns the
registry ABI and calldata fixtures.

For an independent witnessed local environment, see [the integration commands](scripts/integration/README.md).
1 change: 1 addition & 0 deletions scripts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Repository-owned operational tools; excluded from application wheels."""
69 changes: 69 additions & 0 deletions scripts/integration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Standalone Verifier environment

Run from this repository root with Python 3.12.6+ and Anvil 1.5.1 on PATH. No
Oracle, Comply, Solidity checkout or external schema service is required.
Application code runs from an installed wheel in a run-owned virtual environment.

```sh
python -m scripts.integration.env prepare --run-dir /tmp/verifier-demo
python -m scripts.integration.env start --run-dir /tmp/verifier-demo
python -m scripts.integration.env flow --run-dir /tmp/verifier-demo
python -m scripts.integration.env status --run-dir /tmp/verifier-demo
python -m scripts.integration.env logs --run-dir /tmp/verifier-demo --service verifier
python -m scripts.integration.env stop --run-dir /tmp/verifier-demo
python -m scripts.integration.env start --run-dir /tmp/verifier-demo
python -m scripts.integration.env stop --run-dir /tmp/verifier-demo
python -m scripts.integration.env clean --run-dir /tmp/verifier-demo
```

`qualify --run-dir FRESH` performs prepare/start/flow/stop. Add `--local-only`
for target-free acceptance; use a fresh directory when changing mode. `flow`
requires an unused scenario: it issues associations, proves nonce reuse rejection,
loses one post-commit ACK, reopens persistent stores and verifies exact revocation.
Stop retains all state and logs. Start reuses identities, chain and acceptance;
it does not repeat issuance. Clean refuses live owned processes and removes only
the explicit stopped run. Never use an operator's KERI directory as a run root.
Keep run roots outside source checkouts. One controller operates a run at a time; there is no concurrent controller API.

Prepare defaults to six real native witness identities/listeners in one HIO
process. Issuance uses the first witness, matching the maintained credential
profile. `--witness-count 1` is the automated qualification topology. Six available
witnesses do not establish a six-witness credential qualification.

The run manifest records ports, public identities, source revision/content hash,
wheel hash and selected interpreter. Run-owned directories contain native issuer,
witness, receiver and Verifier stores, Anvil state, public CESR/JSON credentials,
source snapshots, wheels and append-only service logs. Source snapshots use Git's
tracked/unignored inventory, omit Git internals and ignored data, and reject
symlinks. Private keys remain inside native stores; the two numbered wallet keys
are public local test constants. Only loopback Anvil URLs are supported.

For a local candidate use `--verifier-source PATH` during preparation. For an
already built wheel supply `--verifier-wheel FILE --tool-revision REVISION` with
its matching tooling source. Those inputs are fixed for the lifetime of a run.
The installed-wheel suite uses this same interface outside the source checkout.

## Fixture boundary

```sh
python -m scripts.integration.env issue --run-dir RUN --wallet 1 --nonce fresh_nonce
python -m scripts.integration.env present --run-dir RUN --said SAID
python -m scripts.integration.env revoke --run-dir RUN --said SAID
```

Issue/revoke open native issuer contexts, wait for witnessed completion, export
exact bytes under `credentials/`, close the contexts, and return a JSON descriptor
on stdout. Progress goes to stderr. Present sends source-chain and credential
bytes to the public CESR endpoint. Neither operation writes application acceptance
records. Nonces are passed unchanged; issuance permits reuse so Verifier policy
can reject it during acceptance.

A caller owning the full stack can start this fixture with `--rpc-url URL
--webhook-url URL --webhook-aid AID --peer-kel FILE`. The caller owns that chain
and receiver; this mode starts neither Anvil nor the focused receipt fixture.
Repeat the original options on restart. Configuration changes require a new run.

The modules keep CLI dispatch, artifact/build selection, process lifetimes,
native infrastructure, issuer ceremonies and scenario assertions separate. Native
Habery/Regery contexts and Doist task ownership follow the pinned KERIpy patterns.
No tooling is included in the application wheel.
1 change: 1 addition & 0 deletions scripts/integration/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Standalone witnessed Verifier integration environment."""
124 changes: 124 additions & 0 deletions scripts/integration/artifacts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
"""Explicit JSON artifacts and isolated candidate source snapshots.

These helpers never copy Git internals, ignored operator data or live stores.
They record what was built so a local dirty candidate is distinguishable from a
published revision. They are tooling only, outside application wheels.
"""

import hashlib
import json
import os
from pathlib import Path
import shutil
import subprocess
import tempfile


def load_json(path: Path) -> dict:
"""Read an explicit UTF-8 JSON artifact; malformed or missing input fails."""
return json.loads(Path(path).read_text(encoding="utf-8"))


def save_json(path: Path, value) -> None:
"""Atomically replace one run-owned JSON file with private file permissions."""
path = Path(path)
with tempfile.NamedTemporaryFile(
mode="w",
encoding="utf-8",
dir=path.parent,
prefix=f".{path.name}-",
delete=False,
) as stream:
temporary = Path(stream.name)
json.dump(value, stream, indent=2)
stream.write("\n")
try:
os.chmod(temporary, 0o600)
temporary.replace(path)
finally:
temporary.unlink(missing_ok=True)


def source_revision(source: Path) -> str:
"""Return the exact base commit of an explicitly selected source checkout."""
return subprocess.check_output(
["git", "-C", str(source), "rev-parse", "HEAD"], text=True
).strip()


def snapshot_source(source: Path, destination: Path) -> dict:
"""Copy tracked and unignored candidate inputs, including recorded submodules.

The destination must be fresh. Git internals and ignored caches/stores are
excluded by Git's own file inventory; symlinks are refused rather than followed
into an operator directory. Return base revision and a content digest.
"""
source = source.resolve()
if destination.resolve().is_relative_to(source):
raise ValueError("Snapshot destination must be outside its source")
destination.mkdir(parents=True)
inputs = (
subprocess.check_output(
[
"git",
"-C",
str(source),
"ls-files",
"-z",
"--cached",
"--others",
"--exclude-standard",
]
)
.decode()
.split("\0")
)
digest = hashlib.sha256()
submodules = {}
for relative in sorted(set(filter(None, inputs))):
original, copied = source / relative, destination / relative
if original.is_symlink():
raise ValueError(f"Symlink source input is not supported: {original}")
if original.is_dir():
provenance = snapshot_source(original, copied)
submodules[relative] = provenance
digest.update(b"directory\0" + relative.encode() + b"\0")
digest.update(bytes.fromhex(provenance["sha256"]))
elif original.is_file():
copied.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(original, copied)
digest.update(b"file\0" + relative.encode() + b"\0")
digest.update(hashlib.sha256(original.read_bytes()).digest())
return {
"revision": source_revision(source),
"sha256": digest.hexdigest(),
"submodules": submodules,
}


def copy_tool_inputs(source: Path, destination: Path) -> dict:
"""Copy an external qualification root alongside an explicitly supplied wheel.

Such a root is deliberately outside Git and contains only owned tooling,
tests and protocol fixtures copied by the caller. Application code is supplied
by the wheel, never imported from this directory.
"""
if destination.resolve().is_relative_to(source.resolve()):
raise ValueError("Snapshot destination must be outside its source")
destination.mkdir(parents=True)
for name in ("scripts", "tests", "protocol"):
if (source / name).is_dir():
shutil.copytree(
source / name,
destination / name,
ignore=shutil.ignore_patterns("__pycache__", "*.pyc"),
)
for name in ("pytest.ini", "README.md"):
if (source / name).is_file():
shutil.copy2(source / name, destination / name)
digest = hashlib.sha256()
for path in sorted(destination.rglob("*")):
if path.is_file():
digest.update(str(path.relative_to(destination)).encode() + b"\0")
digest.update(hashlib.sha256(path.read_bytes()).digest())
return {"sha256": digest.hexdigest()}
75 changes: 75 additions & 0 deletions scripts/integration/builds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""Build a Verifier wheel and its isolated tooling environment from explicit inputs."""

import hashlib
from pathlib import Path
import shutil
import subprocess
import sys

from .artifacts import copy_tool_inputs, snapshot_source


def prepare_installation(
root: Path,
source: Path,
*,
wheel: Path | None = None,
tool_revision: str | None = None,
) -> dict:
"""Install a fresh wheel and return interpreter/tool paths plus provenance.

source is an explicit candidate checkout, or the copied qualification root
accompanying wheel. The latter requires tool_revision because it has no Git
metadata. Build/install output is retained in root/logs/build.log.
"""
snapshot = root / "tools/verifier"
if wheel is None:
provenance = snapshot_source(source, snapshot)
else:
if not tool_revision:
raise ValueError("--verifier-wheel requires --tool-revision")
provenance = (
snapshot_source(source, snapshot)
if (source / ".git").exists()
else copy_tool_inputs(source, snapshot)
)
provenance["revision"] = tool_revision
subprocess.run(
[sys.executable, "-m", "venv", "--symlinks", str(root / "venv")], check=True
)
python = str(root / "venv/bin/python")
with (root / "logs/build.log").open("w") as log:
if wheel is None:
subprocess.run(
[
python,
"-m",
"pip",
"wheel",
"--no-deps",
"--wheel-dir",
str(root / "wheels"),
str(snapshot),
],
check=True,
stdout=log,
stderr=log,
)
wheel = next((root / "wheels").glob("eoa_verifier-*.whl"))
else:
copied = root / "wheels" / wheel.name
shutil.copy2(wheel, copied)
wheel = copied
subprocess.run(
[python, "-m", "pip", "install", str(wheel) + "[test]"],
check=True,
stdout=log,
stderr=log,
)
return {
"python": python,
"tool": str(snapshot / "scripts/integration/env.py"),
"sourceRevision": provenance["revision"],
"sourceSha256": provenance["sha256"],
"wheelSha256": hashlib.sha256(wheel.read_bytes()).hexdigest(),
}
Loading
Loading