SSOT / GOVERNING REFERENCEDOCUMENT 10 OF 28

Capability capture and the static-PHP compiler

Status: normative · Core differentiator. This file governs preservation of model-derived work and progressive deterministic reuse.

Purpose

When a model solves a problem, Maistro SHOULD ask: Can any repeatable part of this task now be executed equivalently without another model call? The question applies to artifacts and conversational mechanics: fixed schema extraction, field renaming, repeated explanations built from variables, query routing, validated calculations, policy decisions, log parsing, email/template compositions, command selection and multi-step recipes. The opportunity scanner runs after permissioned sessions, on an operator-defined cadence, and when repeated signatures emerge; it never treats all chat content as automatically reusable.

Exact original capture: non-negotiable

A capture record MUST preserve, byte-for-byte if permitted: (a) original input and output artifacts, (b) relevant original session turns and ordering, (c) model/tool/version and runtime settings where known, (d) attached files by digest, (e) declared user constraints, (f) explicit approvals and data/retention policy, (g) timestamp, run identity, locale and source provenance, and (h) original failure/corrections. Store immutable bytes alongside SHA-256 and optional signed event digests. Never silently strip whitespace, replace phrases, rerun the model, flatten turns or call a reconstructed prompt “original.” Redaction must be a separately identified derivative with its own hash and mapping; sensitive originals require encryption and strict owner consent. If original context is unavailable, mark partial_capture, not exact.

The exact original result is an evidence fixture, not a guarantee that a proposed algorithm generalizes. Preserve the source even when the derived rule is rejected or changed, subject to retention/deletion law and operator settings. Rights and privacy gates precede any capture.

Two-track output from each eligible opportunity

Track A — Faithful base: a candidate reproduction of the specific approved behavior within declared input scope and explicit oracle. Track B — Possibility expansion: automatically generate an initial small set of runnable candidate variations where parameter substitution and bounds are safe; enumerate many more suggested capabilities with their assumptions and required evidence. Both tracks link to the exact original but remain distinct from it.

For example, a reviewed text-template task may yield a base PHP render(template, variables) recipe plus 3 candidates: alternate subject, alternate recipient role and altered tone tag. Suggested expansions may include locale-specific formatting, CSV batch generation, validation mode, no-PII mode, explain-why output, inverse extraction, multi-format export, diff mode and offline batch processing. Suggestions are not silently enabled, and variants that change semantics need an oracle.

Opportunity detection

Evaluate signature frequency, exact/near input structure, response stability, schema regularity, output entropy, deterministic operators, input diversity, availability of labeled counterexamples, model cost and measured local alternative. Preconfigured heuristics may propose: literal substitution, map/reduce, deterministic format conversion, static retrieval, known schema validation, controlled regex/grammar, finite decision tables and known mathematical transformations. A heuristic score never overrides safety or fidelity. Failed attempts remain useful lessons.

Candidate pipeline

session → consent/privacy filter → immutable snapshot → signature grouping → hypothesis → typed candidate template/algorithm → base golden test → at least 3 bounded variant proposals + broader suggestion queue → negative/property/metamorphic tests → measured comparison → human review → signed immutable PHP/data release → canary → monitored local dispatch / fallback.

Every candidate MUST carry status (observed, draft, testable, verified, rejected, promoted, revoked), owner, scope, failure modes, artifacts, exact baseline digest, generation method, number of independent examples, uncertainty, unsupported behavior, oracle and rollback identity. A single snapshot may justify a template hypothesis but not a universal parser.

Compiled rule design

Prefer a finite allowlisted DSL/configuration interpreted by pinned, reviewed PHP functions over emitting arbitrary executable model-written source. Valid release candidates may include bounded PHP functions, JSON tables, query plans, typed macro DAGs and deterministic transformers. Code-generation must happen in an isolated build process; production never executes eval() or writes its own controller source. CI generates golden, negative, mutation and fuzz tests; applies source scanning; benchmarks local correctness, latency and total cost; and records a human review signature.

Variation generation requirements

At least three safe variant examples SHOULD be drafted whenever ≥1 declared dynamic input exists. Generated sample inputs/outputs are labeled derived / unverified until validated. Suggestion categories SHOULD include: new inputs, new output formats, batch operation, constraints, boundary/error cases, permissions, localization, accessibility, observability, reversibility, integration, offline mode, archival/export, deterministic consistency and pipeline composition. Each suggestion records benefit, missing_evidence, policy_risk, estimated_effort and human_review_required.

When to decline conversion

A legal or privacy conflict, hallucination-sensitive reasoning, unbounded subjective judgment, missing necessary context, stochastic creative task, changed external facts, too few representative cases, unstable outputs, insufficient oracle or disproportionate complexity can block static replacement. Capture safe fragments, partial steps, canonical answers with expiry, or an inference-result cache where rights allow. Route novel tasks to a qualified model.

Worked exact-capture example

An operator creates “Hello Ada, your report is ready.” from an approved communication session. Preserve the exact UTF-8 bytes and source hash. For declared name=Ada, test replacing the single exact occurrence Ada with {{name}} and rerender the original. If mismatch or ambiguity, refuse automatic compile. Then propose, e.g., name=Jo, name=Kai, and name=Sam, each explicitly candidate outputs. Suggest batch CSV, HTML-escaped rendering, plural handling and localization as future reviewed capabilities. An uncontrolled language-model rewrite would not satisfy exact preservation.

The reference CLI implements only bounded string-template capture and synthetic variants, not automated extraction from chat apps or arbitrary LLM-to-PHP conversion. See PHP reference and current status.

Related

Fidelity · Memory · Data security · Offline.