docs: publish game development reference V3.1
This commit is contained in:
@@ -0,0 +1,251 @@
|
||||
"""Validate reference documents and source-bound historical receipts; run no games."""
|
||||
from pathlib import Path
|
||||
from urllib.parse import unquote, urlsplit
|
||||
import argparse
|
||||
import ast
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from datetime import datetime, timezone
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--report', type=Path, help='New output JSON, created exclusively')
|
||||
args = parser.parse_args()
|
||||
root = Path(__file__).resolve().parent.parent
|
||||
# The pack can now be maintained as its own Git checkout. Repository
|
||||
# metadata is outside the tutorial corpus and its content manifest.
|
||||
all_files = sorted(path for path in root.rglob('*') if path.is_file()
|
||||
and '.git' not in path.relative_to(root).parts)
|
||||
failures = []
|
||||
links = 0
|
||||
for path in (p for p in all_files if p.suffix == '.md'):
|
||||
contents = path.read_text(encoding='utf-8')
|
||||
if re.search(r'turn\d+(?:view|search)\d+', contents):
|
||||
failures.append('%s exposes an internal browser reference' % path.relative_to(root))
|
||||
for target in re.findall(r'!?\[[^\]]*\]\(([^)]+)\)', contents):
|
||||
parts = urlsplit(target.strip('<>'))
|
||||
if parts.scheme or parts.netloc or not parts.path:
|
||||
continue
|
||||
links += 1
|
||||
if not (path.parent / unquote(parts.path)).exists():
|
||||
failures.append('%s has a missing relative link: %s' % (path.relative_to(root), target))
|
||||
|
||||
json_files = [p for p in all_files if p.suffix == '.json']
|
||||
parsed = {}
|
||||
for path in json_files:
|
||||
try:
|
||||
parsed[str(path.relative_to(root))] = json.loads(path.read_text(encoding='utf-8'))
|
||||
except (ValueError, OSError) as error:
|
||||
failures.append('%s invalid JSON: %s' % (path.relative_to(root), error))
|
||||
|
||||
required = ['README.md', 'AI_START_HERE.md', '01_learning_path.md',
|
||||
'02_gameplay_and_architecture.md', '03_ui_layout_and_readability.md',
|
||||
'04_art_animation_and_audio.md', '05_open_source_projects.md',
|
||||
'06_ai_tools_and_skills.md', '07_testing_and_acceptance.md',
|
||||
'08_applied_cases.md', 'sources/catalog.json',
|
||||
'sources/repository_snapshots.json', 'sources/local_tool_evidence.json',
|
||||
'examples/ui_styles/provenance.json', 'SHA256SUMS.json',
|
||||
'09_music_and_sound.md', '10_gameplay_genres_and_content.md',
|
||||
'11_public_skills.md', '12_practical_labs.md',
|
||||
'13_source_walkthroughs.md', '14_npc_ai_and_procedural_content.md',
|
||||
'READINESS.md', 'sources/skill_catalog.json', 'sources/research_v2.json',
|
||||
'examples/godot_workshop/project.godot',
|
||||
'evidence/godot_lab/attempt_02/report.json',
|
||||
'15_source_recipes.md', '16_new_game_workflow.md',
|
||||
'17_art_audio_implementation.md', '18_research_maintenance.md',
|
||||
'sources/research_v3.json', 'history/v2_content_manifest.json',
|
||||
'templates/new_game_brief.md', 'templates/source_application_record.json',
|
||||
'skills/learn-from-game-source/SKILL.md',
|
||||
'skills/learn-from-game-source/references/case-map.md',
|
||||
'scripts/snapshot_github.py', '19_visual_consistency_workflow.md',
|
||||
'templates/game_visual_contract.md', 'history/v3_content_manifest.json',
|
||||
'skills/game-visual-consistency/SKILL.md',
|
||||
'skills/game-visual-consistency/references/runtime-checks.md']
|
||||
for name in required:
|
||||
if not (root / name).is_file():
|
||||
failures.append('Missing required file: ' + name)
|
||||
|
||||
catalog = parsed.get('sources/catalog.json', {})
|
||||
entries = catalog.get('entries', [])
|
||||
ids = [entry.get('id') for entry in entries]
|
||||
if len(ids) != len(set(ids)) or not all(ids):
|
||||
failures.append('Source IDs are missing or duplicated')
|
||||
definitions = catalog.get('definitions', {})
|
||||
for entry in entries:
|
||||
if not entry.get('url', '').startswith('https://'):
|
||||
failures.append('Non-HTTPS source: %s' % entry.get('id'))
|
||||
if entry.get('evidence_status') not in definitions:
|
||||
failures.append('Undefined source status: %s' % entry.get('id'))
|
||||
for key in ['commit', 'tested_commit']:
|
||||
if key in entry and not re.fullmatch(r'[0-9a-f]{40}', entry[key]):
|
||||
failures.append('Invalid pinned SHA: %s' % entry.get('id'))
|
||||
|
||||
skill_catalog = parsed.get('sources/skill_catalog.json', {})
|
||||
skills = skill_catalog.get('entries', [])
|
||||
skill_ids = [entry.get('id') for entry in skills]
|
||||
if not all(skill_ids) or len(skill_ids) != len(set(skill_ids)):
|
||||
failures.append('Missing or duplicate Skill IDs')
|
||||
for entry in skills:
|
||||
if not re.fullmatch(r'[0-9a-f]{40}', entry.get('commit', '')):
|
||||
failures.append('Invalid Skill SHA: ' + str(entry.get('id')))
|
||||
if entry.get('status') not in skill_catalog.get('definitions', {}):
|
||||
failures.append('Undefined Skill status: ' + str(entry.get('id')))
|
||||
if entry.get('runtime_tested') is not False or entry.get('installed') is not False:
|
||||
failures.append('Unexpected runtime/install claim for this research: ' + str(entry.get('id')))
|
||||
if '/blob/' + entry.get('commit', '') + '/' not in entry.get('url', ''):
|
||||
failures.append('Skill URL not pinned: ' + str(entry.get('id')))
|
||||
|
||||
research = parsed.get('sources/research_v3.json', {})
|
||||
researched_files = research.get('files', [])
|
||||
researched_repos = {item['repository']: item for item in research.get('repositories', [])}
|
||||
source_keys = [(item.get('repository'), item.get('path')) for item in researched_files]
|
||||
if len(source_keys) != len(set(source_keys)):
|
||||
failures.append('V3 research has duplicate file records')
|
||||
known_urls = set()
|
||||
for item in researched_files:
|
||||
label = '%s/%s' % (item.get('repository'), item.get('path'))
|
||||
commit = item.get('commit', '')
|
||||
if not re.fullmatch(r'[0-9a-f]{40}', commit) or commit != researched_repos.get(item.get('repository'), {}).get('commit'):
|
||||
failures.append('V3 file not bound to repository snapshot: ' + label)
|
||||
expected_url = 'https://github.com/%s/blob/%s/%s' % (item.get('repository'), commit, item.get('path'))
|
||||
if item.get('url') != expected_url:
|
||||
failures.append('V3 file URL mismatch: ' + label)
|
||||
known_urls.add(expected_url)
|
||||
if not re.fullmatch(r'[0-9a-f]{64}', item.get('sha256', '')):
|
||||
failures.append('V3 file hash invalid: ' + label)
|
||||
if item.get('runtime_tested') is not False or item.get('status') not in research.get('definitions', {}):
|
||||
failures.append('V3 file inspection/runtime claim invalid: ' + label)
|
||||
ranges = item.get('inspected_ranges', [])
|
||||
if (item.get('status') == 'downloaded_not_inspected') != (not ranges):
|
||||
failures.append('V3 download/read status disagrees with ranges: ' + label)
|
||||
for span in ranges:
|
||||
if len(span) != 2 or not 1 <= span[0] <= span[1] <= item.get('lines', 0):
|
||||
failures.append('V3 inspection range out of bounds: ' + label)
|
||||
if item.get('status') == 'skill_entrypoint_inspected':
|
||||
matches = [s for s in skills if s.get('url') == expected_url]
|
||||
if len(matches) != 1 or matches[0].get('source_sha256') != item.get('sha256'):
|
||||
failures.append('V3 public Skill hash/catalog mismatch: ' + label)
|
||||
if item.get('references_or_scripts_inspected') is not False:
|
||||
failures.append('V3 Skill reference claim expanded: ' + label)
|
||||
v3_summary = research.get('summary', {})
|
||||
actual_summary = {
|
||||
'metadata_pinned': sum(bool(i.get('commit')) for i in researched_repos.values()),
|
||||
'metadata_unavailable': sum(not i.get('commit') for i in researched_repos.values()),
|
||||
'downloaded_files': len(researched_files),
|
||||
'selected_files_inspected': sum(i.get('status') != 'downloaded_not_inspected' for i in researched_files),
|
||||
'download_only': sum(i.get('status') == 'downloaded_not_inspected' for i in researched_files),
|
||||
'new_public_skill_entrypoints': sum(i.get('status') == 'skill_entrypoint_inspected' for i in researched_files),
|
||||
'source_entries_total': len(entries), 'skill_entries_total': len(skills)}
|
||||
if v3_summary != actual_summary:
|
||||
failures.append('V3 research totals disagree with actual records')
|
||||
recipes = research.get('recipes', [])
|
||||
if len(recipes) != 10 or len({r.get('id') for r in recipes}) != 10:
|
||||
failures.append('V3 requires ten distinct source recipes')
|
||||
for recipe in recipes:
|
||||
if not set(recipe.get('source_ids', [])).issubset(set(ids)) or not recipe.get('source_ids'):
|
||||
failures.append('Recipe source ID missing: ' + str(recipe.get('id')))
|
||||
chapter = root / recipe.get('chapter', '')
|
||||
if not chapter.is_file() or '\n## %s.' % recipe.get('section') not in chapter.read_text(encoding='utf-8'):
|
||||
failures.append('Recipe section missing: ' + str(recipe.get('id')))
|
||||
if recipe.get('application_status') != 'recipe_not_executed':
|
||||
failures.append('Unexpected V3 recipe runtime claim: ' + str(recipe.get('id')))
|
||||
# Catch guessed source paths in the new recipes/workflow, using the exact
|
||||
# pinned files already inspected, without making fresh network requests.
|
||||
new_docs = [root / name for name in ['15_source_recipes.md', '16_new_game_workflow.md',
|
||||
'17_art_audio_implementation.md', '18_research_maintenance.md']]
|
||||
new_docs.extend((root / 'skills/learn-from-game-source').rglob('*.md'))
|
||||
for path in new_docs:
|
||||
for url in re.findall(r'https://github\.com/[^\s)]+', path.read_text(encoding='utf-8')):
|
||||
base_url = url.split('#', 1)[0]
|
||||
if '/blob/' in base_url and base_url not in known_urls:
|
||||
failures.append('New recipe has unrecorded pinned source path: ' + str(path.relative_to(root)) + ': ' + base_url)
|
||||
|
||||
lab = parsed.get('evidence/godot_lab/attempt_02/report.json', {})
|
||||
runtime_root = root / 'examples/godot_workshop'
|
||||
lab_files = set()
|
||||
for item in lab.get('source_files', []):
|
||||
lab_files.add(item['path'])
|
||||
path = runtime_root / item['path']
|
||||
if not path.is_file() or hashlib.sha256(path.read_bytes()).hexdigest() != item['sha256']:
|
||||
failures.append('Godot lab receipt source mismatch: ' + item['path'])
|
||||
actual_runtime = {str(p.relative_to(runtime_root)) for p in runtime_root.rglob('*')
|
||||
if p.is_file() and p.suffix in ['.gd', '.tscn', '.godot']}
|
||||
if lab_files != actual_runtime:
|
||||
failures.append('Godot lab receipt does not cover its complete runtime source')
|
||||
lab_result = lab.get('lab_result', {})
|
||||
if lab.get('classification') != 'PASS' or lab_result.get('failures') != [] or not lab_result.get('passed'):
|
||||
failures.append('Godot lab passing result missing')
|
||||
if len(lab.get('runs', [])) != 2 or any(r.get('exit_code') != 0 or r.get('timed_out')
|
||||
or r.get('log_errors') or r.get('owned_group_remaining') for r in lab.get('runs', [])):
|
||||
failures.append('Godot lab process/log boundary not satisfied')
|
||||
lab_log = root / 'evidence/godot_lab/attempt_02/tests.log'
|
||||
if not lab_log.exists() or 'LAB_RESULT ' not in lab_log.read_text():
|
||||
failures.append('Godot lab raw final marker missing')
|
||||
if not (root / 'evidence/godot_lab/attempt_01/tests.log').is_file():
|
||||
failures.append('Godot lab prior failed attempt missing')
|
||||
|
||||
provenance = parsed.get('examples/ui_styles/provenance.json', {})
|
||||
copies = provenance.get('files', [])
|
||||
for item in copies:
|
||||
path = root / 'examples/ui_styles' / item['destination']
|
||||
if not path.is_file() or hashlib.sha256(path.read_bytes()).hexdigest() != item['sha256']:
|
||||
failures.append('Example copy/hash mismatch: ' + item['destination'])
|
||||
|
||||
html = root / 'examples/ui_styles/ui-styles.html'
|
||||
receipt = parsed.get('examples/ui_styles/original-check-results.json', {})
|
||||
if not html.exists() or receipt.get('source_sha256') != hashlib.sha256(html.read_bytes()).hexdigest():
|
||||
failures.append('Original UI receipt does not bind the copied HTML')
|
||||
if receipt.get('classification') != 'PASS' or len(receipt.get('checks', [])) != 37 or len(receipt.get('layouts', [])) != 12:
|
||||
failures.append('Unexpected original UI receipt scope')
|
||||
if not all(item.get('pass') is True for item in receipt.get('checks', [])):
|
||||
failures.append('Original UI receipt contains a non-passing check')
|
||||
|
||||
for path in (p for p in all_files if p.suffix == '.py'):
|
||||
try:
|
||||
ast.parse(path.read_text(encoding='utf-8'), filename=str(path))
|
||||
except SyntaxError as error:
|
||||
failures.append('Python syntax issue: %s: %s' % (path.relative_to(root), error))
|
||||
|
||||
manifest = parsed.get('SHA256SUMS.json', {})
|
||||
manifest_paths = set()
|
||||
for item in manifest.get('files', []):
|
||||
name = item['path']
|
||||
manifest_paths.add(name)
|
||||
path = root / name
|
||||
if not path.is_file() or path.stat().st_size != item['bytes'] or hashlib.sha256(path.read_bytes()).hexdigest() != item['sha256']:
|
||||
failures.append('Manifest mismatch: ' + name)
|
||||
# Verification receipts are append-only outputs and explicitly excluded from
|
||||
# their own input manifest. Delivery ZIP verification covers all entries.
|
||||
actual_paths = {str(path.relative_to(root)) for path in all_files
|
||||
if str(path.relative_to(root)) not in ['SHA256SUMS.json', 'verification.json']
|
||||
and not (path.parent == root / 'verification' and path.suffix == '.json')}
|
||||
if manifest_paths != actual_paths:
|
||||
failures.append('Manifest does not enumerate the complete reference content')
|
||||
|
||||
secret_pattern = re.compile(rb'(?:sk-[A-Za-z0-9_-]{24,}|-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|Bearer [A-Za-z0-9_-]{24,})')
|
||||
for path in all_files:
|
||||
if path.suffix in ['.md', '.json', '.py', '.css', '.html', '.txt']:
|
||||
if secret_pattern.search(path.read_bytes()):
|
||||
failures.append('Potential credential material in: ' + str(path.relative_to(root)))
|
||||
|
||||
result = {'classification': 'PASS' if not failures else 'FAIL',
|
||||
'scope': 'Reference integrity and historical receipt/source binding only; no new game/browser/device run',
|
||||
'checked_at_utc': datetime.now(timezone.utc).isoformat(),
|
||||
'relative_links_checked': links, 'source_entries': len(entries),
|
||||
'skill_entries': len(skills), 'godot_lab_source_files': len(lab_files),
|
||||
'copied_example_files': len(copies), 'manifest_files': len(manifest_paths),
|
||||
'v3_research_files': len(researched_files), 'v3_source_recipes': len(recipes),
|
||||
'failures': failures}
|
||||
if args.report:
|
||||
with args.report.open('x', encoding='utf-8') as handle:
|
||||
json.dump(result, handle, ensure_ascii=False, indent=2)
|
||||
handle.write('\n')
|
||||
print(json.dumps(result, ensure_ascii=False, indent=2))
|
||||
return 1 if failures else 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user