{
  "schema": "seam.compiler-contract.v2",
  "version": "1.0.0-rc.1",
  "authority": "deterministic-seam-compiler",
  "aiRequired": false,
  "commands": ["/audit", "/accessibility", "/fix", "/redo"],
  "stages": {
    "semanticSeam": {
      "command": "/ideate",
      "authority": "closed kiwe.seam-map.v1 plus inert data-seam-anchor stitches",
      "input": "approved browser-runnable HTML/CSS/JS and exact SiteGraph evidence when cited",
      "output": "builder-neutral semantic contract, exact source fingerprints and proof ledger",
      "sourcePolicy": "marker-only",
      "unmarkedPolicy": "preserve-static",
      "semanticInferenceAllowed": false,
      "requiresCompleteClosure": true,
      "requiresExactSiteGraphHashRevisionAndPointers": true
    },
    "prepareBindings": {
      "command": "/convert /bricks",
      "authority": "participating browser AI under the SEAM command contract",
      "input": "complete accepted pre-existing HTML/CSS/JS project without a strict SEAM Map, plus assets and SiteGraph whenever real site fields are requested",
      "output": "kiwe.bricks-bindings.v1 graph and binding report only; approved raw project remains unchanged; never Bricks JSON",
      "sourcePolicy": "immutable",
      "requiresExactFileTargets": true,
      "requiresExplicitFieldSlotsAndSourceGuards": true,
      "requiresExplicitRepeatPrototypeAndPreviewCount": true,
      "structuralPassProvesRuntime": false,
      "defaultBindingMode": "dynamicTagsAndQueryLoops",
      "modifiers": {"/dynamictags": "dynamicTagsOnly", "/queryloop": "queryLoopsOnly"}
    },
    "compile": {
      "trigger": "explicit submission through the seam.kiwe application UI or API",
      "authority": "deterministic-seam-compiler",
      "input": "complete accepted HTML/CSS/JS project, assets and either a strict validated kiwe.seam-map.v1 or optional legacy kiwe.bricks-bindings.v1",
      "output": "native Bricks page/header/footer/popup templates plus conversion evidence",
      "frameworkNeutral": true,
      "maySplitDocumentChrome": true,
      "nativeFirst": true,
      "customCodePolicy": "only when the calibrated Bricks profile proves no native equivalent"
    },
    "framework": {
      "option": "frameworkMode",
      "input": "the same complete rendered source evidence used by conversion",
      "output": "one Framework Profile, profile-dependent templates, real dependency package and integration audit",
      "optional": true,
      "profileInstallRequiredBeforeTemplateImport": true,
      "fallbackValuesForbidden": true,
      "ownershipOrder": ["Bricks Theme Style", "universal Seam variables and palette", "project variables and reusable classes", "element-native exceptions", "scoped unsupported CSS"]
    },
    "dependencies": {
      "authority": "deterministic-seam-compiler",
      "input": "actual compiled native templates/Profile, referenced real bytes and source-resource reports",
      "output": ["package-integrity.json", "assets/manifest.json", "assets/import-plan.json", "style-dependencies.json"],
      "nativeImportReady": false,
      "aiInventedNativeIdsAllowed": false,
      "remoteFetch": false,
      "targetImport": "separate authorized Kiwe Framework review, supported native Media, compatible shared styles, guarded remapping and draft templates",
      "recovery": "preserve newer edits and reusable Media; no automatic publication or permanent media deletion"
    },
    "audit": {
      "command": "/audit",
      "readOnly": true,
      "requiresExecutableProof": true,
      "visualProofRequiresMatchingViewportProvenance": true,
      "sourceDefectsAreNotConverterDefects": true,
      "invalidOrContaminatedCaptureStatus": "INCOMPLETE"
    },
    "accessibility": {
      "auditCommand": "/accessibility",
      "fixCommand": "/fix",
      "input": "accepted raw or Bricks artifact",
      "output": "measured report or corrected same-lane artifact with before/after evidence",
      "optional": true,
      "requiresExecutableProof": true,
      "browserAiMayNotInventContrastRatios": true,
      "covers": ["semantics", "keyboard", "focus", "names and labels", "contrast", "readability", "overflow", "clipping", "collision", "touch targets", "responsive spacing and alignment", "reduced motion", "light/dark presentation"],
      "creativeBoundary": "preserve the accepted design; dark mode may deliberately coordinate brand, accent, surface and text roles without collapsing every surface to black",
      "bricksDarkModeBinding": ":root[data-brx-theme=\"dark\"] #brxe-<template-root-id>"
    },
    "redo": {
      "command": "/redo",
      "authority": "last accepted artifact plus failure evidence",
      "forbidden": "stacking speculative patches on the failed output"
    }
  },
  "invariants": [
    "Raw conversion never injects or requires Seam Framework.",
    "Framework is an explicit option, not a command or redesign.",
    "Visual quality and the accepted design take priority; consolidate only equivalent values and meanings while preserving page/scoped values and script-owned variables.",
    "Real asset bytes and exact native references determine the compiler package; AI notes, filenames, hashes and IDs are not proof of assets or native installation.",
    "A missing Framework Profile fails closed and templates never depend on variable fallbacks.",
    "Browser AI may author source design and binding intent but never production Bricks JSON or Framework Profile data.",
    "/convert /bricks never emits Bricks JSON; seam.kiwe compilation is a separate explicit application action.",
    "Strict SEAM Map conversion never infers dynamic, commerce, editorial, interaction or conditional meaning; missing, stale, duplicated, unproven or unresolved stitches fail closed.",
    "SEAM Map is builder-neutral conversion context and does not apply Seam Framework or influence art direction.",
    "Visual confidence is evidence based and never a universal fixed percentage.",
    "Source defects are preserved in 1:1 conversion and reported separately.",
    "No project-specific selector, brand, layout or route rule enters compiler core."
  ]
}
