# Shared implementation contract ## Current runtime — static browser application The current deployed app is a public Hugging Face Static Space with `sdk: static` and root `index.html` as its entry point. HTML, CSS and JavaScript run locally in the browser; no Flask/Gradio backend, model, scanner, application password or Space Secrets are needed. Results and notes are saved in IndexedDB for the browser profile and origin. Raw submissions are discarded. The five hats are human review perspectives with suggested tasks and workbooks, not running agents. Use README.md for current usage and verification. The static contract below records the architectural transition; subsequent supported features include JSON restore, analyst findings, role workbooks, report versions and linked continuations. The earlier “import not required” statement is historical scope, not a description of the current feature set. The current deployment is public; the optional helper creates new private projects only. ## Historical prototype — Flask and SQLite (superseded) Python Flask + SQLite + vanilla JS. Root creates Docker, docs, deploy helper; backend owner: app.py, engine.py, tests/test_backend.py; frontend owner: static/index.html, static/app.js, static/style.css. No edits outside owned files. Single isolated customer workspace per deployment. APP_ACCESS_KEY min 24 chars and APP_SECRET_KEY min 32 chars mandatory unless TESTING config. DATA_DIR defaults ./data. Cookie sessions HttpOnly SameSite Strict, Secure by default (COOKIE_SECURE=false for loopback development only). CSRF token via X-CSRF-Token for all authenticated mutations. API JSON responses; errors {error:string}. GET /api/session returns {authenticated:bool,csrf_token:string|null,workspace:string}; POST /api/login {access_key} => same session response; POST /api/logout => {ok:true}. GET /api/assessments => {assessments:[assessment summaries]}. POST /api/assessments {name,workflow:'code'|'alerts'|'exercise',scope,authorization:true,content:string,roles:['red','blue','white','black','purple']} => {assessment:object} HTTP201. GET /api/assessments/ => {assessment:object}. DELETE same => {ok:true}. PATCH /api/assessments//findings/ {verdict,note} => {assessment:object}. GET /api/assessments//export?format=json|markdown returns file. Assessment: {id,name,workflow,scope,created_at,roles,findings:[],missions:[],summary:string,coverage:[],activity:[]}. Finding: {id,title,severity:'high'|'medium'|'low',confidence:'medium'|'low',verdict:'unresolved'|'confirmed-static'|'confirmed-runtime'|'rejected',location,root_cause,input_to_impact,prerequisites,mitigations,evidence,remediation,review_note}. Every automatic result unresolved; manual confirm requires substantive note, no runtime proof claim from engine. Activity {at,action,note}; persisted without raw source/logs. Missions {role,title,objective,steps:[string],deliverable,limitations:[string]}. Summary list fields id,name,workflow,scope,created_at,roles,finding_count,unresolved_count. Code accepts Python snippets max 64000 chars, uses AST for eval/exec and subprocess shell=True candidates; secret-like assignment pattern returns redacted evidence, no raw secrets stored/returned. Alerts strict JSON array <=500 objects: event,actor,source_ip optional; events login_failed repeated >=5 actor+source, privilege_change, malware_detected. Exercise accepts scenario prose. All five roles generate bounded, role-specific mission plans with challenge/adjudication steps, no automatic tools/remote requests/exploitation. No model inference claimed. Frontend session checks; login screen with access key; dashboard starts empty, demo input fill explicit; assessment form; five role selectors; three workflows; scopes + checkbox authority; candidate ledger with analyst decisions and note; missions + coverage; search; JSON/MD export; delete confirmation; logout. No localStorage keys/customer data; textContent for untrusted output. No CDNs/external assets. Accessible labels, responsive mobile. ## Historical prototype — native Gradio (superseded) User explicitly requested no Docker. README now uses sdk:gradio and app_file:gradio_app.py. Native UI adapts the existing Flask API internally; the Flask web server is not exposed. Missing application secrets produce a locked setup page. Gradio uses its own external login (analyst / APP_ACCESS_KEY), share=False and disabled analytics. Raw inputs are not queued or exported as files. Static browser interface is optional legacy engineering UI. Private remote Space created at PabloRod11/napolean-cyber-command through authenticated browser. ## Static architecture transition — historical implementation instructions User requires no cost. Switch same private HF repo to sdk:static, app_file:static/index.html, no build command. No Docker/Gradio/compute/model/API secrets needed for deployed app. Existing Python code may remain as optional reference but is not executed or required by static runtime. Runtime HTML+CSS+JS only, same-origin local assets only. Static engine owner new static/local.js, static/playbooks.js, tests/test_local.cjs. Frontend owner static/index.html, static/app.js,static/style.css. Root owns metadata/docs/deploy helper and packaging. No concurrent shared files. Keep assessment schema and workflows exact. Python code review becomes explicitly limited REGEX/PATTERN nomination, never AST/parser/taint/exploit validation. All automatic candidates unresolved; no eval/Function/subprocess/server calls. Alerts same schema<=500; keyword scenario routing same original templates. Generate playbooks.js data from original engine. Source/raw alerts/scenario never persisted; store minimal output metadata/candidate evidence only. Secret redaction best effort. All roles preserved. Expose globalThis.CyberLocal with async request(path, options={}) returning existing API JSON shapes for /api/assessments list/create/detail/PATCH findings/DELETE; options.body can JSON string, method defaults GET. No auth/session/login API. exportText(id,format) returns authenticated-browser-local record as string (json/markdown). Browser state is NOT authentication or tenant isolation. Store results in IndexedDB and await transaction completion before reporting success. Error if browser storage unavailable; never silently pretend persistence. Browser profile/origin owns records, not cross-user shared database. Concurrent review updates should atomically append activity in readwrite transaction. Do not persist raw inputs. validate fields/roles/authorization, cap records=100 and findinghistory=200 to bound storage growth with clear errors. Expose analyze(payload), redact(value), markdownExport(assessment), LocalService(store), IndexedDBStore. Use plain script UMD/CommonJS for Node built-in tests. request/exportText delegate singleton service. Keep imports local and no runtime dependencies/CDNs. local.js/playbooks.js loaded with defer before app.js. UI auto opens browser workspace after DB ready/list; remove shared-key/login/CSRF/session claims and make clear records stay in this browser; private HF access gate remains separate. Close/clear-view only clears DOM sensitive state, never suggests logout/encryption. Export Blob text locally. Add export import? Not required; explicit JSON exports backup, no new import functionality. Surface storage errors and local-only warning. Demo input remains explicit synthetic sample only.