emergent-security/tools/build_adoption_draft.py
tegwick d0bf65e964 Bind knowledge retrieval to sealed bytes and invalidate changed releases
Assistant: codex
Assistant-Model: gpt-6.1-sol
Assistant-Session: 01a10238-7ecc-78e2-903d-075f50e913cc
2026-10-03 17:44:52 +02:00

83 lines
5 KiB
Python

#!/usr/bin/env python3
"""Build an unsigned, UNSUBMITTED profile-adoption memo; never contact an API.
This is an owner-format draft, not submitter registration or a human answer.
Review class/group/admission with informed-decision before any submission.
"""
from pathlib import Path
import argparse
import hashlib
import json
import sys
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / 'src'))
from emergent_security.knowledge import Knowledge
def build():
package = Knowledge(ROOT / 'knowledge')
version = package.catalog['version']
digest = package.package_digest
item = 'emergent-profile-packet'
content = f'''# Knowledge profile adoption request
Adopt Emergent Security knowledge {version}, release digest {digest}, as a
non-normative orientation profile for coding agents in NetKingdom.
The profile points to existing owners, withholds stale guidance, and separates
human decisions, runtime approvals, PDP decisions, credentials and procedure
records. This asks only to accept that orientation boundary. It does not amend
owner contracts or authorize operational effects, autonomous execution, root,
credential changes or fleet rollout.
Alternatives: return for wording/source corrections; decline this profile;
accept this exact orientation boundary with the documented evidence limits.
Changing the reviewed package requires a new review, not reuse of this answer.
Evidence: knowledge/sources.yaml; docs/decision-runbook-integration.md;
docs/operational-contracts.md; docs/adoption-review.md; docs/evidence/.
Earlier provider reports and owner reviews retain their original release pins.
Whitehat's separately authored offline 0.2.1 review found loaded-package binding
and lifecycle gaps; 0.2.2 addresses them with local regressions. Review close-out
and clean independent acceptance remain incomplete. No full Grok validation is claimed.
Actual compaction/harness proof and wider adoption remain open in EMERGENT-WP-0002.
The draft is unsubmitted. The proposed memo class and review group must be
confirmed by the owner; a synthetic test grant proves format only. INFD-WP-0005
intake rollout remains unfinished. This draft resolves no Statehub decision.
'''
memo = dict(id='emergent-profile-adoption-'+version.replace('.', '-'), version=1,
question=f'Accept Emergent Security knowledge {version} as a non-normative NetKingdom agent orientation profile?',
requested_act='approve', binding_level='organizational', brief='Accept only the orientation boundary of this exact release; operational authority and remaining review gates stay with their owners.',
binding=dict(principal=dict(id='pending-human-session', kind='person', display_name='Pending authenticated reviewer', role='reviewer', identifiers=[]),
target=dict(id='emergent-security:knowledge:'+version+':'+digest, kind='knowledge-profile', label='Non-normative security orientation', environment='rehearsal', requires_new_bind=True), justification=None, terms=None),
step_kind='approve', packet=[dict(item_id=item,label='Profile boundary and limitations',hash='sha256:'+hashlib.sha256(content.encode()).hexdigest())],
highlights=[dict(id='orientation-only',item_id=item,locator=dict(kind='work_record',workplan='EMERGENT-WP-0002',task='EMERGENT-WP-0002-T02'),note='Acceptance is not runtime permission or completion of independent review, provider continuity or fleet rollout.',required_ack=True,severity='critical')],
locale='en',ui_release='informed-decision@0.2.0',approval_id=None,approval_binding_digest=None,sealed=False)
return dict(kind='informed-decision.memo-intake',version=1,idempotency_key='emergent-profile-'+digest,
memo_class='knowledge-profile',review_group='net-kingdom-admins',drafted_by='codex@emergent-security (asserted)',
serves=dict(hub_decision_id='d20a9750-2b29-534e-8227-fb866581a6ca',resolves='never'),
approval_intent=dict(action='accept',principal='emergent-security',purpose='Accept only the non-normative knowledge profile boundary',target=dict(id=memo['binding']['target']['id'],type='knowledge-profile',system='emergent-security')),
memo=memo,packet=[dict(item_id=item,media_type='text/markdown',content=content)])
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--check', action='store_true')
args = parser.parse_args()
path = ROOT / 'docs/decisions/profile-adoption-intake.draft.json'
content = json.dumps(build(), indent=2) + '\n'
if args.check:
if not path.exists() or path.read_text() != content:
print('Draft differs from current release; rebuild and review.')
return 1
print('Unsigned adoption draft matches current release; not submitted.')
else:
path.write_text(content)
print('Wrote unsigned adoption draft; not submitted or approved.')
return 0
if __name__ == '__main__':
raise SystemExit(main())