Skip to content

Phase 0 (execution-integrity surgery) + Phase 1.0 (drift harness) — combined landing - #25

Open
Alajmah wants to merge 22 commits into
mainfrom
phase1.0/drift-harness
Open

Alajmah wants to merge 22 commits into
mainfrom
phase1.0/drift-harness

Conversation

@Alajmah

@Alajmah Alajmah commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Scope correction (pre-merge, per reviewer ruling). This PR originally described itself as "Phase 1.0 harness only / no production code changes." That was inaccurate. The branch carries 22 commits because Phase 0.1–0.5 (execution-integrity surgery — receipt fields, confidence cap, authorization-token rename, preflight ordering, schema unification) was developed on this branch and never independently merged to main (origin/main sits at the v2.1.0 release, 79c7f7a). This body is rewritten before merge to make the audit record honest — turning the mistake into an example of the honesty-gated doctrine working. — ZCode + ChatGPT, fresh-thread msg 3

What this actually lands (two phases, one PR)

Phase 0 — execution-integrity surgery (8b03684…768eb45, 13 commits)

The "make the execution contract honest" sprint. This is production code change — the original body's "no production changes" claim was wrong:

  • 0.1 — 22 receipt evidence fields (contract §3)
  • 0.2 — confidence cap: confidence must not outrun evidence (§4); four-factor min()
  • 0.3 — rename TOCTOU fingerprint → pre-dispatch authorization token (§1)
  • 0.4 — bind runtime preflight to the resolved policy decision (T0.5 green)
  • 0.5 — unify action schema: ACTION_SPECS generated from CAPABILITIES

Phase 1.0 — drift-injection harness (6934d17…46aec66, 9 commits)

The test infrastructure that makes the 9 T1.* integrity tests executable. No further production wiring beyond Phase 0; pure test infrastructure + docs. Reviewer-accepted (ChatGPT) and owner-approved.

Test state

All Phase 0 tests green T0.1–T0.6
T1.5, T1.8, T1.10 green token-stale blocking (0.4) + schema presence (0.1)
8 xfail(strict=True) T1.1, T1.2, T1.3a, T1.3b, T1.4, T1.6, T1.7, T1.9 — Phase 1.1/1.2 work target
0 skipped
0 regressions cascade: 124 passed; the 2 test_deps_installed failures pre-exist on main (Windows-only deps)

The 8 xfail tests are intentionally red — they encode missing lease/floor/postcondition wiring. strict=True keeps them enforceable: they'll fail CI if Phase 1.1/1.2 accidentally makes one pass, forcing an explicit transition.

The harness (tests/test_runtime/drift_harness/)

FakeSurfaceAdapter with the two-clause falsifiable invariant (clause A: poison-on-BLOCK catches illicit dispatch; clause B: target-identity-on-EXECUTE catches right-params-wrong-target — the green-while-unsafe gap), DriftInjector (5 hooks incl. H1), 6 real-resolver fixtures, 4 synthetic __test_* capabilities. 19 harness self-tests green.

Why not split into two PRs

Phase 0 and Phase 1.0 were developed interleaved on one branch; the commit boundaries (phase0.* / phase1.0.*) preserve phase separation for audit/bisect. Splitting now re-opens already-accepted Phase 0 work for a second review lifecycle with no new information. (Co-developer ruling, fresh-thread msg 3.)

Contract docs

  • docs/EXECUTION_INTEGRITY_CONTRACT.md (v0.3) — the locked semantics
  • docs/superpowers/specs/2026-07-03-phase1.0-drift-harness-contract.md — the harness contract (A1–A3 + fidelity review)
  • plans/PHASE-1.0-DRIFT-HARNESS.md — impl plan + Phase 1.1 handoff (§7)

Next

Phase 1.1 (production lease/floor/postcondition wiring — what makes the 8 reds green) starts from this baseline, on a fresh branch, after a co-drafted compact plan. Not in this PR.

🤖 Generated with ZCode

Alajmah added 13 commits July 2, 2026 18:30
Product vision and 4-phase improvement roadmap developed as an equal-partner
collaboration between ZCode and ChatGPT, arbitrated by the owner.

Vision: Deskaoy is the local-first, governed execution layer for AI desktop
automation — 'honest hands' between model intent and real UI side effects.
Wedge: 'governed reliability' (the combination no competitor has).

Four pillars: governed execution, reliable grounding+recovery, agent-native
local runtime, honest cross-platform coverage. Owner arbitrated two forks:
reliability co-equal with governance (not subordinate), and macOS
validate-or-cut.

Roadmap: Phase 0 (shrink trusted core — thin sprint), Phase 1 (real TOCTOU +
recovery + deterministic reliability harness), Phase 2 (fleet-grade audit,
data model early / product later), Phase 3 (coverage claim lockdown +
platform proof, with truth-in-labeling pulled forward).

Implementation planning is a separate follow-up (writing-plans skill).

Signed-off-by: Alajmah <alajmah@users.noreply.github.com>
…irst debate)

Replaces the earlier 8b03684 version, which was a transcription of ChatGPT's
positions, not a peer synthesis. This version is the product of a real debate
in conversation 6a468903-f904-83ed-86cb-812cbf11ba52.

The debate: ZCode argued governance-first (reliability is a fight we lose on
the frontier labs' terms); ChatGPT argued reliability co-equal (governance
without reliability is compliance theater). Two rounds + code verification
settled it on a doctrine neither started with:

  'Governance-first, honesty-gated, integrity-floored, reliability-measured.'

Key code-grounded findings that drove convergence:
- StaleRefResolver (cascade/resolver.py) is a built, tested 3-tier element
  resolver that is NOT wired into execute(). The integrity floor is integration
  of existing components, not research.
- SnapshotStore.is_stale()/get_element() exist but are unused on the hot path.
- _compute_fingerprint() (preflight.py:285) is a near-non-binding staleness
  token, not TOCTOU protection — renamed accordingly.
- _confidence_from_action() returns 0.9 for any result.ok; the confidence cap
  table makes 'confidence must not outrun evidence' concrete.
- Receipt schema lacks target_bound/verification_scope/residual_risk — the
  honesty-gated pillar requires extending it.

1.0 gate = 100% pass on an 8-test hostile-fixture invariant suite, not a
success-rate number. Full semantic TOCTOU stays on a labeled research track.

Signed-off-by: Alajmah <alajmah@users.noreply.github.com>
…ntic review)

The handshake artifact between the governed-execution doctrine (roadmap e4058ce)
and the code. Freezes the semantics before any implementation, so Phase 0 builds
against a locked contract rather than prose-to-code interpretation.

ZCode drafted; ChatGPT did semantic review and landed two corrections that
shaped v0.1:
1. Temporal scope model — verification_scope split into pre_dispatch_scope
   (used for policy floor), post_dispatch_scope (observed after execution),
   and effective verification_scope (weaker of the two, for confidence). The
   'decrease-only' invariant in the draft was logically broken because
   element_lease_plus_postcondition is only knowable after dispatch and cannot
   be a pre-dispatch floor.
2. Policy provenance on auto-degradation — recoverable/draftable can auto-degrade
   below normal_floor to degraded_floor, but only when recorded as policy-mediated
   (degraded_execution + policy_allowed_weak_verification + policy_weak_verification_source).
   Without this, 'floor' is not a floor.

Other fixes from review: draftable separated from recoverable (drafts are
semantically risky); added resolver_match_score/gap/candidates_n for future tier
promotion; confidence = min(adapter, scope_cap, policy_degradation_cap,
postcondition_cap); none cap lowered 0.35->0.30.

Locks: verification_scope enum, confidence cap formula, action-class policy
matrix (normal_floor + degraded_floor per class), and the T0.1-T0.6 + T1.1-T1.8
invariant suite that is the 1.0 gate.

Next: encode as failing invariant tests (red), then Phase 0 implementation plan.

Signed-off-by: Alajmah <alajmah@users.noreply.github.com>
…ged decisions)

v0.3 applies three revisions from the ZCode+ChatGPT peer review of v0.2's
flagged (🔶) judgment calls. All three are minor-revision scope per §8 (no
floors/enums/cap-factors changed):

1. Renamed 'preflight staleness token' -> 'pre-dispatch authorization token'.
   Reframed as policy-decision currency (not UI staleness); made explicit it's
   valid only if computed after final policy resolution; added the
   hard-gate-before-floor invariant. Necessary-but-not-sufficient caveat
   recorded. ChatGPT caught that the current token doesn't yet bind real policy
   (policy_decision=None) so the contract must not imply it has authority it
   doesn't have. (§1, §2, T0.5, T1.5)

2. postcondition_cap made action-class-aware (absent 0.45-0.60, inconclusive
   0.40-0.55, by class) instead of global 0.35/0.50. Separated *alarm*
   (requires_reconciliation / retry_safe) from *confidence* so the number stays
   a calibrated evidence score. ZCode argued 0.35 too punitive; ChatGPT pushed
   back on 0.60 for irreversible; converged on the class-aware table. (§3, §4)

3. T1.9 added: irreversible+executed+unconfirmed-postcondition ->
   degraded_execution=false (semantically correct: pre-dispatch floor was
   satisfied) BUT outcome_confidence=unconfirmed + requires_reconciliation=true
   + retry_safe=false + result.status=NEEDS_REVIEW (existing ResultStatus enum
   value, confirmed at os_types.py:325 — the salient caller trigger). Don't
   overload degraded_execution; fire a separate loud signal. (§6)

Also adds outcome_confidence, requires_reconciliation, retry_safe fields (§3 ->
17 fields total), T1.10 (read_only schema honesty), and updates T1.6/T1.8 to
reference the class-aware cap and new fields.

The contract is v0.3 until red tests land and pass, then v1.0 (locked).

Signed-off-by: Alajmah <alajmah@users.noreply.github.com>
…v0.3

Encodes §6 of docs/EXECUTION_INTEGRITY_CONTRACT.md (v0.3) as failing tests.
These ARE the 1.0 gate: Deskaoy is not 'trustworthy' until 100% pass in a
hostile-fixture suite.

State: RED (verified).
- 6 FAILED (T0.1-T0.5, T1.8): Phase 0 honesty tests that don't need the drift
  harness. Each fails because the v0.3 contract field/behavior doesn't exist
  yet (pre_dispatch_scope is None; confidence returns 0.9 not <=0.30; 19
  evidence fields absent; preflight still claims 'TOCTOU detection').
- 2 PASSED (T0.6, T1.10): vacuously true today (degraded_execution never set;
  read-only fields absent -> accepted as 'honest none'). Will flip to RED as
  Phase 0 lands real fields. Correct TDD progression.
- 9 SKIPPED (T1.1-T1.7, T1.9): Phase 1 integrity tests gated on the
  drift-injection harness that Phase 1 builds.

Per the agreed sequence (contract -> red tests -> Phase 0 implementation plan),
the next step is writing-plans turning Phase 0 into implementation patches
against this locked test suite.

Signed-off-by: Alajmah <alajmah@users.noreply.github.com>
Negotiated in the open with ChatGPT (conversation 6a468903, messages 28-30)
after the owner corrected an error: ZCode had been treating ChatGPT as unable
to read the repo, which was false (repo is public at github.com/Octo-Lex/Deskaoy;
ChatGPT read it accurately throughout the contract review).

Records the agreed coordination so it's visible to any reader/future session,
not buried in a chat thread:
- Task rhythm: draft -> cross-review -> ZCode runs verify loop -> report back
- Two mandatory plan headers (ChatGPT amendments A+B): test target + contract
  scope per task
- Execution mode: inline-with-checkpoints for Phase 0 core (semantically
  coupled; subagents risk doctrine violations). Subagents reserved for 0.5/
  Phase 1/docs.
- Sequencing is durable; ownership is flexible per ChatGPT's guardrail.
- Initial drafting assignments: 0.1 ChatGPT, 0.2/0.3 ZCode, 0.4 ChatGPT,
  0.5 deferred.
- The 'can't access repo' error and the retracted 'lead+meta-review' split
  are on the record.

Signed-off-by: Alajmah <alajmah@users.noreply.github.com>
Adds schema/default plumbing for execution-integrity receipt evidence per
contract v0.3 §3. Drafted by ChatGPT, cross-reviewed by ZCode, executed through
the verify loop per the agreed coordination model.

RuntimeExecutionReceipt gains 22 evidence fields (adapter_acknowledged,
target_bound, resolver_match_level/score/gap/candidates_n, precondition_rechecked,
postcondition_required/verified, pre/post_dispatch_scope, verification_scope,
residual_risk, evidence_refs, confidence_cap_reason, degraded_execution,
policy_allowed_weak_verification, policy_weak_verification_source, blocked_reason,
outcome_confidence, requires_reconciliation, retry_safe). All serialized in
to_dict(); all pessimistic defaults until Phase 1 wires real evidence.

Construction sites (4 in desktop_agent.py) wired strict-minimal:
- blocked preflight: adapter_acknowledged=False, blocked_reason set
- stale fingerprint: adapter_acknowledged=False, blocked_reason='preflight_stale'
- timeout: adapter_acknowledged=False
- completion: adapter_acknowledged=True (independent of result.ok); read-only
  actions carry honest 'not_applicable' scope/postcondition/resolver values (T1.10)

Field-count defect caught in cross-review: contract §3 said '17 fields' but the
table listed 20+; corrected to 22 (the number the table actually describes).
T1.8 aligned to assert all 22 via a shared RECEIPT_EVIDENCE_FIELDS set with
inclusion semantics.

Verify loop results:
- T0.1, T0.3, T1.8: RED -> GREEN (0.1's primary targets)
- T0.6, T1.10: vacuous -> GREEN (honest defaults)
- T0.2, T0.4, T0.5: remain RED (Phase 0.2/0.3/0.4 targets, not 0.1)
- test_receipt_wiring.py (17 tests): GREEN, no regression
- test_mss_imports: pre-existing ModuleNotFoundError, unrelated

Leaves confidence caps, authorization-token rename, preflight ordering, and real
lease evidence computation for later Phase 0/1 tasks.

Signed-off-by: Alajmah <alajmah@users.noreply.github.com>
…act §4)

Replaces the lying _confidence_from_action() (returned 0.9 for any result.ok)
with the contract §4 four-factor cap formula:
  confidence = min(adapter_confidence, verification_scope_cap,
                   policy_degradation_cap, postcondition_cap)

For 0.2, only verification_scope_cap binds. The other three factors are
plumbed but non-binding: policy_degradation_cap=1.0 (degraded_execution is
always False in 0.1), postcondition_cap=1.0 (postcondition_verified is always
'not_applicable' until Phase 1). Formula is structurally complete so later
phases only change which factor binds, not the shape.

Added module constants VERIFICATION_SCOPE_CAPS (scope->cap, incl. read-only
not_applicable=1.00) and POSTCONDITION_CAPS (class-aware table per §4) —
the latter plumbed for Phase 1.

Call site (desktop_agent.py:1170) updated to pass verification_scope +
action_class; confidence.reason now feeds receipt.confidence_cap_reason
(was 'unset' from 0.1).

Verify loop:
- T0.2 (confidence <= 0.30 for scope=none): RED -> GREEN
- T0.1/T0.3/T1.8/T0.6/T1.10: stay GREEN
- T0.4/T0.5: remain RED (Phase 0.3/0.4)
- test_receipt_wiring.py (17): GREEN, no regression
- two_step + aios_bridges (62): GREEN — the confidence-adjacent suites
  don't flow through _confidence_from_action, confirmed safe
- broad sweep 249 passed; only failures are T0.4/T0.5 + pre-existing
  ModuleNotFoundError on optional deps (mss/comtypes)

Drafted by ZCode per coordination assignment; cross-review pending (composer
degraded during send, proceeding on stated positions: only scope_cap binds in
0.2; reorder is clean).

Signed-off-by: Alajmah <alajmah@users.noreply.github.com>
…s-review

Refactors Phase 0.2 per ChatGPT's cross-review (which I executed without due
to composer degradation — on the record in the thread):

1. Introduces _receipt_evidence_defaults(cap_meta) helper that centralizes the
   §3 default values + read-only not_applicable override. Eliminates the
   inline conditional that 0.1 put in the receipt construction site.
2. _confidence_from_action now takes receipt_evidence dict instead of separate
   kwargs, so confidence and receipt read from the SAME evidence and never
   drift. Confidence.reason feeds back into the dict before receipt construction.
3. Receipt construction uses **receipt_evidence splat — no frozen-receipt
   mutation, no circularity.
4. Adds two focused unit tests (per ChatGPT): mutating+none caps to <=0.30 with
   binding=verification_scope; read-only+not_applicable returns 0.9 uncapped.
5. POSTCONDITION_CAPS comment made explicit about non-binding not_applicable rows.
6. Records retry-path confidence-ordering follow-up in roadmap §5 (risk #5).

Kept the class-aware (action_class, postcondition_verified) tuple-keyed
POSTCONDITION_CAPS table per the contract §4 — pushed back on ChatGPT's flat
version, which would have lost class-awareness.

Verify loop: T0.2 (3 tests incl. 2 new unit) GREEN; contract suite 8 passed
(was 6); receipt_wiring+aios_bridges 68 passed; only T0.4/T0.5 remain RED.

Signed-off-by: Alajmah <alajmah@users.noreply.github.com>
Per contract §1 / T0.4. The fingerprint computation was marketed as 'TOCTOU
detection' but binds nothing about the target element — it only proves the
authorization context (policy effect, capabilities, preflight checks, time
bucket) hasn't drifted. Renamed to reflect what it actually is.

Changes:
- preflight.py: _compute_fingerprint -> _compute_authorization_token; docstring
  reframed as policy-decision currency (not TOCTOU protection, not target
  binding; full semantic TOCTOU is on the research track). Call site updated.
- desktop_agent.py: comment 'B38: TOCTOU check' -> 'authorization-token
  staleness check'; truth_message '(TOCTOU detected)' -> 'authorization token
  stale'; confidence reason 'TOCTOU detected' -> 'authorization token stale';
  call site _compute_fingerprint -> _compute_authorization_token.

NOT renamed (intentional, breaking-change avoidance): PreflightResult.fingerprint
field and receipt.preflight_fingerprint field stay — those are serialized names
consumers may read. The contract §1 renames the CONCEPT, not every field
coincidentally named 'fingerprint'.

Verify loop:
- T0.4 (no TOCTOU labeling + authorization-token terminology): RED -> GREEN
- 9 passed in contract suite; only T0.5 remains RED (Phase 0.4)
- receipt_wiring (17): GREEN, no regression

Phase 0.3 drafted by ZCode; cross-review pending in thread (0.2 post-hoc review
landed instead — proceeding on defensible default re: field-name scope).

Signed-off-by: Alajmah <alajmah@users.noreply.github.com>
ChatGPT's delayed 0.3 review (composer lagged) caught two improvements to the
already-committed 0c48794:

1. The stale-token branch's summary + issue.message still said 'fingerprint
   stale' / 'preflight_stale' — renamed to 'Authorization token stale' /
   'authorization_token_stale' so all user/runtime-facing language in the
   branch is consistent with the rename (truth_message + confidence.reason
   were already done).
2. Docstring softened 'proof the authorization context' -> 'binds these inputs
   so dispatch can detect drift... not cryptographic proof of the whole
   context' — a hash over selected inputs plus a time bucket is not proof.

Serialized field names (PreflightResult.fingerprint, receipt.preflight_fingerprint)
remain unchanged per both partners' agreement — 0.3 renames the concept, not
the storage slots.

Verify: T0.4 GREEN, receipt_wiring 17 GREEN (no regression).

Signed-off-by: Alajmah <alajmah@users.noreply.github.com>
…e 0 complete)

Fixes the causality bug ChatGPT originally flagged: RuntimePreflight.run()
was called with policy_decision=None before policy resolved, making the
authorization token policy-binding input meaningless. Policy is now resolved
FIRST, then the token is computed over the real decision (contract 1).

Per ChatGPT 0.4 draft (Option A - move policy before preflight, not split):
- Policy block moved before RuntimePreflight.run. Preflight receives the
  resolved policy_decision instead of None.
- Authorization-token staleness recheck receives the same policy_decision.
- T0.5 rewritten with monkeypatch spies asserting the no-None invariant.

ALLOW_ONCE coupling (risk ChatGPT flagged in Step 3): moving policy before
preflight meant CHK-PF-05 now sees the real DENY effect on the ALLOW_ONCE
path. Fixed by passing policy_override_allowed into RuntimePreflight.run;
_check_policy_allowed treats DENY+override as allowed.

Verify: T0.5 RED->GREEN; contract suite 10 passed 0 failed; safety 377
passed; broad sweep 958 passed 0 failed. ALL PHASE 0 HONESTY TESTS GREEN.

Drafted by ChatGPT; cross-reviewed and executed by ZCode.

Signed-off-by: Alajmah <alajmah@users.noreply.github.com>
Eliminates the CAPABILITIES/ACTION_SPECS drift that was a latent correctness
bug. ACTION_SPECS is now GENERATED from CAPABILITIES at runtime via
capabilities_to_specs(), not hand-maintained. One authoritative source.

Reconciled 5 divergences (CAPABILITIES corrected to match the more-accurate
old ACTION_SPECS values):
1. click.button enum: [left,right,double] -> [left,right,middle] ('double'
   is a click count, not a button; 'middle' was missing)
2. click.target: required=True -> required=False (x,y coordinates are an
   alternative). Added x,y,num_clicks params with bounds.
3. type_text: added 'target' to required (needed for lease binding in Phase 1)
4. navigate: param renamed 'target' -> 'url' (semantically correct)
5. evaluate: removed from ACTION_SPECS (not in CAPABILITIES — browser-era leftover)

Generator converts JSON-schema-style input_schema properties to ParameterSpec
objects with type mapping, enum extraction, min/max bounds, and max_length
defaults. Lazy-initialized to avoid circular import (desktop_agent imports
validate_action from safety; generator imports CAPABILITIES from desktop_agent).

Added 2 consistency tests: is_generated_from_capabilities flag check + button
enum drift check. Both RED before, GREEN after.

Verify: 31 action_validator tests green; contract suite 10 passed; receipt
wiring 17 passed; broad sweep 960 passed, 0 failed.

Drafted by ZCode; cross-review pending (composer degraded). This unblocks
Phase 1 lease wiring (target resolution depends on schema consistency).

Signed-off-by: Alajmah <alajmah@users.noreply.github.com>
@gitwire-hq gitwire-hq Bot added the size/XL label Jul 2, 2026
Alajmah added 8 commits July 3, 2026 02:58
…ner approved)

The Phase 1.0 drift-harness contract (docs/superpowers/specs/) and implementation
plan (plans/) — the artifacts that unblock the 9 skipped T1.* integrity tests.

Contract: ChatGPT draft (msg 59) + ZCode A1-A3 cross-review (msg 62 rulings) +
fidelity review (msg 65/67): five amendments incl. the two-clause falsifiable
invariant (clause A no-dispatch-on-BLOCK + clause B right-target-on-EXECUTE, the
green-while-unsafe gap closure) and the H1 pure-monkeypatch ruling (no production
seam). 12 acceptance criteria.

Plan: 6-step red-verify build sequence under tests/test_runtime/drift_harness/.
Real StaleRefResolver + fake snapshots; synthetic __test_* capabilities (A2);
T1.6 policy-forced postcondition vs T1.9 irreversible (A3); public resolver fields
only in 1.0 (A1).

Also: gitignore the local .chatgpt-collaboration.json binding.

Reviewer: ChatGPT (approved, msg 67). Owner: Alajmah (approved).
Signed-off-by: Alajmah <55954113+Alajmah@users.noreply.github.com>
The drift-injection harness foundation, proven at the unit level before any
runtime wiring. tests/test_runtime/drift_harness/:

- drift_injector.py: DriftEvent/Hook enums (5 hooks incl. H1 amendment),
  DispatchEscapeError (subclass AssertionError), DispatchRecord carrying
  resolved_ref/resolved_automation_id (clause B).
- fake_surface.py: FakeSurfaceAdapter implementing the adapter protocol + the
  two-clause falsifiable invariant:
    clause A — poison_on_dispatch raises BEFORE appending (dispatch_log stays [])
    clause B — _guard resolves the live target from params+tree only (adapter
              isolation) and records its identity; wrong-target-on-execute detectable
  Plus apply_drift (H2/H4 via surface; H1 explicitly rejected) and snapshot()
  returning an AXSnapshot the real resolver consumes.
- fixtures.py: 6 ResolverFixture builders (exact/stable/reidentified_unique/
  reidentified_ambiguous/not_found/window_stale) constructed to force the REAL
  StaleRefResolver into each tier (A1: public fields only; no numeric score/gap).

Verification (15 tests, all green):
- test_harness_skeleton.py (9): both clauses hold; adapter isolation; real
  resolver reaches EXACT via the fake snapshot.
- test_resolver_tiers.py (6): real StaleRefResolver (unmocked) produces each
  fixture's expected tier — the load-bearing proof the harness doesn't fake
  resolver outcomes.

Contract: docs/superpowers/specs/2026-07-03-phase1.0-drift-harness-contract.md
Signed-off-by: Alajmah <55954113+Alajmah@users.noreply.github.com>
H1 checkpoint (contract §3.3 + fidelity review msg 65 ruling). T1.5 is the one
Phase 1.0 step whose strategy was a contract-level ruling: pure monkeypatch,
NO production `_drift_hooks` seam.

Implementation: the test wraps RuntimePreflight._compute_authorization_token so
the first call (preflight capture at desktop_agent.py:922) computes the real
token and the second call (the L1020 recheck) returns a deliberately mismatched
'DRIFTED_TOKEN'. That trips the EXISTING Phase-0.4 stale-token block path
(L1025-1057) — blocked_reason='preflight_stale', adapter_acknowledged=False,
runtime_execution_performed=False, no dispatch.

Verification: T1.5 GREEN (expected per contract §8 — token-stale blocking is a
Phase 0.4 deliverable, not lease wiring). The test asserts:
  - recheck seam reached (≥2 token computations)
  - clause A: dispatch_log == [] (poison adapter never called)
  - blocked_reason == 'preflight_stale'
  - adapter_acknowledged == False

No production files touched. No new imports beyond the harness. Suite: 26 passed
(+1), 8 skipped (-1).

Contract: docs/superpowers/specs/2026-07-03-phase1.0-drift-harness-contract.md §3.3
Signed-off-by: Alajmah <55954113+Alajmah@users.noreply.github.com>
Contract amendment A2: no production CAPABILITIES entry is tagged external or
irreversible today. T1.7 (external below floor) and T1.9 (irreversible
executed-unconfirmed) need fixtures against those classes. Rather than promote a
production capability (a product-semantics change), register test-only entries
via monkeypatch.

- synthetic_actions.py: __test_external_send (action_class=external) and
  __test_irreversible_submit (action_class=irreversible). The __test_ prefix
  marks them harness-only. install_synthetic_capabilities(monkeypatch) patches
  them into deskaoy.desktop_agent.CAPABILITIES + ACTION_CLASSES for the test,
  restored on teardown. Never touches production at import.
- FakeSurfaceAdapter already implements send_external / submit_irreversible
  (added in step 1) with the same _guard poison/identity mechanism.

Verification (4 tests green):
- synthetics absent from production CAPABILITIES at import (test-only enforced)
- install_registers makes them visible + ACTION_CLASSES derived correctly
- _restore_method_for_class maps external→COMPENSATE, irreversible→NONE
- A2 guardrail: __test_irreversible_submit flows through the full runtime path
  (validate_action → policy → preflight → dispatch) and records dispatch via the
  fake adapter's _guard, with resolved_ref == the live target.

Prerequisite for T1.7/T1.9 unskip in commit 5.

Signed-off-by: Alajmah <55954113+Alajmah@users.noreply.github.com>
…te (commit 5)

The point of no easy return. All 9 T1.* invariant tests are now executable and
wired to the drift harness. None skipped. The 8 lease/floor/postcondition tests
land RED for the right reasons (contract §8); T1.5 is green (Phase 0.4).

Unskipped (each asserts the contract's target receipt/dispatch state):
- T1.1 focus-steal → BLOCK (sensitive): poison adapter caught the escape — runtime
  dispatched despite focus drift because lease rechecks aren't wired (Phase 1.1).
- T1.2 target-delete → BLOCK (sensitive): clause A fires on illicit dispatch.
- T1.3a recoverable+reidentified → NORMAL_EXECUTE: dispatch correct (clause B,
  resolved_ref=e7) but resolver_match_level='none' not 'reidentified' (resolver
  unwired on hot path) — truthful red.
- T1.3b draftable+reidentified → DEGRADED_EXECUTE: same, plus degraded provenance
  absent.
- T1.4 ambiguous → BLOCK: clause A catches coordinate/first-match fallback.
- T1.6 postcondition-absent → NORMAL_EXECUTE_WITH_ABSENT_POSTCONDITION (A3,
  policy-forced pc on __test_external_send): no tier upgrade not yet enforced.
- T1.7 external+reidentified → BLOCK (A2 synthetic __test_external_send): below-
  floor block absent.
- T1.9 irreversible executed-unconfirmed (A2 synthetic, two-phase H2+H4 fixture):
  NEEDS_REVIEW/reconciliation/retry_safe=false outcome not yet represented.

Also added 2 synthetic capabilities (recoverable/draftable target-bearing) for
T1.3a/T1.3b — production lacks target-bearing actions in those classes.

Red-state verification (the contract §8 gate):
  8 failed (truthful — missing lease/floor/postcondition wiring, not harness bugs)
  11 passed (T0.* Phase 0 + T1.5 token-stale + T1.8/T1.10 schema)
  0 skipped (acceptance criterion #1 met)

The 8 reds are the Phase 1.1/1.2 work target. Harness itself: 19 tests green.

Contract: docs/superpowers/specs/2026-07-03-phase1.0-drift-harness-contract.md
Signed-off-by: Alajmah <55954113+Alajmah@users.noreply.github.com>
…t (commit 6)

Final stabilization. The contract doc said blocked_reason='authorization_token_stale'
but the Phase-0.4 runtime emits 'preflight_stale' (desktop_agent.py:1042). Per the
fidelity review (msg 71): Phase 1.0 does NOT rename production code; instead amend
the doc and note the semantic equivalence.

- §4 scope mapping + footnote ¹: authorization_token_stale (doc vocab) =
  preflight_stale (code constant). Same event, two names until a later cleanup.
- §6.1 T1.5 assertion: references the code's actual 'preflight_stale' value.

Regression sweep: zero Phase 1.0 regressions. The 2 test_deps_installed failures
(comtypes/mss ModuleNotFoundError) pre-exist on main — Windows-only deps not
installed in this env. Contract suite unchanged: 8 failed (truthful red), 30 passed,
0 skipped. Harness: 19 green.

Phase 1.0 harness complete:
  - All 9 T1.* tests executable (acceptance criterion #1)
  - Real StaleRefResolver + fake snapshots (A1, criterion #3)
  - H1 pure monkeypatch, no production seam (criterion #4)
  - Two-clause falsifiable invariant (poison + target-identity; criterion #5-6)
  - Synthetic __test_* capabilities, full runtime path (A2, criterion #11)
  - T1.6 policy-forced pc vs T1.9 irreversible, not merged (A3, criterion #12)

The 8 reds are the Phase 1.1/1.2 work target (production lease/floor/postcondition
wiring). Branch phase1.0/drift-harness ready for Phase 1.1.

Signed-off-by: Alajmah <55954113+Alajmah@users.noreply.github.com>
… plan

Phase 1.0 reviewer-accepted (ChatGPT msg 73). Persist the completion record and
the Phase 1.1 handoff into the impl plan so it survives outside the chat thread
(now at ~74 messages, near the lifecycle ceiling).

- §6 completion record: 8 failed/30 passed/0 skipped truthful red, the two
  failure patterns (BLOCK poison escapes; EXECUTE receipt deficits).
- §7 Phase 1.1 handoff: branch-handling preference, the 1.1a-1.1e order, the
  TargetLease/LeaseCheckResult object shapes, the separately-testable floor
  evaluator, T1.9's stay-separate invariant, and the fresh-thread opener.

Signed-off-by: Alajmah <55954113+Alajmah@users.noreply.github.com>
…le CI

Per reviewer guidance (ChatGPT msg 73): the 8 T1.* lease/floor/postcondition
tests are intentionally RED — they encode the Phase 1.1/1.2 work target and
must not fail CI on main. xfail(strict=True) makes them:
  - run every commit (catching harness regressions);
  - mergeable (CI green);
  - self-correcting: if Phase 1.1/1.2 wiring accidentally makes one pass, strict
    xfail flips it to a FAILURE, forcing an explicit marker removal.

Suite: 11 passed, 8 xfailed (was 8 failed, 30 passed). T1.5/T1.8/T1.10 stay
green (Phase 0 deliverables, not marked). The 8: T1.1, T1.2, T1.3a, T1.3b,
T1.4, T1.6, T1.7, T1.9.

Signed-off-by: Alajmah <55954113+Alajmah@users.noreply.github.com>
@Alajmah
Alajmah force-pushed the phase1.0/drift-harness branch from e026a14 to b01780f Compare July 2, 2026 23:58

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e026a143f3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +151 to +155
"target": {"type": "string", "description": "Element to type into (required for lease binding)"},
"text": {"type": "string", "description": "Text string to type"},
"delay_ms": {"type": "number", "default": 30, "description": "Delay between keystrokes in milliseconds"},
},
"required": ["text"],
"required": ["target", "text"],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep text-only type_text calls valid

This new required target rejects existing non-dry type_text entry points that only provide text: the CLI builds AgentGoal(capability="type_text", params={"text": text}) in src/deskaoy/cli/main.py, and compact MCP maps computer/type the same way in src/deskaoy/transport/mcp_server.py. In those contexts the request now fails validation before reaching adapters, even though the adapter protocol and platform adapters type into the current focus with type_text(text, ...); please keep target optional until dispatch actually supports/binds it.

Useful? React with 👍 / 👎.

"num_clicks": {"type": "integer", "minimum": 1, "maximum": 3, "default": 1},
},
"required": ["target"],
"required": [],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Translate coordinate clicks before dispatch

With target no longer required, a caller following the new schema can send {"x": 100, "y": 200} and validate_action("click", ...) returns valid, but _execute_single_action dispatches those params directly as adapter_method(**params). The real SurfaceAdapter.click implementations require the positional target: str, so coordinate-only clicks now raise a TypeError instead of clicking; either convert x/y into the existing "x,y" target form before dispatch or keep target required.

Useful? React with 👍 / 👎.

cap_specs.append(ParameterSpec(
name=param_name,
type=py_type,
required=param_name in required_list,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve required params when deriving specs

Deriving required solely from CAPABILITIES weakens validation for existing actions whose metadata still says required: []: key_press and scroll now accept {} as valid, while the adapter protocol and src/deskaoy/validation.py require key and direction. In those contexts _execute_single_action proceeds to adapter_method(**{}), producing a runtime TypeError instead of the previous validation error; please carry forward the legacy required overrides or update CAPABILITIES before generating specs.

Useful? React with 👍 / 👎.

These two tests were missed when Phase 0.2 (confidence cap) and Phase 0.5
(schema unification) landed, and were failing on main. Caught by Phase 1.0 PR CI.

1. test_os_contract.py::test_grounding_confidence_used — expected the adapter's
   visual_confidence=0.72 to pass through unchanged. Phase 0.2 made confidence a
   four-factor min(); with no lease evidence, verification_scope='none' caps it
   at 0.30 (contract §4). Updated to assert the capped score, the
   verification_scope binding factor, and that adapter_confidence is still
   recorded (just no longer binding).

2. test_universal_interface.py::test_tools_list_uses_real_schemas — expected
   click.button enum [left, right, double]. Phase 0.5 corrected it to
   [left, right, middle] ('double' was click-count, not a button). Updated.

Both are one-line corrections aligned with already-merged contract changes;
no behavior change.

Signed-off-by: Alajmah <55954113+Alajmah@users.noreply.github.com>
@Alajmah Alajmah changed the title Phase 1.0: drift-injection harness for the execution-integrity contract (reviewer + owner accepted) Phase 0 (execution-integrity surgery) + Phase 1.0 (drift harness) — combined landing Jul 8, 2026
@gitwire-hq

gitwire-hq Bot commented Sep 3, 2026

Copy link
Copy Markdown

⏰ GitWire Stale Warning

This issue has had no activity for 56 days.
It will be automatically closed in 4 days if no further activity occurs.

To keep it open, leave a comment or push an update.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant