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
92 changes: 92 additions & 0 deletions .github/workflows/emet-integrity-e9.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: EMET PhiOS integrity E9
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
jobs:
advisory:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: '22'
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: actions/checkout@v4
with:
repository: MichaelWave369/XiPhiOmega
ref: 16786d24b2d9e83cb090021273c12564cc27c910
path: dependencies/xpo
persist-credentials: false
- uses: actions/checkout@v4
with:
repository: MichaelWave369/PhiMemory9
ref: d6e5ab1bead458d9af37636d2e81782bf4314276
path: dependencies/xpo/dependencies/memory
persist-credentials: false
- uses: actions/checkout@v4
with:
repository: MichaelWave369/PhiGenesis
ref: e5996fd680ad39f051f31659a20f8d546f1c0991
path: dependencies/xpo/dependencies/genesis-e3
persist-credentials: false
- uses: actions/checkout@v4
with:
repository: MichaelWave369/PhiGenesis
ref: a58b4d25509d96c1c7a502cb82009def1f42a55a
path: dependencies/xpo/dependencies/genesis-e6
persist-credentials: false
- uses: actions/checkout@v4
with:
repository: MichaelWave369/NBGPocketMesh
ref: 0687f10970989194d4af554d9b189c7ce8a1ad15
path: dependencies/xpo/dependencies/mesh-e3
persist-credentials: false
- uses: actions/checkout@v4
with:
repository: MichaelWave369/NBGPocketMesh
ref: 7912d5bab40effb621906833f0ab83bad511018f
path: dependencies/xpo/dependencies/mesh-e4
persist-credentials: false
- uses: actions/checkout@v4
with:
repository: MichaelWave369/Altermath
ref: 919f3ec1fedb0f447d8bbec56cf9bccb7a4eecc8
path: dependencies/xpo/dependencies/altermath
persist-credentials: false
- run: python -m unittest discover -s tests -p test_emet_integrity_advisory.py -v
- name: Generate actual E8 report from merged native source
working-directory: dependencies/xpo
run: python scripts/emet_ecosystem.py generate dependencies ecosystem.json
- name: Consume actual E8 output and preserve HELD
shell: bash
run: |
set +e
python -m phios.emet_integrity_advisory dependencies/xpo/ecosystem.json > emet-phios-advisory.json
code=$?
set -e
test "$code" -eq 3
python - <<'PY'
import hashlib,json
from pathlib import Path
raw=Path("dependencies/xpo/ecosystem.json").read_bytes()
result=json.loads(Path("emet-phios-advisory.json").read_bytes())
assert result["report_sha256"]==hashlib.sha256(raw).hexdigest()
assert result["status"]=="HELD" and result["authority"]=="NONE" and result["release"]=="BLOCKED"
assert result["contract_matched"] is True and result["evidence_verified"] is False
assert result["execution_authorized"] is False and result["live_ready"] is False
assert len(result["stage_declarations"])==7 and len(result["limitations"])==8
assert all(v is False for v in result["limitations"].values())
PY
- uses: actions/upload-artifact@v4
with:
name: emet-phios-integrity-advisory
path: emet-phios-advisory.json
if-no-files-found: error
22 changes: 22 additions & 0 deletions docs/EMET_INTEGRITY_ADVISORY_E9.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# EMET Embodiment E9 — PhiOS integrity advisory

Synthetic, read-only, HELD / NONE / BLOCKED. Final planned Embodiment implementation gate; see [central tracker](https://github.com/MichaelWave369/XiPhiOmega/issues/19). The independent PhiOS consumer recognizes precisely the E8 report contract from [XiPhiOmega merged revision](https://github.com/MichaelWave369/XiPhiOmega/tree/16786d24b2d9e83cb090021273c12564cc27c910). It does not import the producer or trust caller-selected source revisions.

## Contract

The frozen canonical byte representation includes seven stage declarations, six native dependency pins and eight explicitly false qualification flags. Exact equality intentionally refuses unknown fields, duplicate keys, noncanonical serialization, integer/Boolean substitution, removed or reordered stages, altered source/dependency revisions, hidden information loss and authority promotion. This narrow version is not a generic JSON interchange parser. A future reviewed version may add a new pinned contract; no automatic migration.

Review emits a separate PhiOS advisory with contract_matched=true, evidence_verified=false, execution_authorized=false, live_ready=false and all eight limitations preserved. A SHA-256 of the minimized input identifies bytes, not their provenance. Anyone can reproduce those bytes without running the tests. Never describe contract match as authenticated execution. Invalid inputs produce a generic non-echoing refusal. No permission, registry, ledger, execution, memory, kernel, UI or service writes. The CLI reads at most 16 KiB plus one byte from a regular non-symlink file; cooperative filesystem assumptions apply, not hostile concurrent filesystem isolation.

## Reproduce

From PhiOS root, Python 3.12:
```sh
python -m unittest discover -s tests -p test_emet_integrity_advisory.py -v
python -m phios.emet_integrity_advisory /path/to/merged-e8-ecosystem.json
```
Exit 3 = valid but HELD, deliberately nonzero. Exit 2 = invalid. Use an E8 report freshly generated at the exact merged XiPhiOmega revision, not its previous PR-head artifact, which declares a different revision. The CI checks out merged XiPhiOmega and its six reviewed native dependency revisions, runs actual E8 generation (not its report template), then invokes the real PhiOS CLI and checks the separate advisory. Only the minimized PhiOS advisory is uploaded. Unit controls include sixteen field mutations and six invalid byte inputs, CLI no-write and non-echo behavior, and size refusal.

## Limits and closure

E9 adds an operator-invoked CLI, not a desktop panel or automatic runtime integration. No production authority, independent trust custody, factual independence, physical erasure, external copy erasure, personal hardware qualification, live runtime integration or integrated cross-platform rerun is established. E8 is Linux-only; E1/E7 dual-platform results remain separately scoped. External review, independent maintainer reproduction and operational governance are still open. All previous research algorithms and existing PhiOS advisory APIs remain unchanged.
89 changes: 89 additions & 0 deletions phios/emet_integrity_advisory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
"""Read-only EMET E8 advisory consumer. Never grants or attests execution."""
import argparse
import hashlib
import json
from pathlib import Path

SOURCE_REVISION = "16786d24b2d9e83cb090021273c12564cc27c910"
MAX_BYTES = 16384

def expected_report():
# Independent consumer contract, frozen at the reviewed E8 merge.
return {
"schema":"xpo.emet.ecosystem.e8.v1",
"synthetic":True, "authority":"NONE", "status":"HELD", "release":"BLOCKED",
"source_revision":SOURCE_REVISION,
"dependency_revisions":{
"memory":"d6e5ab1bead458d9af37636d2e81782bf4314276",
"genesis-e3":"e5996fd680ad39f051f31659a20f8d546f1c0991",
"genesis-e6":"a58b4d25509d96c1c7a502cb82009def1f42a55a",
"mesh-e3":"0687f10970989194d4af554d9b189c7ce8a1ad15",
"mesh-e4":"7912d5bab40effb621906833f0ab83bad511018f",
"altermath":"919f3ec1fedb0f447d8bbec56cf9bccb7a4eecc8",
},
"stages":[
dict(id=i,name=n,coverage=c,observations=o,result="FIXTURE_PASSED")
for i,n,c,o in (
("E1","reference-lab","single-host regeneration",{"reference_records":213}),
("E2","memory-witness","native fixture",{"fixture_passed":True}),
("E3","execution-coverage","native fixture",{"fixture_passed":True}),
("E4","declared-lineage","native fixture and Python oracle",{"records":9,"refusals":6}),
("E5","semantic-continuity","native fixture and Python oracle",
{"preserved":5648,"information_lost":2032,"refusals":9}),
("E6","fragment-recovery","native fixture and Python oracle",{"matched":9,"refusals":22}),
("E7","governed-forgetting","native fixture, minimized report",{"scenarios":10}),
)
],
"limitations":{key:False for key in (
"execution_authorized","independent_custody_established",
"independent_observation_established","physical_erasure_verified",
"external_copy_erasure_verified","live_integration_verified",
"personal_hardware_verified","cross_platform_rerun_in_this_report")},
"integrity":"self-reported execution summary; not authenticated attestation",
}

def canonical(value):
return json.dumps(value,sort_keys=True,separators=(",",":"),ensure_ascii=True,allow_nan=False).encode("ascii")

def review(raw):
"""Accept only exact canonical E8 bytes; all declarations remain untrusted."""
if type(raw) is not bytes or not 0 < len(raw) <= MAX_BYTES:
raise ValueError("invalid report size or type")
expected = expected_report()
# Exact-byte contract avoids duplicate keys, type coercion and hidden fields.
# No untrusted JSON parser or echo is necessary for this frozen version.
if raw != canonical(expected)+b"\n":
raise ValueError("report differs from frozen E8 contract")
return dict(schema="phios-emet-integrity-advisory/v1",status="HELD",authority="NONE",
release="BLOCKED",synthetic=True,contract_matched=True,
evidence_verified=False,execution_authorized=False,live_ready=False,
source_revision=SOURCE_REVISION,report_sha256=hashlib.sha256(raw).hexdigest(),
stage_declarations=expected["stages"],limitations=expected["limitations"],
reason="unsigned_fixture_declarations_require_independent_review")

def load_report(path):
path=Path(path)
if path.is_symlink() or not path.is_file():
raise ValueError("regular report file required")
with path.open("rb") as f:
raw=f.read(MAX_BYTES+1)
if len(raw)>MAX_BYTES:
raise ValueError("report size")
return raw

def main():
parser=argparse.ArgumentParser(description=__doc__)
parser.add_argument("report",type=Path)
args=parser.parse_args()
try:
result=review(load_report(args.report))
except (OSError,ValueError,TypeError):
print(json.dumps(dict(status="INVALID",authority="NONE",release="BLOCKED",
evidence_verified=False,execution_authorized=False,
reason="invalid_emet_advisory")))
return 2
print(json.dumps(result,sort_keys=True,indent=2))
return 3

if __name__=="__main__":
raise SystemExit(main())
74 changes: 74 additions & 0 deletions tests/test_emet_integrity_advisory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import copy
import json
from pathlib import Path
import subprocess
import sys
import tempfile
import unittest

from phios.emet_integrity_advisory import expected_report,canonical,review,load_report

def wire(x):
return canonical(x)+b"\n"

class EmetIntegrityTests(unittest.TestCase):
def test_held(self):
raw=wire(expected_report())
result=review(raw)
self.assertEqual(result["status"],"HELD")
self.assertEqual(result["authority"],"NONE")
self.assertEqual(result["release"],"BLOCKED")
self.assertTrue(result["contract_matched"])
for key in ("evidence_verified","execution_authorized","live_ready"):
self.assertIs(result[key],False)
self.assertEqual(len(result["stage_declarations"]),7)
self.assertEqual(len(result["limitations"]),8)
self.assertTrue(all(x is False for x in result["limitations"].values()))
def test_promotions_and_drift(self):
for edit in (
lambda x:x.update(authority="EXECUTE"),
lambda x:x.update(status="APPROVED"),
lambda x:x.update(release="READY"),
lambda x:x.update(synthetic=1),
lambda x:x.update(source_revision="0"*40),
lambda x:x["dependency_revisions"].update(memory="0"*40),
lambda x:x["stages"].pop(),
lambda x:x["stages"].append(x["stages"][0]),
lambda x:x["stages"].reverse(),
lambda x:x["stages"][1]["observations"].update(fixture_passed=1),
lambda x:x["stages"][4]["observations"].update(information_lost=0),
lambda x:x["stages"][0].update(result="ATTESTED"),
lambda x:x["limitations"].update(physical_erasure_verified=True),
lambda x:x["limitations"].update(execution_authorized=0),
lambda x:x.update(payload="not retained"),
lambda x:x["limitations"].pop("independent_custody_established"),
):
candidate=expected_report()
edit(candidate)
with self.assertRaises(ValueError):
review(wire(candidate))
for raw in (b"",b"x"*16385,b"{}\n",wire(expected_report())[:-1],
b'{"authority":"NONE","authority":"NONE"}\n',
json.dumps(expected_report(),indent=2).encode()+b"\n"):
with self.assertRaises(ValueError):
review(raw)
def test_read_only_cli(self):
with tempfile.TemporaryDirectory() as tmp:
path=Path(tmp)/"report.json"
raw=wire(expected_report())
path.write_bytes(raw)
result=subprocess.run([sys.executable,"-m","phios.emet_integrity_advisory",str(path)],capture_output=True,check=False)
self.assertEqual(result.returncode,3)
self.assertEqual(json.loads(result.stdout)["status"],"HELD")
self.assertEqual(path.read_bytes(),raw)
path.write_bytes(b'{"payload":"DO_NOT_ECHO"}')
result=subprocess.run([sys.executable,"-m","phios.emet_integrity_advisory",str(path)],capture_output=True,check=False)
self.assertEqual(result.returncode,2)
self.assertNotIn(b"DO_NOT_ECHO",result.stdout+result.stderr)
self.assertEqual(json.loads(result.stdout)["authority"],"NONE")
path.write_bytes(b"x"*16385)
with self.assertRaises(ValueError):
load_report(path)

if __name__=="__main__":
unittest.main()
Loading