Two-Tier Core/Module Split and the Grep Gate
The repository is not one package with a policy folder; it is two dependency tiers with a mechanically enforced seam. The plugin core (zikzak_inappwebview) is a thin platform plugin that may only expose raw capability — widgets, controller facades, headless API, cookie facade, and the raw capture-event stream. Everything that decides, caches, pools, filters, records, or replays lives in zikzak_inappwebview_module, a dev-only sibling package that consumes the core’s public API and nothing else. This page documents the shape of that split, the seven-name seam contract, the anatomy and the blind spots of scripts/grep_gate.sh, and the rules that follow for anyone adding code to either tier.
Sources: SPLIT_MAP.md, AGENTS.md
The Two Tiers as a Dependency Contract
Section titled “The Two Tiers as a Dependency Contract”The split is defined in first principles: a platform plugin’s remit is to make native capability reachable from Dart, and it has no business holding mission policy. The umbrella specification states the consequence directly — the value-add surface (network capture management, WebViewPool, VCR, dialogue dismissers, recipes, navigation tracking, controllers) “has outgrown a platform plugin’s remit,” so the repo takes a two-tier shape in which the tiers version independently. The authoritative artifact is SPLIT_MAP.md, whose stated validation rule is that every class under zikzak_inappwebview/lib/src/ appears exactly once, assigned to either Core (raw plumbing) or Module (policy, state, intelligence, agent surface).
graph TD subgraph Consumer["Consumer app"] APP["application code"] end subgraph Module["Module tier — zikzak_inappwebview_module (publish_to: none)"] PORTS["ports: WebViewSessionFactory · CaptureSource · CassetteEngine · DialogueDismissPort · RecipePort · NavigationTrackerPort"] SVCS["services: WebViewPool · CaptureService · CassetteEngineImpl"] MODELS["models: PoolSession · Cassette"] end subgraph Core["Core tier — zikzak_inappwebview (published, v6.7.0)"] FACADE["public facades: InAppWebView · InAppWebViewController · HeadlessInAppWebView · CookieManager · InAppBrowser · ChromeSafariBrowser"] RAW["raw plumbing: NetworkCaptureManager + interceptor JS · platform channels"] PI["re-exported platform_interface types"] end NATIVE["platform packages: _android · _ios · _macos · _web · _windows · _linux"]
APP --> PORTS APP -. "thin-core usage, no zuraffa" .-> FACADE SVCS --> FACADE PORTS --> FACADE FACADE --> RAW FACADE --> PI RAW --> NATIVE PI --> NATIVE
classDef forbidden fill:#ffe0e0,stroke:#c00,stroke-width:2px; PI -. "MUST NOT be imported by module (grep gate check 2)" .-> PORTS class PI forbiddenThe dependency arrow is the whole architecture: one direction only, module → core public API. There is no core → module edge anywhere in the tree, which is what lets a consumer take the core alone (widget, controller, headless, cookies) with no zuraffa runtime at all, or take the module for pool/capture/VCR while still never touching a platform channel.
Sources: SPLIT_MAP.md, CONSUMER_TRANSITION_PLAN.md, zikzak_inappwebview/pubspec.yaml
The Seam: Seven Names and a Re-Export
Section titled “The Seam: Seven Names and a Re-Export”The seam is not “the core’s lib/” — it is an enumerated list of seven public names. SPLIT_MAP.md names them: InAppWebView, InAppWebViewController, HeadlessInAppWebView, CookieManager, the raw capture-event stream, InAppBrowser, and ChromeSafariBrowser; the module “MUST NOT import zikzak_inappwebview_platform_interface internals other than re-exported public facades.”
| Seam member | Kind | What the module uses it for |
|---|---|---|
InAppWebView |
widget | visible webview surface |
InAppWebViewController |
controller facade | JS eval, navigation, cookies, settings — the primary adapter target |
HeadlessInAppWebView |
headless API | the instance the pool acquires and recycles |
CookieManager |
cookie facade | cookie snapshots for cassettes and recipes |
| raw capture-event stream | event types | input to CaptureSource distillation |
InAppBrowser |
widget | in-app browser surface |
ChromeSafariBrowser |
widget | custom-tab surface |
The mechanism that makes “no platform_interface import” satisfiable rather than aspirational is the umbrella’s barrel file: zikzak_inappwebview.dart re-exports the entire platform interface with a hide list of internals (ChannelController, InternalChannelController, InternalInAppWebViewKeepAlive, IdGenerator, Color_, Util, UtilColor, HexColor, MapSize, MapEdgeInsets). A module file that needs InAppWebViewSettings or HeadlessInAppWebView writes one import — package:zikzak_inappwebview/zikzak_inappwebview.dart — and receives the types transitively, so the platform interface is reachable through the seam without ever being named.
Sources: SPLIT_MAP.md, zikzak_inappwebview.dart, webview_session_factory.dart
What Actually Lives Where Today
Section titled “What Actually Lives Where Today”The split map is a target-state document that also records the current file of each module-tier class, and reading the tree against it produces the single most important nuance for a contributor: the module is a scaffold of ports and services, while several named module-tier implementations are still physically in the core. The module’s own README says so — “Early scaffold — port interfaces and service stubs.”
| Concern | Core location today | Module counterpart | State |
|---|---|---|---|
| Session pooling | HeadlessWebViewRegistry (cap + TTL + dispose-all primitives) |
WebViewPool (453 lines, domain affinity, caps, mutex) |
both present; registry is explicitly documented as “the core-tier equivalent of the module package’s headless pool” |
| Network capture | NetworkCaptureManager, network_capture_interceptor_js.dart, secret_redactor.dart |
CaptureSource port + CaptureService stub with injectEvent |
core holds the raw source; module holds policy |
| VCR | — | CassetteEngine port + CassetteEngineImpl (gzip JSON, redaction) |
module-only |
| Dialogue dismiss | dialogue_dismisser/ (4 files, exported) |
DialogueDismissPort |
duplicated: implementation in core, port in module |
| Recipes | session_recipe/ (7 files, exported) |
RecipePort |
duplicated |
| Navigation tracking | navigation_tracker/ (3 files, exported) |
NavigationTrackerPort |
duplicated |
| Session store | webview_sessions/webview_sessions.dart (zuraffa_session-backed) |
SessionStore DDA datasource |
not yet extracted |
The core barrel still exports the three duplicated families — navigation_tracker/main.dart, session_recipe/main.dart, and dialogue_dismisser/main.dart are lines 20–22 of src/main.dart — and CONSUMER_TRANSITION_PLAN.md describes the intended bridge: a @Deprecated re-export phase from the core, then removal once consumers migrate.
Sources: SPLIT_MAP.md, zikzak_inappwebview_module/README.md, headless_webview_registry.dart, main.dart, CONSUMER_TRANSITION_PLAN.md
Anatomy of the Grep Gate
Section titled “Anatomy of the Grep Gate”scripts/grep_gate.sh is 74 lines of bash implementing FR-006: “an automated grep gate that fails if identifiers tied to the intelligence layer … appear in the plugin core package, with an explicit carve-out for the raw capture-event plumbing.” It runs two independent checks under set -euo pipefail and exits 1 if either fails.
flowchart TD START(["bash scripts/grep_gate.sh"]) --> CORE["CORE_DIR = zikzak_inappwebview/lib/src"] CORE --> LOOP{"for each of 10 PATTERNS"} LOOP -->|"rg -l pattern --type dart"| MATCH{"any file?"} MATCH -->|no| LOOP MATCH -->|yes| CARVE{"does a CARVEOUT_PATTERN<br/>match the file list?"} CARVE -->|yes| LOOP CARVE -->|no| FAIL1["print FAIL + file list<br/>PASS=false"] FAIL1 --> LOOP LOOP -->|exhausted| MOD["MODULE_DIR = zikzak_inappwebview_module/lib"] MOD --> EXISTS{"directory exists?"} EXISTS -->|no| VERDICT EXISTS -->|yes| PI["rg zikzak_inappwebview_platform_interface --type dart"] PI --> PIHIT{"any hit?"} PIHIT -->|yes| FAIL2["print FAIL + file list<br/>PASS=false"] PIHIT -->|no| VERDICT FAIL2 --> VERDICT{"PASS == true?"} VERDICT -->|yes| OK(["PASS · exit 0"]) VERDICT -->|no| BAD(["Grep gate FAILED · exit 1"])Check 1 is a denylist over the core, split cleanly into class-name forms and file-stem forms:
| Pattern | Form | Target |
|---|---|---|
WebViewPool, CaptureSource, CassetteEngine, DialogueDismissPort, RecipePort, NavigationTrackerPort, VCRWrapper |
PascalCase identifier | the six ports + pool + VCR wrapper |
webview_pool, capture_service, cassette_engine |
snake_case stem | module filenames leaking into core |
network_capture_interceptor_js |
carve-out | the one file permitted to stay |
Check 2 is the converse and is the half that protects the other direction of the contract: if anything under zikzak_inappwebview_module/lib names zikzak_inappwebview_platform_interface, the gate fails. The module directory is optional (if [ -d "$MODULE_DIR" ]), so the gate is meaningful before the module exists and after it is populated. Both checks use rg --type dart with 2>/dev/null || true, so a missing ripgrep degrades to “no matches” rather than an error — the gate requires rg on PATH to have any teeth.
Sources: grep_gate.sh, specs/003-rewrite-umbrella-platform-core/spec.md
The Carve-Out: Why Raw Capture Plumbing Stays
Section titled “The Carve-Out: Why Raw Capture Plumbing Stays”The carve-out is the architecturally interesting line in the script, because it encodes a distinction the class inventory alone would blur. The specification is explicit that “the raw capture event stream stays in core; only the capture management/distillation wiring (state, policy) moves to the module,” and the split map operationalizes it: network_capture_interceptor_js.dart and the interface’s capture event types are Core, while NetworkCaptureManager itself is Module-bound as the CaptureSource adapter because it holds the filtering, budget, and routing policy.
The physical reason is proximity to the WebView. NetworkCaptureManager builds a UserScript injected AT_DOCUMENT_START in all frames, registers the __zikzakNetworkCapture__ JavaScript handler on the controller, and re-flushes the in-page buffer on page load — all of which must happen inside the core’s WebView lifecycle, not across a package boundary. Its only imports are the platform interface, the core controller, the interceptor JS, and the redactor. Meanwhile the module side is pure policy: CaptureService keeps per-session StreamControllers and a budget map, encodes “unlimited” (maxEvents == 0) as -1 so an exhausted zero budget is distinguishable, and exposes injectEvent as the seam the future plugin adapter calls.
Sources: specs/003-rewrite-umbrella-platform-core/spec.md, SPLIT_MAP.md, network_capture_manager.dart, network_capture_manager.dart, capture_service.dart
Precision Limits: What a Green Gate Does Not Prove
Section titled “Precision Limits: What a Green Gate Does Not Prove”A green gate is evidence about ten identifiers, not about the inventory. Four gaps follow directly from the script’s text and are worth holding in mind before treating a pass as architectural proof.
| Limit | Mechanism | Consequence |
|---|---|---|
| Class names absent from the denylist | the list holds ports + pool + VCR only | DialogueDismisser, NavigationTracker, RecipeRecorder, NetworkCaptureManager, WebViewSessions may sit in core and the gate still passes — and today they do |
| Carve-out short-circuits the whole pattern | continue 2 fires if any matched path contains the carve-out string |
a real violation in file B is masked when the carve-out file A also matches the same pattern |
| Substring, case-sensitive matching | rg -l "$pattern" with no anchors |
MyWebViewPoolFactory trips it; a differently-named pool does not |
| Import check is name-based | only zikzak_inappwebview_platform_interface is grepped |
a transitive path to interface internals through another package is invisible |
The correct reading is therefore: the gate proves the seam’s naming discipline, and the split map’s import-graph review proves the rest. FR-002 and SC-001 both describe an import-graph check as the real validator; the script is the cheap, deterministic subset that can run in a shell.
Sources: grep_gate.sh, SPLIT_MAP.md, specs/003-rewrite-umbrella-platform-core/spec.md, specs/003-rewrite-umbrella-platform-core/spec.md
Where the Gate Runs — and Where It Does Not
Section titled “Where the Gate Runs — and Where It Does Not”The gate is a contributor-workflow gate, not a CI job. .github/workflows/ci.yml defines build-linux, analyze, test, test-web, and resolve-floor matrices over eight packages; zikzak_inappwebview_module appears in none of them, and no step invokes grep_gate.sh. Because scripts/local_ci.sh derives its steps by parsing .github/workflows/* at run time — explicitly “not a second copy of the workflow” — the gate does not run there either. Its enforcement surface is the convention in AGENTS.md: “Two-tier split gate: bash scripts/grep_gate.sh must stay green after any core↔module refactor,” and the per-change instruction to run it “for anything touching core↔module boundaries” alongside flutter analyze and flutter test.
Two adjacent facts explain why the module is absent from CI without being an oversight in the gate itself. The module is publish_to: none with version: 0.0.1-dev, and it resolves its siblings through dependency_overrides — including a zikzak_inappwebview_platform_interface path override that exists purely so the core’s transitive dependency resolves against the sibling checkout. PUBLISH.md records the consequence as a hard rule: every published package shares the lockstep version, and “zikzak_inappwebview_module is publish_to: none and is the only package allowed to differ.” A dev-only tier cannot be published, and its lockfile is one of only seven tracked in the repo.
Sources: ci.yml, local_ci.sh, AGENTS.md, AGENTS.md, zikzak_inappwebview_module/pubspec.yaml, PUBLISH.md
Working With the Split
Section titled “Working With the Split”The decision procedure is short enough to apply mechanically. Does the code call a native API, hold no cross-session state, and make no policy decision? It belongs in the core, and it must not name a module-tier identifier. Does it decide, cache, pool, filter, budget, record, replay, or redact? It belongs in the module, behind a port interface, importing only package:zikzak_inappwebview/zikzak_inappwebview.dart. AGENTS.md states the same rule from the contributor’s side: “put it in zikzak_inappwebview_module behind a port interface; never import platform_interface directly; keep scripts/grep_gate.sh green.”
| Situation | Correct tier | Verification |
|---|---|---|
| New WebView setting or platform method | Core (entity + native wiring + facade) | flutter analyze in the affected packages |
| New policy over captured events | Module, as a CaptureSource distiller slot |
module flutter test + grep gate |
| New pooled-session behavior | Module (WebViewPool), reusing HeadlessInAppWebView.maxLiveWebViews as the ceiling |
webview_pool_test.dart acceptance behaviors |
| Anything touching the boundary | either | bash scripts/grep_gate.sh in addition to analyze/test |
One subtlety rewards attention when touching pooling from either side: the live-instance ceiling is a core concern, the pooling policy is not. HeadlessInAppWebView.maxLiveWebViews is a process-wide static, settable only before the first run() (it throws StateError while any headless view is live, and rejects values below 1), with platform defaults of 8 on web, 3 on iOS/Android, 5 on macOS. Both HeadlessWebViewRegistryConfig.platformDefaults() in the core and WebViewPoolConfig.platformDefaults() in the module read that same number, which is precisely why the cap can live in the core while the eviction and affinity policy lives in the module without the two drifting apart.
Sources: AGENTS.md, headless_in_app_webview.dart, headless_webview_registry.dart, webview_pool.dart
Where the Seam Points Next
Section titled “Where the Seam Points Next”The seam is the prerequisite for everything the module is meant to become, so the natural continuation is the contract the module plugs into — The Platform Interface: The Contract Seam — followed by the facades that constitute the module’s entire usable surface in Domain Controller Facades: Navigation, JavaScript, Cookies, Settings. For the pooling and capture policy the module actually ships today, read VCR Cassettes and the WebView Pool and Network Capture, Interception, and Secret Redaction; for the headless ceiling both tiers share, Headless WebView and the Live-Instance Cap. The verification story around the gate continues in Testing Strategy and Per-Package Commands and Continuous Integration, GYM Exercises, and Publishing, and the process that produced the split map itself is documented in Spec-Kit Specification and TDD Workflow.