Experimental research reports

Use these pure helpers to report caller-supplied observations in offline experiments. They do not enforce permissions, validate source provenance, evaluate task artifacts, inspect causal traces, or measure provider cache hits. The host owns those checks. See Inspiration primitives (host import guide) for stable integration surfaces and Trouble research and implementation for the remaining Trouble acceptance gaps.

Claim and ledger review

Review caller-supplied claim labels against a caller-supplied ledger.

Retrieved pages, discovered resource names, and agent memory may be recorded. They do not create grants, drop exclusions, or revive a revoked operation. This experimental report helper does not verify provenance or dispatch effects.

class mechaharness.authority_admission.AdmissionClaim(*, id: str, source_class: str, kind: str = 'requirement', quote: str = '', predicate: str = '', uncertain: bool = False, **extra_data: Any)[source]

Bases: BaseModel

A source label supplied by the caller, awaiting actual source/gate validation.

id: str
kind: str
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

predicate: str
quote: str
source_class: str
uncertain: bool
class mechaharness.authority_admission.AdmissionReport(*, decisions: dict[str, str]=<factory>, effects: dict[str, ~typing.Literal['ledger_match', 'ledger_miss']]=<factory>, gate_status: Literal['not_evaluated'] = 'not_evaluated', evidence_origin: Literal['caller_supplied'] = 'caller_supplied')[source]

Bases: BaseModel

decisions: dict[str, str]
effects: dict[str, Literal['ledger_match', 'ledger_miss']]
evidence_origin: Literal['caller_supplied']
gate_status: Literal['not_evaluated']
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class mechaharness.authority_admission.ProposedEffect(*, resource_id: str, operation: str, id: str)[source]

Bases: ResourceOperation

id: str
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class mechaharness.authority_admission.ResourceOperation(*, resource_id: str, operation: str)[source]

Bases: BaseModel

An entry in a host-supplied ledger; it is not an authorization token.

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

operation: str
resource_id: str
mechaharness.authority_admission.review_admission(*, ledger: list[dict[str, str]], claims: list[dict[str, Any]], effects: list[dict[str, str]]) → dict[str, Any][source]

Report supplied claim labels and resource/operation ledger matches.

ledger entries are {resource_id, operation} from the host authority store. claims carry id, kind, source_class, quote, and optional predicate, resource_id, operation, uncertain. effects are proposed calls {id, resource_id, operation}.

The host must authenticate source labels and own the trusted ledger before calling. A nonempty predicate is recorded, not evaluated; source_label_accepted does not verify the quote against a source. ledger_match means exact membership in the supplied ledger, not authorization by AuthorityGate. The host must still enforce grants and revalidate authority when dispatching effects.

Example

>>> review_admission(ledger=[], claims=[{
...     "id": "memory", "source_class": "memory",
...     "predicate": "restore write permission",
... }], effects=[{
...     "id": "write", "resource_id": "object:X", "operation": "write",
... }])["effects"]
{'write': 'ledger_miss'}

Paired verdict reporting

Paired task-success and harness-fidelity scores.

A correct file can hide a dropped tool error, and a faithful harness can still deliver a wrong answer. Missing observations stay unknown; they are not rewritten as a pass or as an infrastructure failure.

class mechaharness.layered_verdict.LayeredEvaluation(*, task: Claim, harness: Claim, outcome: EvaluationOutcome, causal_support: Claim | None = None)[source]

Bases: BaseModel

Typed report over existing evaluation claims; supplied claims are not observations.

causal_support: Claim | None
harness: Claim
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

outcome: EvaluationOutcome
report() → dict[str, Any][source]
task: Claim
mechaharness.layered_verdict.score_layers(*, task: Literal['pass', 'fail'], harness: Literal['pass', 'fail'] | None = None, harness_observed: bool = True, infrastructure_failure: bool = False, trace_supports_cause: bool = False) → dict[str, Any][source]

Combine caller-supplied task and harness verdicts for one run.

The caller evaluates task success and trace fidelity before calling this helper. Missing harness observations yield unknown; an infrastructure failure leaves both layers unscored. A run is clean only if both pass. attribution='caller_asserted' records the caller’s trace_supports_cause assertion when both fail; this helper does not inspect causal evidence.

Example

>>> lucky = score_layers(task="pass", harness="fail")
>>> (lucky["task"], lucky["harness"], lucky["clean"])
('pass', 'fail', False)
>>> score_layers(task="pass")["harness"]
'unknown'
>>> score_layers(task="fail", harness="fail")["attribution"]
'hypothesis'

Selected request-field comparison

Compare selected request fields without storing their prompt text.

The report labels tool-order and policy changes for offline experiments. It neither observes the serialized provider request nor measures cache misses.

mechaharness.request_prefix.classify_prefix_change(before: dict[str, Any], after: dict[str, Any], *, provider_metrics: bool) → dict[str, Any][source]

Label a change between two prefix_snapshot() reports.

provider_metrics is caller-supplied availability, not measured telemetry. Identical snapshots yield unknown without it. volatile_system means policy text changed without a version bump; the helper cannot tell a clock from a legitimate edit. Labels are heuristic experiment categories, not observed cache-miss causes. Policy-version changes take precedence over tool-order changes. Changed tool names or schemas take priority and yield unknown: their legitimacy cannot be determined by comparing hashes alone.

Example

>>> snap = prefix_snapshot(tools=[], policy="policy", policy_version="1",
...                        dynamic="task")
>>> classify_prefix_change(snap, snap, provider_metrics=False)["cause"]
'unknown'
>>> classify_prefix_change(snap, snap, provider_metrics=True)["cause"]
'match'
mechaharness.request_prefix.prefix_snapshot(*, tools: list[dict[str, Any]], policy: str, policy_version: str, dynamic: str) → dict[str, Any][source]

Hash caller-supplied tool, policy, and dynamic blocks.

Tool fingerprints include only name and parameters (missing or empty parameters normalize to an empty dict). Descriptions and provider-specific fields are omitted. Policy text and dynamic text are hashed; policy_version is retained verbatim and must be a nonsensitive identifier. These hashes are diagnostics, not a secrecy guarantee or full wire-request fingerprints.

Example

>>> snap = prefix_snapshot(tools=[{"name": "read"}], policy="Be concise",
...                        policy_version="1", dynamic="Read a file")
>>> sorted(snap)
['dynamic', 'policy', 'policy_version', 'tools_canonical', 'tools_order']
>>> snap["policy_version"]
'1'