From 4be1ed2fdb75f95aeb75b0812e219217242466fb Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:12:19 +0100 Subject: [PATCH 01/28] test(mvp): qualify live human dashboard and agent API before and after real workload recreation --- scripts/ci/qualify-mvp-windows-workloads.sh | 56 +++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/scripts/ci/qualify-mvp-windows-workloads.sh b/scripts/ci/qualify-mvp-windows-workloads.sh index 1a9c721a..37583453 100644 --- a/scripts/ci/qualify-mvp-windows-workloads.sh +++ b/scripts/ci/qualify-mvp-windows-workloads.sh @@ -69,7 +69,62 @@ wait_health() { done return 1 } +# Live HTTP delivery across the actual runtime boundary, without TestClient. +# Fixed local destination, bounded reads, no redirects, no raw output. +verify_live_interfaces() { + python3 - <<'PY' +import json +import os +import urllib.error +import urllib.request + +class NoRedirect(urllib.request.HTTPRedirectHandler): + def redirect_request(self, *args, **kwargs): + return None + +opener = urllib.request.build_opener( + urllib.request.ProxyHandler({}), NoRedirect() +) +token = os.environ["WINEBOT_API_TOKEN"] +def request(path, authenticated=True): + headers = {"X-API-Key": token} if authenticated else {} + req = urllib.request.Request("http://127.0.0.1:8000" + path, headers=headers) + with opener.open(req, timeout=15) as response: + data = response.read(2 * 1024 * 1024 + 1) + assert len(data) <= 2 * 1024 * 1024 + return data, response.headers + +try: + try: + request("/handshake", False) + except urllib.error.HTTPError as err: + assert err.code == 401 + else: + raise AssertionError("missing authentication refusal") + _, health_headers = request("/health") + raw, headers = request("/handshake") + handshake = json.loads(raw) + version = json.loads(request("/version")[0]) + assert handshake["status"] == "ready" + assert handshake["api_version"] == version["api_version"] + assert handshake["build_version"] == version["version"] + assert handshake["schema_versions"]["artifact"] == version["artifact_schema_version"] + assert handshake["schema_versions"]["event"] == version["event_schema_version"] + assert headers["X-WineBot-API-Version"] == handshake["api_version"] + assert headers["X-Request-ID"] and health_headers["X-Request-ID"] + assert isinstance(handshake["capabilities"], list) and handshake["capabilities"] + html, ui_headers = request("/ui/", False) + assert ui_headers.get_content_type() == "text/html" + assert b"WineBot Dashboard" in html + assert "no-store" in ui_headers.get("Cache-Control", "") +except Exception: + raise SystemExit("MVP_LIVE_INTERFACE=FAIL") +print("MVP_LIVE_INTERFACE=PASS") +PY +} + wait_health || fail health_initial +verify_live_interfaces || fail live_interface_initial docker compose -f compose/layered.yml exec -T winebot-interactive wine --version \ 2>/dev/null | grep -Eq '^wine-11([.]|$)' || fail wrong_wine_version echo 'MVP_WORKLOAD stage=wine11_layered_ready' @@ -224,6 +279,7 @@ echo 'MVP_WORKLOAD stage=quiesced_before_recreate' docker compose -f compose/layered.yml up -d --force-recreate --no-build \ winebot-interactive >/dev/null 2>&1 || fail recreate wait_health || fail recreate_health +verify_live_interfaces || fail live_interface_after_recreate docker compose -f compose/layered.yml exec -T winebot-interactive /bin/bash -euo pipefail -c ' grep -q IC1-APP-INPUT-PROOF /userdata/ic1-editor.txt || { echo "MVP_WORKLOAD_REPLAY_CAUSE=editor_data_missing"; exit 40; } From d9731c5b5dfcae5331879966f3ba5dcc670666ae Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:14:17 +0100 Subject: [PATCH 02/28] integration: preserve original qualified observation contract --- rdte/re-observation-contract/README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 rdte/re-observation-contract/README.md diff --git a/rdte/re-observation-contract/README.md b/rdte/re-observation-contract/README.md new file mode 100644 index 00000000..7d4d03be --- /dev/null +++ b/rdte/re-observation-contract/README.md @@ -0,0 +1,21 @@ +# Cross-provider reverse-engineering observation metadata v1 + +An independent, public synthetic-only Go stdlib **adapter contract candidate**, not a new control plane, actual security attestor, runtime database, or Observatory critic replacement. + +Strict, tiny flat JSON metadata envelope for WineBot Win32 self-enumeration, WinBot native NT queries (phnt) and Windows ETW (TraceEvent). It deliberately reports origin=synthetic_fixture, trust=UNVERIFIED and coverage=partial even when the source or run pointer is present. A claimed Git commit SHA is only a self-declared field; it MUST be checked against the authoritative run and exact commit externally. This v0 CANNOT label evidence production LIVE/VERIFIED or represent an app-private semantic type, stable object ID or allocation generation. + +Addresses are allowed only from Win32 API observations and then only in a Windows guest process virtual address space. ETW and native-NT probe variants currently emit no pointers; the actual NT query can privately read a PEB but the v0 observation must not confuse a kernel/host pointer with guest VA. No raw memory, target paths, strings, buffer contents or user values are accepted by the schema. + +Negative suite tests 3 allowed provider types, source/backend mismatches, fabricated semantic types, invalid address spaces, fake trust claims, bad provenance, duplicate keys, unexpected fields and size limits. No original target or sensitive/private fixture. + +Future integration is only through the authorized WineBot/WinBot sensor owners and Ghidra/Observatory consumer, subject to exact source/run readback and the reversing workbench's R030/R126 H0/source/held-out gates. No public research result overrides private DLE, no automatic Ghidra source changes, no profile publication. The important output is an approved source of truth for what UNKNOWN still means. + +## Exact-source one-sensor batch qualification + +The v1 schema explicitly requires allocation extents for Win32 API records, so pre-v1 envelopes are rejected (draft research contract: no production consumer migration). The optional `ValidateOneSensorBatch` helper checks an **independently supplied source commit** against every individual synthetic observation; it rejects mixed process IDs, mixed sensors/backends, duplicate event kinds, unknown fields and unbounded record counts. It does **not** join native NT, ETW and Wine observations into one causal session. Different providers require an independently authenticated correlation/experiment ID and actual producer receipts before their identities can be reconciled. A matching 40-character SHA is not proof that GitHub emitted the record or that the underlying run was real. + +The offline negative tests deliberately attempt cross-sensor mixing, PID mixing, duplicate kinds, source-head mismatch, corrupt records, and oversize batches. Native/WinBot and Ghidra adapters remain separately gated. + +## Pinned Wine 11 typed current-state bridge + +`NormalizeWine11CurrentStateWitness` accepts the exact synthetic PE64 three-record query produced in the **pinned source-built Wine 11.0** control. It checks a bounded no-duplicates schema, three records in source order, same process, non-overflowing addresses, memory-region containment, and unobserved application semantics. It retains address **and size** in the metadata-only cross-provider observation contract, with `source_commit` supplied by the owning exact-source runner and `trust=UNVERIFIED`. A string-shaped source commit is **not** attestation; the caller must independently bind the run receipt to that Git commit. Negative tests explicitly refuse forged Wine-owned provenance, private type claims, duplicate fields, mixed PIDs, invalid address spaces and disjoint regions. No live target or private data is used in public CI. The full Ghidra/Observatory consumer remains under ghidra-tools#4 admission. From 11db4e5b1ec9943f1bb2a18152a1f6d0d0526ef8 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:14:20 +0100 Subject: [PATCH 03/28] integration: preserve original qualified observation contract --- rdte/re-observation-contract/batch.go | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 rdte/re-observation-contract/batch.go diff --git a/rdte/re-observation-contract/batch.go b/rdte/re-observation-contract/batch.go new file mode 100644 index 00000000..36f50e64 --- /dev/null +++ b/rdte/re-observation-contract/batch.go @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: MIT +package evidence + +import "errors" + +// ValidateOneSensorBatch binds a synthetic evidence batch to the independently +// supplied exact-source commit. A self-declared record SHA is not attestation. +// Different sensors/OS processes cannot be joined without a separate verified +// session correlation contract. This helper therefore rejects mixed providers. +func ValidateOneSensorBatch(records [][]byte, expectedCommit string) error { + if !commitSHA.MatchString(expectedCommit) { + return errors.New("invalid_expected_source") + } + if len(records) < 1 || len(records) > 16 { + return errors.New("invalid_batch_size") + } + var original Observation + seen := make(map[string]bool) + for index, raw := range records { + one, err := Validate(raw) + if err != nil { + return errors.New("invalid_batch_record") + } + if one.SourceCommit != expectedCommit { + return errors.New("source_head_mismatch") + } + if index == 0 { + original = one + } else if one.Backend != original.Backend || + one.Sensor != original.Sensor || + one.ProcessID != original.ProcessID { + return errors.New("mixed_process_or_sensor") + } + if seen[one.Kind] { + return errors.New("duplicate_kind") + } + seen[one.Kind] = true + } + // An invented digest or a same-process guess does not prove a real + // acquisition. Caller must independently verify Git ref and workflow run. + return nil +} From 35c2327482d2c8fc3c0ef59802698fc5cafdd8ed Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:14:22 +0100 Subject: [PATCH 04/28] integration: preserve original qualified observation contract --- rdte/re-observation-contract/batch_test.go | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 rdte/re-observation-contract/batch_test.go diff --git a/rdte/re-observation-contract/batch_test.go b/rdte/re-observation-contract/batch_test.go new file mode 100644 index 00000000..7a3052b2 --- /dev/null +++ b/rdte/re-observation-contract/batch_test.go @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: MIT +package evidence + +import ( + "encoding/json" + "strings" + "testing" +) + +func encodeTestRecord(t *testing.T, o Observation) []byte { + t.Helper() + data, err := json.Marshal(o) + if err != nil { + t.Fatal(err) + } + return data +} + +func TestOneSensorBatchValid(t *testing.T) { + for _, sensor := range []string{"phnt", "traceevent", "win32_api"} { + a := fixture(sensor) + recs := [][]byte{encodeTestRecord(t, a)} + if sensor == "phnt" { + b := a + b.Kind = "nt_process" + recs = append(recs, encodeTestRecord(t, b)) + } + if sensor == "win32_api" { + b := a + b.Kind = "memory_region" + recs = append(recs, encodeTestRecord(t, b)) + } + if err := ValidateOneSensorBatch(recs, strings.Repeat("a", 40)); err != nil { + t.Fatalf("valid %s: %v", sensor, err) + } + } +} + +func TestBatchRejectsFalseCorrelations(t *testing.T) { + a := fixture("win32_api") + b := a + b.Kind = "module" + good := encodeTestRecord(t, a) + other := encodeTestRecord(t, b) + bad := map[string][][]byte{ + "empty": {}, + "duplicate_kind": {good, good}, + "mixed_sensors": {good, encodeTestRecord(t, fixture("phnt"))}, + "bad_record": {good, []byte("{}")}, + "too_many": make([][]byte, 17), + } + for i := range bad["too_many"] { + bad["too_many"][i] = good + } + b.ProcessID = 45 + bad["mixed_process"] = [][]byte{good, encodeTestRecord(t, b)} + for name, input := range bad { + t.Run(name, func(t *testing.T) { + if err := ValidateOneSensorBatch(input, strings.Repeat("a", 40)); err == nil { + t.Fatal("accepted unsupported mixed batch") + } + }) + } + if err := ValidateOneSensorBatch([][]byte{good, other}, strings.Repeat("b", 40)); err == nil { + t.Fatal("accepted mismatched exact source") + } + if err := ValidateOneSensorBatch([][]byte{good}, "unverified"); err == nil { + t.Fatal("accepted invalid externally supplied digest") + } +} From ada3d728d2b46c0c532cb97475bc310dfe2c4fba Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:14:24 +0100 Subject: [PATCH 05/28] integration: preserve original qualified observation contract --- rdte/re-observation-contract/observation.go | 87 +++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 rdte/re-observation-contract/observation.go diff --git a/rdte/re-observation-contract/observation.go b/rdte/re-observation-contract/observation.go new file mode 100644 index 00000000..5886e048 --- /dev/null +++ b/rdte/re-observation-contract/observation.go @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: MIT +// Research observation metadata only, not an execution controller or private critic. +package evidence +import ("bytes";"encoding/json";"errors";"io";"regexp";"strconv") +const Schema="winebot.research.observation/v1" +var hexAddress=regexp.MustCompile("^0x[0-9a-f]{1,16}$") +var commitSHA=regexp.MustCompile("^[0-9a-f]{40}$") +type Observation struct { + Schema string `json:"schema"` + Backend string `json:"backend"` + Sensor string `json:"sensor"` + Kind string `json:"kind"` + Origin string `json:"origin"` + ProcessID uint64 `json:"process_id"` + AddressSpace string `json:"address_space"` + Address *string `json:"address"` + SizeBytes *uint64 `json:"size_bytes"` + SemanticType *string `json:"semantic_type"` + ObjectID *string `json:"object_id"` + Generation *uint64 `json:"generation"` + Coverage string `json:"coverage"` + SourceCommit string `json:"source_commit"` + Trust string `json:"trust"` +} +var fields=map[string]bool{ + "schema":true,"backend":true,"sensor":true,"kind":true, + "origin":true,"process_id":true,"address_space":true,"address":true, + "size_bytes":true, + "semantic_type":true,"object_id":true,"generation":true, + "coverage":true,"source_commit":true,"trust":true, +} +func Validate(raw []byte) (Observation,error) { + var out Observation + if len(raw)==0 || len(raw)>4096 {return out,errors.New("bad_record_size")} + dec:=json.NewDecoder(bytes.NewReader(raw)) + first,err:=dec.Token() + if err!=nil || first!=json.Delim('{'){return out,errors.New("not_object")} + seen:=map[string]bool{} + for dec.More(){ + tok,err:=dec.Token() + if err!=nil{return out,errors.New("bad_key")} + key,ok:=tok.(string) + if !ok || !fields[key] || seen[key]{return out,errors.New("bad_or_duplicate_key")} + seen[key]=true + var v json.RawMessage + if err:=dec.Decode(&v);err!=nil{return out,errors.New("bad_value")} + } + end,err:=dec.Token() + if err!=nil || end!=json.Delim('}') || len(seen)!=len(fields){ + return out,errors.New("incomplete_record") + } + if tok,err:=dec.Token();err!=io.EOF || tok!=nil{ + return out,errors.New("extra_json") + } + if err:=json.Unmarshal(raw,&out);err!=nil{return out,errors.New("bad_type")} + if out.Schema!=Schema || out.Origin!="synthetic_fixture" || + out.Coverage!="partial" || out.Trust!="UNVERIFIED" || out.ProcessID==0 || + !commitSHA.MatchString(out.SourceCommit){ + return out,errors.New("invalid_provenance") + } + if out.SemanticType!=nil || out.ObjectID!=nil || out.Generation!=nil{ + return out,errors.New("unproven_object_semantics") + } + ok:=false + switch out.Sensor { + case "win32_api": + ok=(out.Backend=="wine" || out.Backend=="windows") && + (out.Kind=="module" || out.Kind=="heap_allocation" || out.Kind=="memory_region") + case "phnt": + ok=out.Backend=="windows" && (out.Kind=="nt_process" || out.Kind=="nt_handle") + case "traceevent": + ok=out.Backend=="windows" && out.Kind=="etw_transition" + } + if !ok{return out,errors.New("unsupported_provider_kind")} + if out.Sensor=="win32_api"{ + if out.AddressSpace!="windows_process_va" || out.Address==nil || + !hexAddress.MatchString(*out.Address){return out,errors.New("wrong_address_domain")} + n,err:=strconv.ParseUint((*out.Address)[2:],16,64) + if err!=nil || n==0{return out,errors.New("bad_address")} + if out.SizeBytes==nil || *out.SizeBytes==0 || n>^uint64(0)-*out.SizeBytes { + return out,errors.New("bad_allocation_extent") + } + }else if out.AddressSpace!="none" || out.Address!=nil || out.SizeBytes!=nil{ + return out,errors.New("wrong_address_domain") + } + return out,nil +} From 10452292a29304c1c17d7bf445a12d5ffc8c92ad Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:14:27 +0100 Subject: [PATCH 06/28] integration: preserve original qualified observation contract --- .../observation_test.go | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 rdte/re-observation-contract/observation_test.go diff --git a/rdte/re-observation-contract/observation_test.go b/rdte/re-observation-contract/observation_test.go new file mode 100644 index 00000000..d6bf1865 --- /dev/null +++ b/rdte/re-observation-contract/observation_test.go @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: MIT +package evidence +import ("encoding/json";"strings";"testing") +func str(s string)*string{return &s} +func sizePtr(n uint64)*uint64{return &n} +func fixture(sensor string) Observation{ + o:=Observation{ + Schema:Schema,Backend:"windows",Sensor:sensor,Kind:"nt_handle", + Origin:"synthetic_fixture",ProcessID:44,AddressSpace:"none", + Coverage:"partial",SourceCommit:strings.Repeat("a",40),Trust:"UNVERIFIED", + } + if sensor=="traceevent"{o.Kind="etw_transition"} + if sensor=="win32_api"{o.Backend="wine";o.Kind="heap_allocation";o.AddressSpace="windows_process_va";o.Address=str("0x200040");o.SizeBytes=sizePtr(256)} + return o +} +func TestSupportedSyntheticSources(t *testing.T){ + for _,src:=range []string{"win32_api","phnt","traceevent"}{ + o:=fixture(src) + b,_:=json.Marshal(o) + if _,err:=Validate(b);err!=nil{t.Errorf("%s rejected: %v",src,err)} + } +} +func TestRejectFabricatedEvidence(t *testing.T){ + base:=fixture("win32_api") + modifications:=map[string]func(*Observation){ + "private target":func(o *Observation){o.Origin="private_target"}, + "claimed verification":func(o *Observation){o.Trust="VERIFIED"}, + "type inference":func(o *Observation){o.SemanticType=str("Player")}, + "object identity":func(o *Observation){o.ObjectID=str("known")}, + "address domain":func(o *Observation){o.AddressSpace="wine_server_host_va"}, + "lost address":func(o *Observation){o.Address=nil}, + "bad address":func(o *Observation){o.Address=str("0x0")}, + "size missing":func(o *Observation){o.SizeBytes=nil}, + "size zero":func(o *Observation){o.SizeBytes=sizePtr(0)}, + "size overflow":func(o *Observation){o.Address=str("0xfffffffffffffff0");o.SizeBytes=sizePtr(100)}, + "wrong backend":func(o *Observation){o.Backend="other"}, + "empty sha":func(o *Observation){o.SourceCommit=""}, + "wrong coverage":func(o *Observation){o.Coverage="complete"}, + "legacy v0":func(o *Observation){o.Schema="winebot.research.observation/v0"}, + "zero process":func(o *Observation){o.ProcessID=0}, + "wrong kind":func(o *Observation){o.Kind="etw_transition"}, + "bad sensor":func(o *Observation){o.Sensor="static_tool"}, + } + for name,change:=range modifications{ + t.Run(name,func(t *testing.T){ + o:=base + change(&o) + b,_:=json.Marshal(o) + if _,err:=Validate(b);err==nil{t.Fatal("accepted unproven observation")} + }) + } + for name,raw:=range map[string]string{ + "duplicate":`{"schema":"x","schema":"winebot.research.observation/v0"}`, + "extra":`{"raw_memory":"secret"}`, + "missing":"{}", + "trailing":"{}{}", + "oversize":strings.Repeat("x",5000), + }{ + t.Run(name,func(t *testing.T){if _,err:=Validate([]byte(raw));err==nil{t.Fatal("accepted malformed input")}}) + } +} From e273b5bcb0e9bcd30dea95f7d5b9fa80cbff956a Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:14:29 +0100 Subject: [PATCH 07/28] integration: preserve original qualified observation contract --- rdte/re-observation-contract/wine11_bridge.go | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 rdte/re-observation-contract/wine11_bridge.go diff --git a/rdte/re-observation-contract/wine11_bridge.go b/rdte/re-observation-contract/wine11_bridge.go new file mode 100644 index 00000000..48b601a5 --- /dev/null +++ b/rdte/re-observation-contract/wine11_bridge.go @@ -0,0 +1,122 @@ +// SPDX-License-Identifier: MIT +// Strict bridge from source-Wine11's original synthetic current-state witness. +package evidence + +import ( + "bytes" + "encoding/json" + "errors" + "io" + "strconv" +) + +const wine11WitnessSchema = "wine-introspection-rdte/v0" +type wine11Witness struct { + Schema string `json:"schema"` + Source string `json:"source"` + Kind string `json:"kind"` + ProcessID uint64 `json:"process_id"` + AddressSpace string `json:"address_space"` + Address string `json:"address"` + SizeBytes uint64 `json:"size_bytes"` + ObjectID *string `json:"object_id"` + Generation *uint64 `json:"generation"` + SemanticType *string `json:"semantic_type"` + Snapshot string `json:"snapshot"` + Coverage string `json:"coverage"` +} + +var wine11WitnessKeys = map[string]bool{ + "schema":true,"source":true,"kind":true,"process_id":true, + "address_space":true,"address":true,"size_bytes":true, + "object_id":true,"generation":true,"semantic_type":true, + "snapshot":true,"coverage":true, +} + +func decodeWine11Witness(data []byte) (wine11Witness,error) { + var out wine11Witness + if len(data)==0 || len(data)>4096 {return out,errors.New("bad_wine11_record_size")} + dec:=json.NewDecoder(bytes.NewReader(data)) + start,err:=dec.Token() + if err!=nil || start!=json.Delim('{') {return out,errors.New("bad_wine11_object")} + seen:=map[string]bool{} + for dec.More() { + token,err:=dec.Token() + if err!=nil {return out,errors.New("bad_wine11_key")} + key,ok:=token.(string) + if !ok || !wine11WitnessKeys[key] || seen[key] { + return out,errors.New("bad_or_duplicate_wine11_key") + } + seen[key]=true + var raw json.RawMessage + if err:=dec.Decode(&raw);err!=nil{return out,errors.New("bad_wine11_value")} + } + end,err:=dec.Token() + if err!=nil || end!=json.Delim('}') || len(seen)!=len(wine11WitnessKeys) { + return out,errors.New("incomplete_wine11_record") + } + if token,err:=dec.Token();err!=io.EOF || token!=nil { + return out,errors.New("trailing_wine11_json") + } + if err:=json.Unmarshal(data,&out);err!=nil{return out,errors.New("wine11_field_type")} + if out.Schema!=wine11WitnessSchema || out.Source!="WIN32_API_ENUMERATED" || + out.AddressSpace!="windows_process_va" || out.Snapshot!="best_effort" || + out.Coverage!="partial" || out.ProcessID==0 || out.SizeBytes==0 || + out.ObjectID!=nil || out.Generation!=nil || out.SemanticType!=nil || + !hexAddress.MatchString(out.Address) { + return out,errors.New("unproved_wine11_record") + } + base,err:=strconv.ParseUint(out.Address[2:],16,64) + if err!=nil || base==0 || base>^uint64(0)-out.SizeBytes{ + return out,errors.New("invalid_wine11_extent") + } + return out,nil +} + +// NormalizeWine11CurrentStateWitness converts exactly three metadata-only +// synthetic records. The external Git/run SHA must still be verified by the +// owning runner; this function never claims a LIVE or verified source. +func NormalizeWine11CurrentStateWitness(data []byte, expectedCommit string) ([]Observation,error) { + if !commitSHA.MatchString(expectedCommit) || len(data)==0 || len(data)>12288 { + return nil,errors.New("invalid_source_or_witness_size") + } + raw:=bytes.TrimSuffix(data,[]byte("\n")) + lines:=bytes.Split(raw,[]byte("\n")) + if len(lines)!=3 {return nil,errors.New("invalid_record_count")} + ordered:=[3]string{"module","heap_allocation","memory_region"} + var items [3]wine11Witness + records:=make([]Observation,0,3) + serialized:=make([][]byte,0,3) + for i,line:=range lines { + one,err:=decodeWine11Witness(bytes.TrimSuffix(line,[]byte("\r"))) + if err!=nil || one.Kind!=ordered[i] {return nil,errors.New("invalid_record_or_order")} + if i>0 && one.ProcessID!=items[0].ProcessID {return nil,errors.New("mixed_wine11_pid")} + items[i]=one + address:=one.Address + size:=one.SizeBytes + value:=Observation{ + Schema:Schema,Backend:"wine",Sensor:"win32_api", + Kind:one.Kind,Origin:"synthetic_fixture",ProcessID:one.ProcessID, + AddressSpace:"windows_process_va",Address:&address,SizeBytes:&size, + Coverage:"partial",SourceCommit:expectedCommit,Trust:"UNVERIFIED", + } + encoded,err:=json.Marshal(value) + if err!=nil{return nil,errors.New("cannot_normalize_wine11")} + records=append(records,value) + serialized=append(serialized,encoded) + } + module,heap,region:=items[0],items[1],items[2] + if module.SizeBytes<4096 || heap.SizeBytes<256 || region.SizeBytes=region.SizeBytes || + heap.SizeBytes>region.SizeBytes-(heapBase-regionBase) { + return nil,errors.New("wine11_heap_outside_region") + } + if err:=ValidateOneSensorBatch(serialized,expectedCommit);err!=nil { + return nil,errors.New("wine11_normalized_batch_invalid") + } + return records,nil +} From bc2e08d43e2e5e24b3c603fd22b7b28bf6d31e2c Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:14:32 +0100 Subject: [PATCH 08/28] integration: preserve original qualified observation contract --- .../wine11_bridge_test.go | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 rdte/re-observation-contract/wine11_bridge_test.go diff --git a/rdte/re-observation-contract/wine11_bridge_test.go b/rdte/re-observation-contract/wine11_bridge_test.go new file mode 100644 index 00000000..bebe9d01 --- /dev/null +++ b/rdte/re-observation-contract/wine11_bridge_test.go @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: MIT +package evidence + +import ( + "encoding/json" + "fmt" + "strings" + "testing" +) + +func syntheticWine11Row(kind,address string, size,pid uint64) string { + return fmt.Sprintf( + "{\"schema\":\"wine-introspection-rdte/v0\",\"source\":\"WIN32_API_ENUMERATED\",\"kind\":%q,\"process_id\":%d,\"address_space\":\"windows_process_va\",\"address\":%q,\"size_bytes\":%d,\"object_id\":null,\"generation\":null,\"semantic_type\":null,\"snapshot\":\"best_effort\",\"coverage\":\"partial\"}", + kind,pid,address,size, + ) +} +func validWine11Witness() string { + return syntheticWine11Row("module","0x140000000",8192,42)+"\n"+ + syntheticWine11Row("heap_allocation","0x200040",256,42)+"\n"+ + syntheticWine11Row("memory_region","0x200000",4096,42)+"\n" +} +func TestNormalizeWine11CurrentState(t *testing.T) { + sha:=strings.Repeat("a",40) + items,err:=NormalizeWine11CurrentStateWitness([]byte(validWine11Witness()),sha) + if err!=nil || len(items)!=3 {t.Fatalf("valid synthetic witness rejected: %v",err)} + if items[1].SizeBytes==nil || *items[1].SizeBytes!=256 || + items[1].Trust!="UNVERIFIED" || items[1].SemanticType!=nil || + items[1].SourceCommit!=sha {t.Fatal("incorrect normalized provenance or allocation size")} + for _,item:=range items { + raw,err:=json.Marshal(item) + if err!=nil {t.Fatal(err)} + if _,err:=Validate(raw);err!=nil {t.Fatalf("normalized item refused: %v",err)} + } +} +func TestWine11NormalizerRefusesUnprovedEvidence(t *testing.T) { + good:=validWine11Witness() + tests:=map[string]string{ + "wrong_source":strings.Replace(good,"WIN32_API_ENUMERATED","WINE_OWNED",1), + "wrong_schema":strings.Replace(good,"wine-introspection-rdte/v0","wine-introspection-rdte/v7",1), + "invented_type":strings.Replace(good,"\"semantic_type\":null","\"semantic_type\":\"Player\"",1), + "fabricated_id":strings.Replace(good,"\"object_id\":null","\"object_id\":\"object-1\"",1), + "wrong_address_domain":strings.Replace(good,"windows_process_va","wine_server_host_va",1), + "extra_field":strings.Replace(good,"\"snapshot\":\"best_effort\"","\"unknown\":\"sensitive\",\"snapshot\":\"best_effort\"",1), + "duplicate_kind_key":strings.Replace(good,"\"kind\":\"module\"","\"kind\":\"module\",\"kind\":\"module\"",1), + "cross_process":strings.Replace(good,"\"process_id\":42","\"process_id\":43",1), + "disjoint_region":strings.Replace(good,"\"address\":\"0x200000\"","\"address\":\"0x800000\"",1), + "overflow":strings.Replace(good,"\"address\":\"0x200040\"","\"address\":\"0xfffffffffffffff0\"",1), + "missing":strings.Join(strings.Split(good,"\n")[:2],"\n"), + "extra_record":good+syntheticWine11Row("module","0x140000000",8192,42)+"\n", + "blank":"", + "oversized":strings.Repeat("a",13000), + } + for name,source:=range tests { + t.Run(name,func(t *testing.T){ + if _,err:=NormalizeWine11CurrentStateWitness([]byte(source),strings.Repeat("a",40));err==nil{ + t.Fatal("invalid synthetic Wine11 witness accepted") + } + }) + } + if _,err:=NormalizeWine11CurrentStateWitness([]byte(good),"unverified");err==nil { + t.Fatal("unqualified external source accepted") + } +} From 3b10cfd20c79116b05b1639544509f217795e906 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:14:37 +0100 Subject: [PATCH 09/28] integration: preserve exact Wine11 lifetime evidence consumer --- rdte/wine11-heap-trace/verify.go | 75 ++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 rdte/wine11-heap-trace/verify.go diff --git a/rdte/wine11-heap-trace/verify.go b/rdte/wine11-heap-trace/verify.go new file mode 100644 index 00000000..a6a7af72 --- /dev/null +++ b/rdte/wine11-heap-trace/verify.go @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: MIT +// Strict synthetic-only verifier for Wine 11.0's existing +heap trace channel. +package heaptrace + +import ( + "bufio" + "errors" + "io" + "regexp" + "strconv" + "strings" +) + +const maxTraceBytes int64 = 8 << 20 +const maxTraceLine = 16 << 10 + +// These format patterns are grounded in Wine 11.0 dlls/ntdll/heap.c +// RtlAllocateHeap and RtlFreeHeap TRACE calls. They are intentionally narrow. +var ( + allocEvent = regexp.MustCompile(`trace:heap:RtlAllocateHeap handle ([0-9a-fA-Fx]+), flags ([0-9a-fA-Fx]+), size ([0-9a-fA-Fx]+), return ([0-9a-fA-Fx]+), status ([0-9a-fA-Fx]+)\.`) + freeEvent = regexp.MustCompile(`trace:heap:RtlFreeHeap handle ([0-9a-fA-Fx]+), flags ([0-9a-fA-Fx]+), ptr ([0-9a-fA-Fx]+), return ([01]), status ([0-9a-fA-Fx]+)\.`) +) + +func hexNum(v string) (uint64, error) { + v = strings.TrimPrefix(strings.ToLower(v), "0x") + if v == "" { return 0,errors.New("invalid_trace_hex") } + return strconv.ParseUint(v, 16, 64) +} + +// VerifySyntheticLifetime proves only that an exact allocation/free sequence for +// one source-known synthetic pointer and size exists in an externally isolated +// Wine 11 trace stream. It does not establish process identity, application +// object type, global allocation history, complete tracing, or no observer effect. +func VerifySyntheticLifetime(r io.Reader, expectedPointer string, expectedSize uint64) error { + target,err:=hexNum(expectedPointer) + if err!=nil || target==0 || expectedSize==0 || target>^uint64(0)-expectedSize { + return errors.New("invalid_synthetic_target") + } + limited:=&io.LimitedReader{R:r,N:maxTraceBytes+1} + scanner:=bufio.NewScanner(limited) + scanner.Buffer(make([]byte,4096),maxTraceLine) + seenAlloc:=false + seenFree:=false + var targetHeap uint64 + for scanner.Scan() { + line:=scanner.Text() + if m:=allocEvent.FindStringSubmatch(line);m!=nil { + addr,e1:=hexNum(m[4]) + size,e2:=hexNum(m[3]) + if e1!=nil || e2!=nil { return errors.New("bad_allocation_event") } + if addr!=target {continue} + status,e3:=hexNum(m[5]) + handle,e4:=hexNum(m[1]) + if e3!=nil || e4!=nil || status!=0 || size!=expectedSize || seenAlloc { + return errors.New("contradictory_allocation_event") + } + seenAlloc=true + targetHeap=handle + } else if m:=freeEvent.FindStringSubmatch(line);m!=nil { + addr,e1:=hexNum(m[3]) + if e1!=nil {return errors.New("bad_free_event")} + if addr!=target {continue} + status,e2:=hexNum(m[5]) + handle,e3:=hexNum(m[1]) + if e2!=nil || e3!=nil || !seenAlloc || seenFree || + handle!=targetHeap || m[4]!="1" || status!=0 { + return errors.New("contradictory_free_event") + } + seenFree=true + } + } + if scanner.Err()!=nil || limited.N==0 {return errors.New("trace_lost_or_overbudget")} + if !seenAlloc || !seenFree {return errors.New("incomplete_synthetic_lifetime")} + return nil +} From a3d4efa2416a8629fdda76b6caaa2bc06323d81d Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:14:40 +0100 Subject: [PATCH 10/28] integration: preserve exact Wine11 lifetime evidence consumer --- rdte/wine11-heap-trace/verify_test.go | 50 +++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 rdte/wine11-heap-trace/verify_test.go diff --git a/rdte/wine11-heap-trace/verify_test.go b/rdte/wine11-heap-trace/verify_test.go new file mode 100644 index 00000000..f65d8d73 --- /dev/null +++ b/rdte/wine11-heap-trace/verify_test.go @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: MIT +package heaptrace + +import ( + "strings" + "testing" +) + +const allocLine = "0034:trace:heap:RtlAllocateHeap handle 0xabc, flags 0, size 0x100, return 0x200040, status 0.\n" +const freeLine = "0034:trace:heap:RtlFreeHeap handle 0xabc, flags 0, ptr 0x200040, return 1, status 0.\n" + +func TestWine11SyntheticLifetime(t *testing.T) { + trace:="unrelated:WineLoader starts\n"+allocLine+ + "0034:trace:heap:RtlAllocateHeap handle 0xdef, flags 0, size 0x20, return 0x300040, status 0.\n"+ + freeLine + if err:=VerifySyntheticLifetime(strings.NewReader(trace),"0x200040",256);err!=nil { + t.Fatal(err) + } +} + +func TestWine11FailClosed(t *testing.T) { + testCases:=map[string]string{ + "missing_free":allocLine, + "missing_allocate":freeLine, + "wrong_order":freeLine+allocLine, + "duplicate_allocation":allocLine+allocLine+freeLine, + "duplicate_free":allocLine+freeLine+freeLine, + "wrong_heap":allocLine+"0034:trace:heap:RtlFreeHeap handle 0xdef, flags 0, ptr 0x200040, return 1, status 0.\n", + "wrong_status":strings.Replace(allocLine,"status 0.","status 0xc0000017.",1)+freeLine, + "failed_free":allocLine+strings.Replace(freeLine,"return 1, status 0.","return 0, status 0xc000000d.",1), + "wrong_size":strings.Replace(allocLine,"size 0x100","size 0x80",1)+freeLine, + "no_heap_trace":strings.Replace(allocLine,"trace:heap:","trace:other:",1)+freeLine, + "nonsense":"garbage", + "overbudget":allocLine+strings.Repeat("A",int(maxTraceBytes))+freeLine, + "line_too_big":allocLine+strings.Repeat("A",maxTraceLine+1)+"\n"+freeLine, + } + for name,data:=range testCases { + t.Run(name,func(t *testing.T){ + if err:=VerifySyntheticLifetime(strings.NewReader(data),"0x200040",256);err==nil{ + t.Fatal("accepted incomplete or contradictory Wine11 trace") + } + }) + } + if err:=VerifySyntheticLifetime(strings.NewReader(allocLine+freeLine),"invalid",256);err==nil { + t.Fatal("accepted malformed target") + } + if err:=VerifySyntheticLifetime(strings.NewReader(allocLine+freeLine),"0x200040",0);err==nil { + t.Fatal("accepted missing size") + } +} From 041dc2d26685d66b4de459892a7ef80b2c7b456e Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:14:42 +0100 Subject: [PATCH 11/28] integration: preserve exact Wine11 lifetime evidence consumer --- rdte/re-lifetime-join/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 rdte/re-lifetime-join/README.md diff --git a/rdte/re-lifetime-join/README.md b/rdte/re-lifetime-join/README.md new file mode 100644 index 00000000..6da948bf --- /dev/null +++ b/rdte/re-lifetime-join/README.md @@ -0,0 +1,15 @@ +# Synthetic Wine 11 current-state / heap-lifetime join (research-only) + +**Owner:** mark-e-deyoung/winebot-research#3. This is a stacked candidate on source-exact typed evidence WineBot PR #190. The integration branch reuses the **same immutable Git blob SHAs** for the original Go trace parser and negative controls from pinned source-built Wine 11 research PR #197, rather than creating a forked parser. + +Offline run (Go standard library, no dependencies): + + GO111MODULE=off go test -race -count=1 ./rdte/re-observation-contract ./rdte/wine11-heap-trace ./rdte/re-lifetime-join + +Input #1: strict three-row module / heap allocation / containing memory region Win32 current-state fixture verified by NormalizeWine11CurrentStateWitness. Input #2: bounded filtered Wine 11 heap TRACE stream verified by VerifySyntheticLifetime. Join requires exactly the same allocation pointer and size and a successful allocate-then-free sequence. Negative controls refuse mixed witness process, fabricated app class, invalid source, wrong heap, duplicate/reordered events, wrong extent, malformed record, or resource-budget overflow. + +Output: a fixed metadata-only v1 Receipt. **No pointer, heap handle, PID, raw trace, stack memory, or application object metadata.** Evidence class remains SYNTHETIC_CONSISTENCY_ONLY, trust/source UNVERIFIED, process attribution and trace completeness UNKNOWN, clock correlation UNAVAILABLE, and application semantics UNKNOWN. + +Limits: The same memory pointer in two independently supplied text streams **does not attest common process/generation**, actual Wine 11 source, time order across hosts, event-loss bounds, or reliable first-writer attribution. Git SHA remains externally asserted until independently bound by source/run/fixture custody. The separate live Wine 11 +heap success at PR #197 is not inherited as a proof for this join. This does not implement an API endpoint, production Wine fork, actual WinBot reference comparison, Ghidra/Observatory pipeline, arbitrary target, or authorized debug actuation. + +No private GHA minutes, artifact uploads, images, restricted target bytes, host modifications or main merge. Next integration gate is exact-source/process-generation/clock/loss binding under WineBot/Observatory owners and externally qualified live fixture capture. Keep this workcell draft. \ No newline at end of file From b8cdfe934d6d0966bc44687e048b19679db48049 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:14:45 +0100 Subject: [PATCH 12/28] integration: preserve exact Wine11 lifetime evidence consumer --- rdte/re-lifetime-join/join.go | 73 +++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 rdte/re-lifetime-join/join.go diff --git a/rdte/re-lifetime-join/join.go b/rdte/re-lifetime-join/join.go new file mode 100644 index 00000000..e84d8ac6 --- /dev/null +++ b/rdte/re-lifetime-join/join.go @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: MIT +// Synthetic-only correlation of current-state Win32 and Wine11 +heap evidence. +package rejoin + +import ( + "errors" + "io" + + evidence "../re-observation-contract" + heaptrace "../wine11-heap-trace" +) + +const maxWitnessBytes int64 = 12288 +const ReceiptSchema = "winebot.research.synthetic-lifetime-join/v1" + +// Receipt deliberately contains no address, heap handle, PID, raw trace, +// application-private type, or authenticated process identity. +// A syntactically consistent synthetic trace is NOT proof of provenance. +type Receipt struct { + Schema string `json:"schema"` + Backend string `json:"backend"` + SourceCommit string `json:"source_commit"` + WitnessRecords int `json:"witness_records"` + Join string `json:"join"` + EvidenceClass string `json:"evidence_class"` + SourceAttestation string `json:"source_attestation"` + ProcessAttribution string `json:"process_attribution"` + TraceCompleteness string `json:"trace_completeness"` + ClockCorrelation string `json:"clock_correlation"` + SemanticIdentity string `json:"semantic_identity"` + Trust string `json:"trust"` +} + +// VerifySyntheticLifetimeJoin checks three strict current-state records AND +// one exact synthetic allocation->free trace of the same pointer and extent. +// Both input parsers retain their own budgets and adversarial controls. +// It never promotes synthetic consistency to LIVE or VERIFIED provenance. +// Caller must independently bind source SHA, fixture, runner and process. +func VerifySyntheticLifetimeJoin(witness, trace io.Reader, claimedSourceCommit string) (Receipt, error) { + var empty Receipt + if witness == nil || trace == nil { + return empty, errors.New("missing_synthetic_inputs") + } + payload, err := io.ReadAll(io.LimitReader(witness, maxWitnessBytes+1)) + if err != nil || len(payload) == 0 || int64(len(payload)) > maxWitnessBytes { + return empty, errors.New("invalid_bounded_wine11_witness") + } + records, err := evidence.NormalizeWine11CurrentStateWitness(payload, claimedSourceCommit) + if err != nil || len(records) != 3 { + return empty, errors.New("invalid_synthetic_current_state") + } + heap := records[1] + if heap.Kind != "heap_allocation" || heap.Address == nil || heap.SizeBytes == nil { + return empty, errors.New("missing_heap_allocation") + } + if err := heaptrace.VerifySyntheticLifetime(trace, *heap.Address, *heap.SizeBytes); err != nil { + return empty, errors.New("invalid_synthetic_heap_lifetime") + } + return Receipt{ + Schema: ReceiptSchema, + Backend: "wine", + SourceCommit: claimedSourceCommit, + WitnessRecords: len(records), + Join: "same_pointer_and_extent_alloc_then_free", + EvidenceClass: "SYNTHETIC_CONSISTENCY_ONLY", + SourceAttestation: "UNVERIFIED", + ProcessAttribution: "UNKNOWN", + TraceCompleteness: "UNKNOWN", + ClockCorrelation: "UNAVAILABLE", + SemanticIdentity: "UNKNOWN", + Trust: "UNVERIFIED", + }, nil +} From cab5069b8086dc66b2dfd252182d034f9e6b5b51 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:14:48 +0100 Subject: [PATCH 13/28] integration: preserve exact Wine11 lifetime evidence consumer --- rdte/re-lifetime-join/join_test.go | 95 ++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 rdte/re-lifetime-join/join_test.go diff --git a/rdte/re-lifetime-join/join_test.go b/rdte/re-lifetime-join/join_test.go new file mode 100644 index 00000000..c86e96a8 --- /dev/null +++ b/rdte/re-lifetime-join/join_test.go @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: MIT +package rejoin + +import ( + "encoding/json" + "fmt" + "strings" + "testing" +) + +const syntheticSHA = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + +func witnessRow(kind, address string, size, pid uint64) string { + return fmt.Sprintf( + "{\"schema\":\"wine-introspection-rdte/v0\",\"source\":\"WIN32_API_ENUMERATED\",\"kind\":%q,\"process_id\":%d,\"address_space\":\"windows_process_va\",\"address\":%q,\"size_bytes\":%d,\"object_id\":null,\"generation\":null,\"semantic_type\":null,\"snapshot\":\"best_effort\",\"coverage\":\"partial\"}", + kind, pid, address, size, + ) +} + +func validWitness() string { + return witnessRow("module", "0x140000000", 8192, 42) + "\n" + + witnessRow("heap_allocation", "0x200040", 256, 42) + "\n" + + witnessRow("memory_region", "0x200000", 4096, 42) + "\n" +} + +const alloc = "0034:trace:heap:RtlAllocateHeap handle 0xabc, flags 0, size 0x100, return 0x200040, status 0.\n" +const release = "0034:trace:heap:RtlFreeHeap handle 0xabc, flags 0, ptr 0x200040, return 1, status 0.\n" + +func TestJoinedSyntheticWine11Evidence(t *testing.T) { + got, err := VerifySyntheticLifetimeJoin(strings.NewReader(validWitness()), strings.NewReader(alloc+release), syntheticSHA) + if err != nil { + t.Fatalf("original bounded fixture rejected: %v", err) + } + if got.Schema != ReceiptSchema || got.WitnessRecords != 3 || + got.EvidenceClass != "SYNTHETIC_CONSISTENCY_ONLY" || + got.Trust != "UNVERIFIED" || got.SourceAttestation != "UNVERIFIED" || + got.ProcessAttribution != "UNKNOWN" || got.TraceCompleteness != "UNKNOWN" || + got.SemanticIdentity != "UNKNOWN" || got.ClockCorrelation != "UNAVAILABLE" { + t.Fatal("joined result made an unsupported assurance or omitted required uncertainty") + } + encoded, err := json.Marshal(got) + if err != nil { + t.Fatal(err) + } + for _, forbidden := range []string{"0x200040", "0xabc", "process_id", "semantic_type", "\"trust\":\"VERIFIED\""} { + if strings.Contains(string(encoded), forbidden) { + t.Fatal("receipt exposes raw witness or fabricates a verified live claim") + } + } +} + +func TestJoinRefusesContradictoryInputs(t *testing.T) { + good := validWitness() + cases := map[string]struct { + witness string + trace string + commit string + }{ + "missing_free": {good, alloc, syntheticSHA}, + "free_before_alloc": {good, release+alloc, syntheticSHA}, + "wrong_trace_size": {good, strings.Replace(alloc, "size 0x100", "size 0x80", 1)+release, syntheticSHA}, + "wrong_trace_pointer": {good, strings.Replace(alloc, "return 0x200040", "return 0x300040", 1)+release, syntheticSHA}, + "wrong_heap_handle": {good, alloc+strings.Replace(release, "handle 0xabc", "handle 0xdef", 1), syntheticSHA}, + "duplicate_alloc": {good, alloc+alloc+release, syntheticSHA}, + "duplicate_free": {good, alloc+release+release, syntheticSHA}, + "failed_free": {good, alloc+strings.Replace(release, "return 1", "return 0", 1), syntheticSHA}, + "mixed_witness_pid": {strings.Replace(good, "\"process_id\":42", "\"process_id\":43", 1), alloc+release, syntheticSHA}, + "fabricated_type": {strings.Replace(good, "\"semantic_type\":null", "\"semantic_type\":\"Widget\"", 1), alloc+release, syntheticSHA}, + "bad_address_domain": {strings.Replace(good, "windows_process_va", "wineserver_host_va", 1), alloc+release, syntheticSHA}, + "duplicate_json_key": {strings.Replace(good, "\"kind\":\"module\"", "\"kind\":\"module\",\"kind\":\"module\"", 1), alloc+release, syntheticSHA}, + "bad_region": {strings.Replace(good, "\"address\":\"0x200000\"", "\"address\":\"0x800000\"", 1), alloc+release, syntheticSHA}, + "oversize_witness": {strings.Repeat("x", int(maxWitnessBytes)+1), alloc+release, syntheticSHA}, + "oversize_trace": {good, alloc+strings.Repeat("A", 8<<20)+release, syntheticSHA}, + "bad_commit": {good, alloc+release, "not-a-source-ref"}, + "empty_witness": {"", alloc+release, syntheticSHA}, + "empty_trace": {good, "", syntheticSHA}, + } + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + receipt, err := VerifySyntheticLifetimeJoin(strings.NewReader(tc.witness), strings.NewReader(tc.trace), tc.commit) + if err == nil || receipt.Schema != "" { + t.Fatal("invalid synthetic join accepted or retained a partial receipt") + } + if strings.Contains(err.Error(), "0x200040") || strings.Contains(err.Error(), "0xabc") { + t.Fatal("error leaked raw fixture memory addresses") + } + }) + } + if _, err := VerifySyntheticLifetimeJoin(nil, strings.NewReader(alloc+release), syntheticSHA); err == nil { + t.Fatal("nil witness accepted") + } + if _, err := VerifySyntheticLifetimeJoin(strings.NewReader(validWitness()), nil, syntheticSHA); err == nil { + t.Fatal("nil trace accepted") + } +} From d426e079c3a71353e340e6b99dc7e1b3497357b2 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:14:50 +0100 Subject: [PATCH 14/28] integration: preserve exact Wine11 lifetime evidence consumer --- rdte/re-lifetime-join/join_live_test.go | 49 +++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 rdte/re-lifetime-join/join_live_test.go diff --git a/rdte/re-lifetime-join/join_live_test.go b/rdte/re-lifetime-join/join_live_test.go new file mode 100644 index 00000000..9539b381 --- /dev/null +++ b/rdte/re-lifetime-join/join_live_test.go @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: MIT +package rejoin + +import ( + "os" + "testing" +) + +const pinnedSourceWine11Fixture = "858121cb3cb2bbf2196869b8befef302efd143dd" + +// This test runs only when the exact Wine11 source-builder checkout has +// produced ephemeral evidence. It never echoes raw addresses or trace text. +// A source SHA literal is still not independent runtime provenance attestation. +func TestPinnedWine11RuntimeJoin(t *testing.T) { + witnessPath := os.Getenv("WINE11_JOIN_WITNESS") + tracePath := os.Getenv("WINE11_JOIN_TRACE") + if witnessPath == "" && tracePath == "" { + t.Skip("source Wine11 runtime input not provided") + } + if witnessPath == "" || tracePath == "" { + t.Fatal("incomplete synthetic Wine11 stream inputs") + } + witness, err := os.Open(witnessPath) + if err != nil { + t.Fatal("unavailable bounded synthetic Wine11 witness") + } + defer witness.Close() + trace, err := os.Open(tracePath) + if err != nil { + t.Fatal("unavailable bounded synthetic Wine11 heap trace") + } + defer trace.Close() + + result, err := VerifySyntheticLifetimeJoin(witness, trace, pinnedSourceWine11Fixture) + if err != nil { + t.Fatal("actual synthetic Wine11 witness/heap join refused") + } + if result.Schema != ReceiptSchema || + result.SourceCommit != pinnedSourceWine11Fixture || + result.WitnessRecords != 3 || + result.EvidenceClass != "SYNTHETIC_CONSISTENCY_ONLY" || + result.Trust != "UNVERIFIED" || + result.ProcessAttribution != "UNKNOWN" || + result.TraceCompleteness != "UNKNOWN" || + result.ClockCorrelation != "UNAVAILABLE" || + result.SemanticIdentity != "UNKNOWN" { + t.Fatal("unsupported provenance or semantic claim") + } +} From 2987818e568186462f076a804499a52ce9dca627 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:15:00 +0100 Subject: [PATCH 15/28] feat(observability): expose qualified evidence join as read-only receipt CLI --- rdte/re-observation-cli/main.go | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 rdte/re-observation-cli/main.go diff --git a/rdte/re-observation-cli/main.go b/rdte/re-observation-cli/main.go new file mode 100644 index 00000000..ed648a4b --- /dev/null +++ b/rdte/re-observation-cli/main.go @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: MIT +// Read-only local CLI for the synthetic Wine 11 evidence join. +package main + +import ( + "encoding/json" + "flag" + "fmt" + "io" + "os" + + rejoin "../re-lifetime-join" +) + +func run(args []string, out io.Writer) int { + flags := flag.NewFlagSet("winebot-observation", flag.ContinueOnError) + flags.SetOutput(io.Discard) + witnessPath := flags.String("witness", "", "local synthetic current-state JSONL") + tracePath := flags.String("trace", "", "local filtered synthetic heap trace") + source := flags.String("source-commit", "", "externally asserted source commit") + if flags.Parse(args) != nil || flags.NArg() != 0 || *witnessPath == "" || *tracePath == "" || *source == "" { + return 2 + } + // Refuse nonregular inputs before opening. This CLI is for trusted local + // fixture directories, not hostile paths or a remotely exposed service. + open := func(path string) (*os.File, error) { + st, err := os.Lstat(path) + if err != nil || !st.Mode().IsRegular() { + return nil, fmt.Errorf("invalid local fixture") + } + return os.Open(path) + } + witness, err := open(*witnessPath) + if err != nil { return 1 } + defer witness.Close() + trace, err := open(*tracePath) + if err != nil { return 1 } + defer trace.Close() + receipt, err := rejoin.VerifySyntheticLifetimeJoin(witness, trace, *source) + if err != nil { return 1 } + if json.NewEncoder(out).Encode(receipt) != nil { return 1 } + return 0 +} + +func main() { + code := run(os.Args[1:], os.Stdout) + if code != 0 { fmt.Fprintln(os.Stderr, "WINEBOT_OBSERVATION=REFUSED") } + os.Exit(code) +} From ba383dfd2e5004b87adf04a497b2c9b97f8a44fb Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:15:11 +0100 Subject: [PATCH 16/28] test(observability): exercise actual receipt CLI and refusal behavior --- rdte/re-observation-cli/qualify.py | 72 ++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 rdte/re-observation-cli/qualify.py diff --git a/rdte/re-observation-cli/qualify.py b/rdte/re-observation-cli/qualify.py new file mode 100644 index 00000000..badd9a88 --- /dev/null +++ b/rdte/re-observation-cli/qualify.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +"""Run the actual compiled receipt CLI on original synthetic fixtures.""" +import json +import os +import pathlib +import subprocess +import sys +import tempfile + +source = "a" * 40 +rows = [ + ("module", "0x140000000", 8192), + ("heap_allocation", "0x200040", 256), + ("memory_region", "0x200000", 4096), +] +alloc = "0034:trace:heap:RtlAllocateHeap handle 0xabc, flags 0, size 0x100, return 0x200040, status 0.\n" +release = "0034:trace:heap:RtlFreeHeap handle 0xabc, flags 0, ptr 0x200040, return 1, status 0.\n" + +def main(): + binary = sys.argv[1] + with tempfile.TemporaryDirectory() as work: + witness = pathlib.Path(work, "witness.jsonl") + trace = pathlib.Path(work, "filtered.heap") + witness.write_text("".join(json.dumps({ + "schema": "wine-introspection-rdte/v0", + "source": "WIN32_API_ENUMERATED", + "kind": kind, "process_id": 42, + "address_space": "windows_process_va", + "address": address, "size_bytes": size, + "object_id": None, "generation": None, + "semantic_type": None, "snapshot": "best_effort", + "coverage": "partial", + }) + "\n" for kind, address, size in rows), encoding="utf-8") + trace.write_text(alloc + release, encoding="utf-8") + args = [binary, "-witness", str(witness), "-trace", str(trace), "-source-commit", source] + def invoke(argv): + return subprocess.run(argv, capture_output=True, text=True, timeout=5, check=False) + result = invoke(args) + assert result.returncode == 0 and not result.stderr + receipt = json.loads(result.stdout) + assert receipt["schema"] == "winebot.research.synthetic-lifetime-join/v1" + assert receipt["source_commit"] == source and receipt["witness_records"] == 3 + for key, value in { + "evidence_class": "SYNTHETIC_CONSISTENCY_ONLY", "trust": "UNVERIFIED", + "source_attestation": "UNVERIFIED", "process_attribution": "UNKNOWN", + "trace_completeness": "UNKNOWN", "clock_correlation": "UNAVAILABLE", + "semantic_identity": "UNKNOWN", + }.items(): + assert receipt[key] == value + for secret in ("0x200040", "0xabc", "process_id", str(witness), str(trace)): + assert secret not in result.stdout + def refuse(argv): + result = invoke(argv) + assert result.returncode != 0 and result.stdout == "" + assert result.stderr.strip() == "WINEBOT_OBSERVATION=REFUSED" + trace.write_text(alloc, encoding="utf-8") + refuse(args) + trace.write_text(alloc + release.replace("0xabc", "0xdef"), encoding="utf-8") + refuse(args) + trace.write_text(alloc + release, encoding="utf-8") + refuse(args[:-1] + ["not-a-source"]) + refuse([binary, "-witness", str(witness)]) + trace.unlink() + os.symlink(witness, trace) + refuse(args) + print("OBSERVATION_CLI=PASS") + +if __name__ == "__main__": + try: + main() + except Exception: + raise SystemExit("OBSERVATION_CLI=FAIL") From 8a9a4f243582d428c5e3a9b8292fc608dec41c07 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:15:17 +0100 Subject: [PATCH 17/28] ci(observability): qualify actual receipt executable without rebuilding Wine --- .../wine11-observation-consumer-rdte.yml | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/wine11-observation-consumer-rdte.yml diff --git a/.github/workflows/wine11-observation-consumer-rdte.yml b/.github/workflows/wine11-observation-consumer-rdte.yml new file mode 100644 index 00000000..0ce6904f --- /dev/null +++ b/.github/workflows/wine11-observation-consumer-rdte.yml @@ -0,0 +1,30 @@ +name: Wine11 Observation Consumer RDTE +on: + pull_request: + paths: + - 'rdte/re-observation-contract/**' + - 'rdte/wine11-heap-trace/**' + - 'rdte/re-lifetime-join/**' + - 'rdte/re-observation-cli/**' + - '.github/workflows/wine11-observation-consumer-rdte.yml' +permissions: + contents: read +jobs: + observation-consumer: + runs-on: ubuntu-24.04 + timeout-minutes: 10 + env: + GO111MODULE: 'off' + GOTOOLCHAIN: local + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd + with: + persist-credentials: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Requalify exact transferred parsers and receipt consumer + run: | + go vet ./rdte/re-observation-contract ./rdte/wine11-heap-trace ./rdte/re-lifetime-join ./rdte/re-observation-cli + go test -race -count=1 ./rdte/re-observation-contract ./rdte/wine11-heap-trace ./rdte/re-lifetime-join + go build -o "$RUNNER_TEMP/winebot-observation" ./rdte/re-observation-cli + - name: Execute actual CLI on bounded synthetic fixtures + run: python3 rdte/re-observation-cli/qualify.py "$RUNNER_TEMP/winebot-observation" From 48c2335b3d21eb1d67c61594f37873a48de5823a Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:15:27 +0100 Subject: [PATCH 18/28] docs(observability): document human automation and agent receipt usage --- rdte/re-observation-cli/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 rdte/re-observation-cli/README.md diff --git a/rdte/re-observation-cli/README.md b/rdte/re-observation-cli/README.md new file mode 100644 index 00000000..110c0759 --- /dev/null +++ b/rdte/re-observation-cli/README.md @@ -0,0 +1,17 @@ +# WineBot observation receipt command (synthetic RDTE) + +A local, read-only command for the already qualified Wine 11 synthetic current-state / heap lifetime join. It imports the original parser libraries without modifications. + +Build from this repository: + + GO111MODULE=off go build -o winebot-observation ./rdte/re-observation-cli + +Run against an independently authorized, local synthetic fixture directory: + + ./winebot-observation -witness witness.jsonl -trace filtered.heap -source-commit + +Exit 0 emits a single metadata-only JSON receipt on stdout. Exit 1 refuses invalid input or an unavailable file; exit 2 refuses invalid usage. Failures emit a fixed category only, with no raw addresses, paths, memory or traces. No network service or automatic runtime actions. Do not use adversarial filesystem locations or real user captures; the tool is not a sandbox. + +Human: inspect the receipt or use jq. Automation: check exit status and the schema before consuming JSON. Agent: use the same schema and treat UNVERIFIED/UNKNOWN/UNAVAILABLE as explicit limitations, not successful authentication or missing work to hallucinate. + +Actual historical producer qualification: WineBot PR #206 exact fe2ac64de5e00bb9879ff26555b547bcf87da6f7, public run 45174475488, actual source-built Wine 11 synthetic join PASS. Its unrelated broad conformance failure is retained. This integration transfers libraries into the #181 MVP lineage, requalifies the offline command and does not rerun the source compile. No inference of source attestation, real application semantics, continuous event coverage, cross-process causality, or production acceptance. Native WinBot comparison and Observatory ingestion remain separately qualified tasks. From 7fe1d035965adb341541b9ae7e2bd4a7f1a938e0 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 14:40:35 +0100 Subject: [PATCH 19/28] R059: refuse unresolved xdotool target --- api/routers/input.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/api/routers/input.py b/api/routers/input.py index d17f7eb3..85e46f33 100644 --- a/api/routers/input.py +++ b/api/routers/input.py @@ -224,6 +224,15 @@ async def _send_keys( effective_backend = "xdotool" if _desktop_absent() else "ahk" if effective_backend == "xdotool": + # A supplied but unresolved title must never silently become + # unscoped XTEST input to the currently focused application. + if window_title and not window_id: + return { + "ok": False, + "backend": "xdotool", + "error": "xdotool_target_unresolved", + "stderr": "", + } cmd = ["xdotool"] if window_id: cmd.extend(["key", "--window", window_id, keys]) From 218328441f7f5b621e22723bb19859aef85dfa1c Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 14:40:37 +0100 Subject: [PATCH 20/28] R059: qualify target refusal and delivery distinction --- tests/test_input_keyboard_conformance.py | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/test_input_keyboard_conformance.py b/tests/test_input_keyboard_conformance.py index 219594d3..99b60191 100644 --- a/tests/test_input_keyboard_conformance.py +++ b/tests/test_input_keyboard_conformance.py @@ -302,3 +302,36 @@ def test_ahk_special_escaped(self): assert "{^}" in _xdotool_to_ahk_keys("^") assert "{!}" in _xdotool_to_ahk_keys("!") assert "{#}" in _xdotool_to_ahk_keys("#") + + + +@pytest.mark.parametrize("backend", ["xdotool", "auto"]) +def test_unresolved_xdotool_title_never_dispatches_to_focus(backend): + """A requested target that did not resolve is not permission for global input.""" + import asyncio + from api.routers.input import _send_keys + + with patch("api.routers.input._desktop_absent", return_value=True), patch( + "api.routers.input.run_async_command" + ) as command: + result = asyncio.run(_send_keys("z", None, "missing", backend, "/tmp", 2)) + assert result["ok"] is False + assert result["error"] == "xdotool_target_unresolved" + command.assert_not_called() + + +@pytest.mark.parametrize("window_id,expected", [ + (None, ["xdotool", "key", "z"]), + ("12345", ["xdotool", "key", "--window", "12345", "z"]), +]) +def test_xdotool_delivery_mode_not_silently_changed(window_id, expected): + import asyncio + from api.routers.input import _send_keys + + with patch("api.routers.input.run_async_command") as command: + command.return_value = {"ok": True} + result = asyncio.run( + _send_keys("z", window_id, None, "xdotool", "/tmp", 2) + ) + assert result["ok"] is True + command.assert_awaited_once_with(expected, timeout=2) From 1de39f0336f4220750641f8ff8e1827dfc9dd380 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 14:40:39 +0100 Subject: [PATCH 21/28] R059: measure directed vs focused keyboard postcondition --- .../ci/qualify-mvp-broker-real-keyboard.py | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/scripts/ci/qualify-mvp-broker-real-keyboard.py b/scripts/ci/qualify-mvp-broker-real-keyboard.py index 61fe9131..af4ec8f6 100644 --- a/scripts/ci/qualify-mvp-broker-real-keyboard.py +++ b/scripts/ci/qualify-mvp-broker-real-keyboard.py @@ -56,6 +56,8 @@ def main() -> None: if active.returncode: fail("real_window_focus") + original_text = PROOF.read_text() + with ExitStack() as stack: stack.enter_context(patch.dict(os.environ, { "API_TOKEN": HEADER["X-API-Key"], @@ -81,12 +83,33 @@ def main() -> None: # Use the same in-process route harness as the proven HTTP unit tests. # Entering TestClient lifespan would mutate unrelated real service state. client = TestClient(app) - def key(keys: str): - return client.post( - "/input/key", - json={"keys": keys, "window_id": window, "backend": "xdotool"}, - headers=HEADER, - ) + def key(keys: str, *, targeted: bool = True): + payload = {"keys": keys, "backend": "xdotool"} + if targeted: + payload["window_id"] = window + return client.post("/input/key", json=payload, headers=HEADER) + + def focused_differential() -> str: + # Diagnostic only: same real broker and editor, different X11 + # delivery primitive. Never waive the original targeted failure. + # This is an isolated disposable desktop; focus checks are not an + # atomic target-binding guarantee for a shared production desktop. + for chord in ("ctrl+End", "y", "ctrl+s"): + observed = subprocess.run( + ["xdotool", "getactivewindow"], capture_output=True, + text=True, timeout=5, check=False, + ) + if observed.returncode or observed.stdout.strip() != window: + return "focused_xtest_focus_mismatch" + if key(chord, targeted=False).status_code != 200: + return "focused_xtest_dispatch_failed" + deadline = time.monotonic() + 15 + while time.monotonic() < deadline: + # z may have been inserted but not saved by directed delivery. + if PROOF.read_text() in (original_text + "y", original_text + "zy"): + return "focused_xtest_pass" + time.sleep(0.25) + return "focused_xtest_save_failed" if key("z").status_code != 423: fail("unguarded_input") @@ -115,6 +138,11 @@ def key(keys: str): break time.sleep(0.25) else: + try: + outcome = focused_differential() + except Exception: + outcome = "focused_xtest_probe_error" + print("IC1_BROKER_DIFFERENTIAL=" + outcome, flush=True) fail("real_wine_save_postcondition") stopped = client.post( "/sessions/ic1-broker-live/user_intent", From 9f40d4a26f0cea1190406104aad43ec2aa495408 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 14:40:42 +0100 Subject: [PATCH 22/28] R059: retain fixed differential failure receipt --- scripts/ci/qualify-mvp-windows-workloads.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/ci/qualify-mvp-windows-workloads.sh b/scripts/ci/qualify-mvp-windows-workloads.sh index 37583453..2e8b3cc1 100644 --- a/scripts/ci/qualify-mvp-windows-workloads.sh +++ b/scripts/ci/qualify-mvp-windows-workloads.sh @@ -185,6 +185,10 @@ docker compose -f compose/layered.yml exec -T \ IC1_BROKER_CAUSE=*) printf '%s\n' "$cause" ;; *) echo 'IC1_BROKER_CAUSE=unclassified' ;; esac + differential="$(grep -Eo 'IC1_BROKER_DIFFERENTIAL=(focused_xtest_pass|focused_xtest_focus_mismatch|focused_xtest_dispatch_failed|focused_xtest_save_failed|focused_xtest_probe_error)' "$RUNNER_TEMP/ic1-broker-local.log" | tail -1 || true)" + case "$differential" in + IC1_BROKER_DIFFERENTIAL=*) printf '%s\n' "$differential" ;; + esac fail broker_real_keyboard } grep -Fq 'IC1_BROKER=real_wine_keyboard_and_stop_pass' "$RUNNER_TEMP/ic1-broker-local.log" || fail broker_receipt_missing From ecc88c52c2adfbddc0d0d2d6739fbf595c7dc8dc Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 14:40:45 +0100 Subject: [PATCH 23/28] R059: replace deprecated coreutils no-clobber flag --- .github/workflows/mvp-ic1-windows-workloads.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mvp-ic1-windows-workloads.yml b/.github/workflows/mvp-ic1-windows-workloads.yml index 80f1cd30..9a41c3c1 100644 --- a/.github/workflows/mvp-ic1-windows-workloads.yml +++ b/.github/workflows/mvp-ic1-windows-workloads.yml @@ -80,7 +80,7 @@ jobs: basedir="$(dirname "$exe")/baseset" mkdir -p "$basedir" find "$work/gfx" -type f \( -iname '*.tar' -o -iname '*.obg' -o -iname '*.grf' \) \ - -exec cp -n '{}' "$basedir" \; + -exec cp --update=none '{}' "$basedir" \; test -n "$(find "$basedir" -type f -print -quit)" || { echo 'MVP_WORKLOAD stage=gfx_missing'; exit 1; } test -z "$(find apps/mvp-ic1 -type l -print -quit)" || From b3e281e85f1a6c57a26401e202bd6af0b3b761ac Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 14:40:47 +0100 Subject: [PATCH 24/28] R059: document dispatch versus application delivery --- docs/api.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/api.md b/docs/api.md index b2d92dd2..161f08d7 100644 --- a/docs/api.md +++ b/docs/api.md @@ -353,6 +353,25 @@ Focus a specific window. - **Body:** `{"window_id": "0x123456"}` - **Response:** `{"status": "focused", "id": "..."}` +#### `POST /input/key` +Send keys through an authenticated, policy-admitted control session. + +- Explicit `backend: "xdotool"` with a resolved `window_id` uses X11 + directed synthetic events (XSendEvent); some applications ignore them. + A successful command/HTTP `status: "sent"` is dispatch acknowledgement, + **not** proof of application receipt or an application state change. +- Without a requested target, xdotool uses the active desktop focus (XTEST). + Use only when the caller intentionally controls the current focus, on an + isolated desktop with no concurrent human input. Verify the focus and an + application-level postcondition; do not automatically retry an ambiguous + dispatch or silently drop a requested target. +- A supplied title that cannot resolve to an X11 window on the xdotool path + fails with `xdotool_target_unresolved`; it must not send keys to the + current focus. The AHK title path remains distinct. +- The Wine 11 directed-key/save acceptance remains a release gate. An + alternate focused-mode result is a differential, not a waiver or proof + of atomic focus binding. Keep X11 window IDs distinct from native HWNDs. + #### `POST /input/mouse/click` Click at specific coordinates. - **Body:** From 51450961db9f979e8d132704161e12b6d18ccde2 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 14:42:38 +0100 Subject: [PATCH 25/28] R059: require exact WinInspect wire handshake and boolean status --- api/core/wininspect.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/api/core/wininspect.py b/api/core/wininspect.py index a09209a1..2c870842 100644 --- a/api/core/wininspect.py +++ b/api/core/wininspect.py @@ -14,6 +14,9 @@ DEFAULT_HOST = "127.0.0.1" DEFAULT_PORT = 1985 +# Wire protocol and product release are independent. Never infer either from +# the other; the actual provider artifact is a separate qualification gate. +WININSPECT_PROTOCOL_VERSION = "0.4.0" DEFAULT_TIMEOUT_SECONDS = 3.0 MAX_MESSAGE_SIZE = 10 * 1024 * 1024 READ_ONLY_METHODS = { @@ -278,6 +281,10 @@ def _write_frame(sock: socket.socket, payload: dict[str, Any]) -> None: def request(method: str, params: dict[str, Any] | None = None) -> dict[str, Any]: if method not in READ_ONLY_METHODS and method not in MUTATION_METHODS: raise WinInspectError(f"WinInspect method is not allowed by WineBot: {method}") + # Deny a caller-supplied protocol override before process or socket effects. + if params is not None and "protocol_version" in params: + if params["protocol_version"] != WININSPECT_PROTOCOL_VERSION: + raise WinInspectError("WinInspect request protocol mismatch") state = ensure_daemon(start=True) if not state.get("running"): raise WinInspectError(str(state.get("error") or "WinInspect daemon is not running")) @@ -287,20 +294,26 @@ def request(method: str, params: dict[str, Any] | None = None) -> dict[str, Any] "id": request_id, "method": method, "params": { - "protocol_version": "0.4.0", **(params or {}), + "protocol_version": WININSPECT_PROTOCOL_VERSION, }, } with socket.create_connection((host(), port()), timeout=timeout_seconds()) as sock: sock.settimeout(timeout_seconds()) hello = _read_frame(sock) + if (hello.get("type") != "hello" + or hello.get("version") != WININSPECT_PROTOCOL_VERSION): + # Do not expose untrusted version/identity data or send RPC bytes. + raise WinInspectError("WinInspect hello protocol mismatch") _write_frame(sock, payload) response = _read_frame(sock) if response.get("id") != request_id: # Never expose untrusted daemon hello identity in API-visible errors. raise WinInspectError("WinInspect response correlation failed") - if not response.get("ok"): + if type(response.get("ok")) is not bool: + raise WinInspectError("WinInspect response status invalid") + if response["ok"] is False: error = response.get("error") or {} if isinstance(error, dict): code = error.get("code") From 8d3daa92e66399154afbc60a1842ec2192af5cf0 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 14:42:41 +0100 Subject: [PATCH 26/28] R059: prove wrong protocol refuses before effects --- tests/test_wininspect_error_redaction.py | 82 +++++++++++++++++++++--- 1 file changed, 74 insertions(+), 8 deletions(-) diff --git a/tests/test_wininspect_error_redaction.py b/tests/test_wininspect_error_redaction.py index 76649b55..9999656b 100644 --- a/tests/test_wininspect_error_redaction.py +++ b/tests/test_wininspect_error_redaction.py @@ -10,13 +10,15 @@ class Socket: - def __init__(self, response): - hello = { - "type": "hello", "version": "0.3.0", - "hostname": "SYNTHETIC_HOST_NEVER_ECHO", - "name": "SYNTHETIC_PERSON_NEVER_ECHO", - "uuid": "SYNTHETIC_UUID_NEVER_ECHO", - } + def __init__(self, response, hello=None): + if hello is None: + hello = { + "type": "hello", "version": "0.4.0", + "hostname": "SYNTHETIC_HOST_NEVER_ECHO", + "name": "SYNTHETIC_PERSON_NEVER_ECHO", + "uuid": "SYNTHETIC_UUID_NEVER_ECHO", + } + self.sent = bytearray() self.incoming = bytearray() for item in (hello, response): raw = json.dumps(item).encode() @@ -31,7 +33,7 @@ def settimeout(self, timeout): pass def sendall(self, value): - pass + self.sent.extend(value) def __enter__(self): return self @@ -57,3 +59,67 @@ def test_mismatched_correlation_refuses_without_hello_disclosure(bad_reply): for token in ("SYNTHETIC_HOST", "SYNTHETIC_PERSON", "SYNTHETIC_UUID", "different-request"): assert token not in str(error.value) + + + +@pytest.mark.parametrize("hello", [ + {}, + {"type": "not-hello", "version": "0.4.0"}, + {"type": "hello", "version": "0.3.0"}, + {"type": "hello", "version": "SYNTHETIC_VERSION_NEVER_ECHO"}, + {"type": "hello", "version": ["0.4.0"]}, + {"type": "hello"}, +]) +def test_wrong_hello_refuses_before_any_rpc(hello): + sock = Socket({}, hello=hello) + with ( + patch.object(wi, "ensure_daemon", return_value={"running": True}), + patch.object(wi.socket, "create_connection", return_value=sock), + ): + with pytest.raises(wi.WinInspectError) as error: + wi.request("daemon.capabilities") + assert str(error.value) == "WinInspect hello protocol mismatch" + assert not sock.sent + + +@pytest.mark.parametrize("version", ["0.3.0", "0.5.0", None, True, ["0.4.0"]]) +def test_protocol_override_refuses_before_process_or_socket(version): + with ( + patch.object(wi, "ensure_daemon") as ensure, + patch.object(wi.socket, "create_connection") as connect, + ): + with pytest.raises(wi.WinInspectError) as error: + wi.request("daemon.capabilities", {"protocol_version": version}) + assert str(error.value) == "WinInspect request protocol mismatch" + ensure.assert_not_called() + connect.assert_not_called() + + +def test_exact_protocol_and_correlation_are_required(): + sock = Socket({"id": "winebot-abc123456789", "ok": True, "result": {}}) + with ( + patch.object(wi, "ensure_daemon", return_value={"running": True}), + patch.object(wi.socket, "create_connection", return_value=sock), + patch.object(wi.uuid, "uuid4") as mock_uuid, + ): + mock_uuid.return_value.hex = "abc1234567890" + result = wi.request("daemon.capabilities", {"protocol_version": "0.4.0"}) + assert result["result"] == {} + size = struct.unpack("!I", sock.sent[:4])[0] + assert size == len(sock.sent) - 4 + request = json.loads(sock.sent[4:]) + assert request["params"]["protocol_version"] == "0.4.0" + + +@pytest.mark.parametrize("status", [None, 0, 1, "true", {}, []]) +def test_non_boolean_reply_status_refuses(status): + sock = Socket({"id": "winebot-abc123456789", "ok": status, "result": {}}) + with ( + patch.object(wi, "ensure_daemon", return_value={"running": True}), + patch.object(wi.socket, "create_connection", return_value=sock), + patch.object(wi.uuid, "uuid4") as mock_uuid, + ): + mock_uuid.return_value.hex = "abc1234567890" + with pytest.raises(wi.WinInspectError) as error: + wi.request("daemon.capabilities") + assert str(error.value) == "WinInspect response status invalid" From 4d101f138febe8f9cf3ef562bdf93bcc46c1a72f Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 14:42:44 +0100 Subject: [PATCH 27/28] R059: align observer test with explicit wire contract --- tests/test_wininspect_observer_contract.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_wininspect_observer_contract.py b/tests/test_wininspect_observer_contract.py index 62a7c2c6..c34a1396 100644 --- a/tests/test_wininspect_observer_contract.py +++ b/tests/test_wininspect_observer_contract.py @@ -119,7 +119,7 @@ def test_malformed_event_envelope_fails_closed(monkeypatch, payload): class Socket: def __init__(self, response): self.data = bytearray() - for message in ({"type": "hello", "name": "NEVER_RETURN_IDENTITY"}, response): + for message in ({"type": "hello", "version": "0.4.0", "name": "NEVER_RETURN_IDENTITY"}, response): raw = json.dumps(message).encode("utf-8") self.data += struct.pack("!I", len(raw)) + raw From 6c2d5a3d1b574c789b60aa969320b6883c7d07b1 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 26 Nov 2026 16:48:18 +0100 Subject: [PATCH 28/28] fix: separate standard-library and WineBot imports in keyboard regression tests --- tests/test_input_keyboard_conformance.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_input_keyboard_conformance.py b/tests/test_input_keyboard_conformance.py index 99b60191..e8ed03af 100644 --- a/tests/test_input_keyboard_conformance.py +++ b/tests/test_input_keyboard_conformance.py @@ -309,6 +309,7 @@ def test_ahk_special_escaped(self): def test_unresolved_xdotool_title_never_dispatches_to_focus(backend): """A requested target that did not resolve is not permission for global input.""" import asyncio + from api.routers.input import _send_keys with patch("api.routers.input._desktop_absent", return_value=True), patch( @@ -326,6 +327,7 @@ def test_unresolved_xdotool_title_never_dispatches_to_focus(backend): ]) def test_xdotool_delivery_mode_not_silently_changed(window_id, expected): import asyncio + from api.routers.input import _send_keys with patch("api.routers.input.run_async_command") as command: