Record reviewed case source evidence (2/13)
This commit is contained in:
parent
d8d63778f6
commit
0543257514
8 changed files with 5101 additions and 0 deletions
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"original_packet": "docs/changes/netkingdom-target-2026-10-17/nk48-catalog-fixture-publication-r1",
|
||||
"reason": "Normal Warden allocator committed one previously missing historical UUID; no code/source fixture changes. Original apply stopped before any writes.",
|
||||
"previous_warden_head": "ae7bc73b4f4bac22454144959b870d161498e0af",
|
||||
"current_warden_head": "922c26da0f3fcb0182352ea83e6ae06f29878580",
|
||||
"only_head_delta_path": "workplans/WARDEN-WP-0038-plan-mutation-intent.md",
|
||||
"all_validation_source_hashes_unchanged": true
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
"""Prepared canonical source validation; --execute launches only the two scoped tests."""
|
||||
from pathlib import Path
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
PACKET = Path(__file__).resolve().parent
|
||||
ROOTS = {'net-kingdom': Path('/home/worsch/net-kingdom'), 'ops-warden': Path('/home/worsch/ops-warden')}
|
||||
|
||||
def sha(data):
|
||||
return 'sha256:' + hashlib.sha256(data).hexdigest()
|
||||
|
||||
def sources(manifest):
|
||||
allowed = []
|
||||
for owner, rows in manifest['validation']['source_hashes'].items():
|
||||
for relative, expected in rows.items():
|
||||
path = ROOTS[owner] / relative
|
||||
assert not path.is_symlink(), str(path)
|
||||
assert sha(path.read_bytes()) == expected, str(path)
|
||||
allowed.append(str(path.resolve()))
|
||||
return allowed
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--execute', action='store_true')
|
||||
args = parser.parse_args()
|
||||
manifest = json.loads((PACKET / 'publication-inputs.json').read_text())
|
||||
allowed = sources(manifest)
|
||||
revision = subprocess.check_output(['git', '-C', str(ROOTS['ops-warden']), 'rev-parse', 'HEAD'], text=True).strip()
|
||||
assert revision == manifest['warden_revision']
|
||||
if not args.execute:
|
||||
print(json.dumps({'prepared_only': True, 'public_source_files_verified': len(allowed),
|
||||
'tests': manifest['validation']['tests']}))
|
||||
return
|
||||
protected = {name: sha((ROOTS['net-kingdom'] / name).read_bytes()) for name in manifest['protected_files']}
|
||||
scratch = Path(tempfile.mkdtemp(prefix='nk48-catalog-canonical-validation-'))
|
||||
for name in ['home', 'tmp', 'guard', 'pycache']:
|
||||
(scratch / name).mkdir()
|
||||
shutil.copyfile(PACKET / 'validation-guard.py', scratch / 'guard/sitecustomize.py')
|
||||
shutil.copyfile(PACKET / 'validation-child.py', scratch / 'child.py')
|
||||
(scratch / 'allowed.json').write_text(json.dumps(allowed))
|
||||
(scratch / 'pytest.ini').write_text('[pytest]\n')
|
||||
environment = {
|
||||
'HOME': str(scratch / 'home'), 'TMPDIR': str(scratch / 'tmp'), 'PATH': '/usr/bin:/bin',
|
||||
'PYTHONPATH': str(scratch / 'guard') + ':' + str(ROOTS['ops-warden'] / 'src'),
|
||||
'PYTHONDONTWRITEBYTECODE': '1', 'PYTHONPYCACHEPREFIX': str(scratch / 'pycache'),
|
||||
'LANG': 'C.UTF-8', 'WARDEN_REVIEW_ALLOWED_SOURCE_LIST': str(scratch / 'allowed.json'),
|
||||
'WARDEN_REVIEW_VALIDATOR_PREFIX': str(scratch / 'tmp/warden-case-validator-'),
|
||||
}
|
||||
with (PACKET / 'canonical-validation.log').open('w') as log:
|
||||
result = subprocess.run([manifest['validation']['python'], str(scratch / 'child.py')],
|
||||
cwd=ROOTS['net-kingdom'], env=environment,
|
||||
stdout=log, stderr=subprocess.STDOUT)
|
||||
sources(manifest)
|
||||
assert protected == {name: sha((ROOTS['net-kingdom'] / name).read_bytes()) for name in manifest['protected_files']}
|
||||
log_text = (PACKET / 'canonical-validation.log').read_text()
|
||||
counts_verified = bool(re.search(r'\b31 passed, 53 subtests passed\b', log_text))
|
||||
counts_verified = counts_verified and not re.search(r'\b[1-9][0-9]* (?:skipped|deselected)\b', log_text)
|
||||
receipt = {'executed': True, 'counts_verified': counts_verified, 'returncode': result.returncode, 'warden_revision': revision,
|
||||
'net_kingdom_head': subprocess.check_output(['git', '-C', str(ROOTS['net-kingdom']), 'rev-parse', 'HEAD'], text=True).strip(),
|
||||
'verified_public_source_files': len(allowed), 'tests': manifest['validation']['tests'],
|
||||
'log_sha256': sha((PACKET / 'canonical-validation.log').read_bytes()), 'scratch': str(scratch),
|
||||
'limitations': 'Source fixture tests only; no native owner execution, acceptance, catalog promotion or pin.'}
|
||||
(PACKET / 'canonical-validation.json').write_text(json.dumps(receipt, indent=2) + '\n')
|
||||
print(json.dumps(receipt, indent=2))
|
||||
raise SystemExit(result.returncode or (0 if counts_verified else 1))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
|
||||
## T35 — Align source admission fixtures with the authenticated catalog and attended-session API
|
||||
|
||||
```task
|
||||
id: NK-WP-0048-T35
|
||||
status: done
|
||||
priority: high
|
||||
```
|
||||
|
||||
Completed 2026-10-17, source fixture compatibility only. Distinct from T32's
|
||||
independent agent-mint regression repair: both remaining opaque catalog byte
|
||||
placeholders now use one well-formed synthetic catalog whose exact bytes are
|
||||
bound by the fixture evidence verifier. The fixture mirrors the six relevant
|
||||
Warden lane shapes; four draft statuses are hypothetically active, while both
|
||||
Apps establishing login references remain unresolved. No real catalog entry,
|
||||
owner login choice or production parameter pin changes.
|
||||
|
||||
Against the reviewed mode-aware Warden source now integrated at
|
||||
`ae7bc73b4f4bac22454144959b870d161498e0af`, scratch validation passes 31 tests
|
||||
and 53 subtests. Five resolvable 1.3 descriptors conditionally admit under
|
||||
fixture-only acknowledgment and pinning; both Apps attended steps refuse before
|
||||
execution. Changed catalog bytes refuse, all independent mint-guard tests still
|
||||
reach their intended guard, and the registration fixture's actual kernel
|
||||
run/rollback and uncertain-result paths pass with synthetic owner callbacks.
|
||||
The registration fixture explicitly aligns its in-memory proposed type lane
|
||||
with its current descriptor; canonical 1.1 is unchanged.
|
||||
|
||||
The same tests against predecessor `117fec9241e7b985dfb187b992e173d0a5dc3700`
|
||||
pass 31 tests and 51 subtests, with only the two new Apps refusal assertions
|
||||
failing because that predecessor lacks the attended-session catalog check.
|
||||
Tests target the reviewed current API; the parser or Apps gate is not weakened
|
||||
for predecessor compatibility. Evidence and root source review:
|
||||
`the-custodian/docs/changes/netkingdom-target-2026-10-17/nk48-catalog-fixture-update-r1/`
|
||||
and `nk48-catalog-fixture-publication-r1/`. Canonical validation/publication
|
||||
receipts belong in the latter packet when performed. This records source
|
||||
fixture work, not native T03, owner assent, exact-type acknowledgment, PIN-1,
|
||||
composition/admission completion under T16 or the native first case under T06.
|
||||
T33 and T34 retain their existing issuer-store and consumer-inverse work.
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
"""Focused canonical-source test process. Network/native/estate-read guard required."""
|
||||
from pathlib import Path
|
||||
import os
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import sitecustomize
|
||||
|
||||
assert sitecustomize.ACTIVE is True
|
||||
assert not {'BAO_TOKEN', 'VAULT_TOKEN', 'WARDEN_AGENT_ID'} & os.environ.keys()
|
||||
assert list(Path.home().iterdir()) == []
|
||||
try:
|
||||
socket.socket()
|
||||
except RuntimeError as error:
|
||||
assert str(error) == 'fixture validation: network disabled'
|
||||
else:
|
||||
raise AssertionError('network guard inactive')
|
||||
|
||||
import warden.case_inputs as inputs
|
||||
import pytest
|
||||
|
||||
assert Path(inputs.__file__).resolve() == Path('/home/worsch/ops-warden/src/warden/case_inputs.py')
|
||||
PREAMBLE = '''import sys as _review_sys\ndef _review_guard(event,args):\n if event.startswith('socket.') or event in {'subprocess.Popen','os.system','os.exec','os.posix_spawn'}:\n raise RuntimeError('review validator: network/native disabled')\n if event=='open' and isinstance(args[0],str) and (args[0].startswith('/home/') or args[0].startswith('/root/')):\n raise RuntimeError('review validator: ambient home denied')\n_review_sys.addaudithook(_review_guard)\n'''
|
||||
old_run = subprocess.run
|
||||
|
||||
def run_pinned(arguments, *positional, **keywords):
|
||||
if (type(arguments) is not list or len(arguments) != 5
|
||||
or arguments[:3] != [sys.executable, '-I', '-c']
|
||||
or arguments[3] != inputs._VALIDATE
|
||||
or not str(arguments[4]).startswith(sitecustomize.VALIDATOR_PREFIX)
|
||||
or keywords.get('env') != {}):
|
||||
raise RuntimeError('fixture validation: unexpected process refused')
|
||||
return old_run([*arguments[:3], PREAMBLE + arguments[3], arguments[4]],
|
||||
*positional, **keywords)
|
||||
|
||||
inputs.subprocess.run = run_pinned
|
||||
raise SystemExit(pytest.main([
|
||||
'-q', '-p', 'no:cacheprovider', '--noconftest',
|
||||
'-c', str(Path(os.environ['TMPDIR']).parent / 'pytest.ini'),
|
||||
'--rootdir=/home/worsch/net-kingdom',
|
||||
'/home/worsch/net-kingdom/sso-mfa/k8s/keycape/test_admit_1_3_type.py',
|
||||
'/home/worsch/net-kingdom/sso-mfa/k8s/keycape/test_keycape_registration_adapter.py',
|
||||
]))
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
"""Copied as sitecustomize.py into a fresh scratch directory by run_validation."""
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
ALLOWED = frozenset(json.loads(Path(os.environ['WARDEN_REVIEW_ALLOWED_SOURCE_LIST']).read_text()))
|
||||
VALIDATOR_PREFIX = os.environ['WARDEN_REVIEW_VALIDATOR_PREFIX']
|
||||
|
||||
def guard(event, args):
|
||||
if event.startswith('socket.'):
|
||||
raise RuntimeError('fixture validation: network disabled')
|
||||
if event == 'subprocess.Popen':
|
||||
command = args[1]
|
||||
if (type(command) is list and len(command) == 5
|
||||
and command[:3] == [sys.executable, '-I', '-c']
|
||||
and command[3].startswith('import sys as _review_sys\ndef _review_guard(')
|
||||
and str(command[4]).startswith(VALIDATOR_PREFIX) and args[3] == {}):
|
||||
return
|
||||
raise RuntimeError('fixture validation: native process disabled')
|
||||
if event in {'os.system', 'os.exec', 'os.posix_spawn'}:
|
||||
raise RuntimeError('fixture validation: native process disabled')
|
||||
if event == 'open' and isinstance(args[0], str):
|
||||
path = str(Path(args[0]).absolute())
|
||||
if path.startswith(('/home/', '/root/')):
|
||||
# Only exact prehashed public source may be read from the estate.
|
||||
if str(Path(path).resolve()) not in ALLOWED:
|
||||
raise PermissionError('fixture validation: unlisted estate file disabled')
|
||||
mode, flags = args[1:3]
|
||||
if ((isinstance(mode, str) and any(c in mode for c in 'wax+'))
|
||||
or (flags & (os.O_WRONLY | os.O_RDWR | os.O_CREAT | os.O_TRUNC | os.O_APPEND))):
|
||||
raise PermissionError('fixture validation: canonical source writes disabled')
|
||||
|
||||
sys.addaudithook(guard)
|
||||
ACTIVE = True
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue