lycheedev 2.0.1 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +39 -29
  2. package/THIRD_PARTY_NOTICES +3 -2
  3. package/native/windows-amd64/lycheedev.exe +0 -0
  4. package/package.json +1 -1
  5. package/payload/addon/Bridge/CaptureWriter.lua +97 -0
  6. package/payload/addon/Bridge/FaultRunner.lua +41 -0
  7. package/payload/addon/Bridge/Identity.lua +1 -1
  8. package/payload/addon/Bridge/ProbeQueue.lua +51 -4
  9. package/payload/addon/Bridge/ProbeRunner.lua +100 -21
  10. package/payload/addon/Bridge/ReceiptView.lua +103 -31
  11. package/payload/addon/Bridge/Reentry.lua +77 -9
  12. package/payload/addon/Bridge/ReportStore.lua +28 -11
  13. package/payload/addon/Bridge/Session.lua +1 -1
  14. package/payload/addon/Core/ClientGate.lua +31 -0
  15. package/payload/addon/Core/Compat.lua +19 -21
  16. package/payload/addon/Core/Controls.lua +58 -9
  17. package/payload/addon/Core/Platform.lua +5 -1
  18. package/payload/addon/Core/Runtime.lua +47 -10
  19. package/payload/addon/{Lychee Dev_Mainline.toc → Lychee Dev.toc } +14 -7
  20. package/payload/addon/Modules/Events/Catalog.lua +5 -1
  21. package/payload/addon/Modules/Events/CatalogData_Forever.lua +1 -1
  22. package/payload/addon/Modules/Events/CatalogData_Mainline.lua +1 -1
  23. package/payload/addon/Modules/Events/CatalogData_Mists.lua +1 -1
  24. package/payload/addon/Modules/Events/CatalogData_Titan.lua +1 -1
  25. package/payload/skill/SKILL.md +52 -4
  26. package/payload/skill/agents/openai.yaml +1 -1
  27. package/payload/skill/references/addon-validation.md +37 -8
  28. package/payload/skill/references/asset-export.md +30 -2
  29. package/payload/skill/references/commands.md +163 -121
  30. package/payload/skill/references/data-investigation.md +52 -14
  31. package/payload/skill/references/error-diagnosis.md +32 -39
  32. package/payload/skill/references/installation.md +6 -0
  33. package/payload/skill/references/live-investigation.md +187 -107
  34. package/payload/skill/references/live-startup.md +88 -0
  35. package/payload/skill/references/source-research.md +29 -11
  36. package/payload/skill/scripts/lycheedev.mjs +10 -0
  37. package/release.json +80 -100
  38. package/payload/addon/Clients/Evergreen.lua +0 -2
  39. package/payload/addon/Clients/Live.lua +0 -2
  40. package/payload/addon/Clients/Pandaria.lua +0 -2
  41. package/payload/addon/Clients/Titan.lua +0 -2
  42. package/payload/addon/Lychee Dev_Forever.toc +0 -52
  43. package/payload/addon/Lychee Dev_Mists.toc +0 -52
  44. package/payload/addon/Lychee Dev_Wrath.toc +0 -52
@@ -1,11 +1,11 @@
1
1
  local ADDON_NAME, ns = ...
2
2
 
3
- local frame, strips, lastBytes, lastReady, lastGeneration, lastScale
3
+ local frame, strips, lastBytes, lastReady, lastGeneration, lastScale, lastRefresh
4
4
  local focusWatch
5
+ local revision = 0
5
6
  local focusEvent = "ChatFrame.OnEditBoxFocusGained"
6
- -- The white receipt card matches the legacy automation notice: anchored to the
7
- -- top-left corner, at most 480 UI units on a side, with module size derived
8
- -- from physical pixels so high-resolution screens do not grow giant symbols.
7
+ -- One optical symbol in the top-left corner. Paired report/readiness proofs
8
+ -- share a transport envelope, not two separately padded QR symbols.
9
9
  local MAX_CARD_UI_SIZE = 480
10
10
  local function restricted(value)
11
11
  return issecretvalue and issecretvalue(value)
@@ -16,10 +16,12 @@ local function stopFocusWatch()
16
16
  if watch then watch.registry:UnregisterCallback(focusEvent, watch) end
17
17
  end
18
18
  local function hide()
19
+ revision = revision + 1
19
20
  stopFocusWatch()
20
21
  if ns.Session and type(ns.Session.CancelInputWait) == "function" then ns.Session.CancelInputWait() end
21
22
  if ns.Identity and type(ns.Identity.CancelWait) == "function" then ns.Identity.CancelWait() end
22
23
  lastBytes, lastReady, lastGeneration, lastScale = nil, nil, nil, nil
24
+ lastRefresh = nil
23
25
  if frame then
24
26
  frame:Hide()
25
27
  frame:UnregisterAllEvents()
@@ -45,31 +47,70 @@ local function payload(value)
45
47
  end
46
48
  -- One visual system for every receipt kind. The generation key only memoizes
47
49
  -- identical redisplays; it is never an identity or an input permission.
48
- -- Module size is max(2, ceil(3 * physical pixel)) UI units, every symbol keeps
49
- -- a 4-module quiet zone, and the whole card is clamped to MAX_CARD_UI_SIZE.
50
+ --
51
+ -- One square symbol and its quiet zone. Module size is fixed in UI units.
52
+ --
53
+ -- It is deliberately NOT derived from the screen: the engines disagree about
54
+ -- what GetScreenHeight means (Retail reports the UIParent height, Classic the
55
+ -- display height), and GetPhysicalScreenSize is unavailable on several clients,
56
+ -- so any ratio built from them either shrinks or inflates the card by a large
57
+ -- factor on the clients that matter. A fixed module makes the card the same
58
+ -- readable size everywhere; the UI scale, not this addon, decides how many
59
+ -- physical pixels that is. The only other bound is the card budget, which keeps
60
+ -- a dense symbol on screen instead of clipping it.
61
+ local TARGET_CARD_MODULES = 2
62
+ local MIN_CARD_MODULES = 2
50
63
  local function cardGeometry(sizes)
51
- local unit = 1
52
- if ns.Compat and type(ns.Compat.GetPhysicalPixelSize) == "function" then
53
- local measured = ns.Compat.GetPhysicalPixelSize()
54
- if not (issecretvalue and issecretvalue(measured)) and type(measured) == "number"
55
- and measured == measured and measured > 0 and measured < math.huge then
56
- unit = measured
57
- end
58
- end
59
64
  local across, tall = 8, 8
60
65
  for index, size in ipairs(sizes) do
61
- across = across + size
62
- if index > 1 then across = across + 8 end
63
- if size + 8 > tall then tall = size + 8 end
66
+ if size + 8 > across then across = size + 8 end
67
+ tall = tall + size
68
+ if index > 1 then tall = tall + 8 end
64
69
  end
65
- local modules = math.max(2, math.ceil(3 * unit))
66
- modules = math.min(modules,
70
+ -- The card budget is a ceiling, not a target: a module that would push a
71
+ -- dense symbol past MAX_CARD_UI_SIZE is reduced, but never below the floor
72
+ -- that keeps the grid readable. A symbol too dense for even the floor is
73
+ -- drawn oversized, because the host reading a clipped grid is exactly the
74
+ -- failure this whole path exists to avoid.
75
+ local modules = math.max(MIN_CARD_MODULES, TARGET_CARD_MODULES)
76
+ local budget = math.min(
67
77
  math.max(1, math.floor(MAX_CARD_UI_SIZE / across)),
68
78
  math.max(1, math.floor(MAX_CARD_UI_SIZE / tall)))
79
+ if budget >= MIN_CARD_MODULES then
80
+ modules = math.min(modules, budget)
81
+ end
69
82
  return modules, across, tall
70
83
  end
71
84
 
72
- local function display(receipt, readiness, generation)
85
+ local display
86
+ -- Focus invalidates pixels, not the pending result. Restore only through a
87
+ -- producer which observes current state; never latch an old inputReady=true.
88
+ local function suspend(refresh, generation)
89
+ hide()
90
+ if type(refresh) ~= "function" then return end
91
+ local expected = revision
92
+ local source = generation == 0 and ns.Identity or ns.Session
93
+ if not source or type(source.WhenInputReady) ~= "function" then return end
94
+ -- Explicit Hide, replacement, opt-out and leaving the world invalidate this
95
+ -- one-shot wait. No frame is allocated until the first displayed receipt.
96
+ frame:RegisterEvent("PLAYER_LEAVING_WORLD")
97
+ frame:RegisterEvent("LOADING_SCREEN_ENABLED")
98
+ frame:SetScript("OnEvent", hide)
99
+ local waiting = source.WhenInputReady(function(ready)
100
+ if revision ~= expected then return end
101
+ if not ready then hide(); return end
102
+ if generation ~= 0 then
103
+ local current = ns.Session.Current()
104
+ if not current or current.generation ~= generation then hide(); return end
105
+ end
106
+ local ok, receipt, readiness, readySignal = pcall(refresh)
107
+ if revision ~= expected then return end
108
+ if not ok or not receipt then hide(); return end
109
+ display(receipt, readiness, generation, refresh, readySignal)
110
+ end)
111
+ if not waiting and revision == expected then hide() end
112
+ end
113
+ display = function(receipt, readiness, generation, refresh, readySignal)
73
114
  local valid, failure = payload(receipt)
74
115
  if not valid then hide(); return nil, failure end
75
116
  if readiness ~= nil then
@@ -85,13 +126,25 @@ local function display(receipt, readiness, generation)
85
126
  if restricted(scale) or type(scale) ~= "number" or scale ~= scale or scale <= 0 or scale == math.huge then
86
127
  hide(); return nil, "receipt_invalid_scale"
87
128
  end
88
- if lastBytes == receipt and lastReady == readiness and lastGeneration == generation and lastScale == scale then return true end
129
+ if lastBytes == receipt and lastReady == readiness and lastGeneration == generation
130
+ and lastScale == scale and lastRefresh == refresh then return true end
131
+ -- A replacement owns the card and its input wait, even with identical
132
+ -- pixels. Cancel the previous producer before installing the new one.
133
+ hide()
89
134
  -- Merge horizontal black runs instead of allocating a texture per cell.
90
- -- Matrix coordinates are [x][y]. Every symbol owns a 4-module quiet zone;
91
- -- both share invalidation and one frame.
135
+ -- Matrix coordinates are [x][y]. Every symbol owns a 4-module quiet zone.
136
+ -- Pairing changes only the optical transport. Producers retain the original
137
+ -- receipt and refresh readiness from current state after focus changes.
138
+ local optical = receipt
139
+ if readiness ~= nil then
140
+ local reason
141
+ optical, reason = ns.CaptureWriter.EncodeReceiptPair(receipt, readySignal)
142
+ if not optical then hide(); return nil, reason end
143
+ end
92
144
  local runs, sizes = {}, {}
93
145
  local origin = 4
94
- for _, bytes in ipairs({receipt, readiness}) do
146
+ local rowOffset = 0
147
+ for _, bytes in ipairs({optical}) do
95
148
  local matrix, reason = ns.MatrixSymbol.Encode(bytes)
96
149
  if not matrix then hide(); return nil, reason end
97
150
  local size = #matrix
@@ -104,13 +157,13 @@ local function display(receipt, readiness, generation)
104
157
  if matrix[x][y] > 0 then
105
158
  local start = x
106
159
  repeat x = x + 1 until x > size or matrix[x][y] <= 0
107
- runs[#runs + 1] = { origin + start, y, x - start }
160
+ runs[#runs + 1] = { origin + start, rowOffset + y, x - start }
108
161
  count = count + 1
109
162
  if count > 8192 then hide(); return nil, "receipt_texture_limit" end
110
163
  else x = x + 1 end
111
164
  end
112
165
  end
113
- origin = origin + size + 8
166
+ rowOffset = rowOffset + size + 8
114
167
  end
115
168
  local modules, across, tall = cardGeometry(sizes)
116
169
  if not frame then create() end
@@ -131,6 +184,7 @@ local function display(receipt, readiness, generation)
131
184
  for index = #runs + 1, #strips do strips[index]:Hide() end
132
185
  frame:SetScript("OnEvent", hide)
133
186
  frame:RegisterEvent("PLAYER_LEAVING_WORLD")
187
+ frame:RegisterEvent("LOADING_SCREEN_ENABLED")
134
188
  frame:RegisterEvent("PLAYER_REGEN_DISABLED")
135
189
  -- Visible receipts are point-in-time observations, not latched input
136
190
  -- permission. Invalidate on known focus/combat changes without polling.
@@ -138,23 +192,41 @@ local function display(receipt, readiness, generation)
138
192
  local watch = { registry = EventRegistry }
139
193
  focusWatch = watch
140
194
  watch.registry:RegisterCallback(focusEvent, function()
141
- if focusWatch == watch then hide() end
195
+ if focusWatch == watch then suspend(refresh, generation) end
142
196
  end, watch)
143
197
  lastBytes, lastReady, lastGeneration, lastScale = receipt, readiness, generation, scale
198
+ lastRefresh = refresh
144
199
  frame:Show()
145
200
  return true
146
201
  end
147
202
 
148
203
  ns.ReceiptView = {
149
204
  Hide = hide,
150
- Show = function(receipt, readiness)
205
+ -- Explicit host dismissal after the displayed receipt's evidence has been
206
+ -- archived. A request-scoped operation in flight owns the display, so
207
+ -- uncertainty fails closed; clearing without a shown card is a no-op.
208
+ Dismiss = function()
209
+ if type(ns.ProbeQueue) == "table" and type(ns.ProbeQueue.Busy) == "function" then
210
+ local busy, reason = ns.ProbeQueue.Busy()
211
+ if busy == nil then return nil, reason end
212
+ if busy then return nil, "receipt_busy" end
213
+ end
214
+ if type(ns.Reentry) == "table" and type(ns.Reentry.Busy) == "function" then
215
+ local busy, reason = ns.Reentry.Busy()
216
+ if busy == nil then return nil, reason end
217
+ if busy then return nil, "receipt_busy" end
218
+ end
219
+ hide()
220
+ return true
221
+ end,
222
+ Show = function(receipt, readiness, refresh, readySignal)
151
223
  local session, failure = ns.Session.Current()
152
224
  if not session then hide(); return nil, failure end
153
- return display(receipt, readiness, session.generation)
225
+ return display(receipt, readiness, session.generation, refresh, readySignal)
154
226
  end,
155
227
  -- Identity markers bind no session. They share the exact display,
156
228
  -- invalidation and focus/combat rules; only the memo key differs.
157
- ShowIdentity = function(receipt)
158
- return display(receipt, nil, 0)
229
+ ShowIdentity = function(receipt, refresh)
230
+ return display(receipt, nil, 0, refresh)
159
231
  end,
160
232
  }
@@ -8,7 +8,8 @@ end
8
8
  local fields = { schema=true, requestId=true, sessionNonce=true, reloadNonce=true,
9
9
  release=true, product=true, build=true, character=true, realm=true, guid=true,
10
10
  runtimeEpoch=true, receipt=true, bodyBytes=true, bodyAdler32=true,
11
- codeSHA256=true, codeAdler32=true, codeBytes=true, cleanupNonce=true, queueReload=true }
11
+ codeSHA256=true, codeAdler32=true, codeBytes=true, cleanupNonce=true, queueReload=true,
12
+ standalone=true, builtin=true }
12
13
  local function valid(ticket)
13
14
  if not plain(ticket) then return false end
14
15
  -- Encoding traverses all values before comparisons, rejecting secrets,
@@ -26,6 +27,19 @@ local function valid(ticket)
26
27
  end
27
28
  if type(ticket.runtimeEpoch)~="number" or ticket.runtimeEpoch<1
28
29
  or ticket.runtimeEpoch>=9007199254740991 or ticket.runtimeEpoch%1~=0 then return false end
30
+ if ticket.standalone~=nil then
31
+ return ticket.standalone==true and ticket.queueReload==nil and ticket.receipt==nil
32
+ and ticket.bodyBytes==nil and ticket.bodyAdler32==nil and ticket.codeSHA256==nil
33
+ and ticket.codeAdler32==nil and ticket.codeBytes==nil and ticket.cleanupNonce==nil
34
+ end
35
+ if ticket.builtin~=nil then
36
+ return ticket.builtin==true and ticket.queueReload==nil and ticket.cleanupNonce==nil
37
+ and type(ticket.receipt)=="string" and #ticket.receipt>0 and #ticket.receipt<=4096
38
+ and type(ticket.bodyBytes)=="number" and ticket.bodyBytes>=1 and ticket.bodyBytes<=512*1024
39
+ and ticket.bodyBytes%1==0 and type(ticket.bodyAdler32)=="string"
40
+ and #ticket.bodyAdler32==8 and string.match(ticket.bodyAdler32,"^[0-9a-f]+$")~=nil
41
+ and ticket.codeSHA256==nil and ticket.codeAdler32==nil and ticket.codeBytes==nil
42
+ end
29
43
  if ticket.queueReload~=nil then
30
44
  return ticket.queueReload==true and ticket.receipt==nil and ticket.bodyBytes==nil
31
45
  and ticket.bodyAdler32==nil and ticket.codeSHA256==nil and ticket.codeAdler32==nil
@@ -51,16 +65,16 @@ local function cancel(discard)
51
65
  and ns.CaptureWriter.Encode(state.reentry,8192)==ownedBytes)) then state.reentry=nil end
52
66
  ownedTicket,ownedRoot,ownedBytes=nil,nil,nil
53
67
  end
54
- local function show(ticket)
68
+ local function receiptFor(ticket)
55
69
  if ticket.cleanupNonce then
56
70
  local receipt,reason=ns.ProbeQueue.VerifyRetired(ticket.requestId,ticket.cleanupNonce)
57
71
  if not receipt then return nil,reason end
58
- return ns.ReceiptView.Show(receipt)
72
+ return receipt
59
73
  end
60
74
  local identity,reason=ns.Session.NextIdentity()
61
75
  if not identity then return nil,reason end
62
76
  local ready=ns.Platform.ObserveInputState()==true
63
- local receipt,failure=ns.CaptureWriter.Encode({
77
+ local receipt,failure=ns.CaptureWriter.EncodeSignal({
64
78
  schema="lycheedev.signal.v1",kind="ready",release=ns.Release,
65
79
  sessionNonce=identity.sessionNonce,requestId=ticket.requestId,reloadNonce=ticket.reloadNonce,
66
80
  character=identity.character,realm=identity.realm,guid=identity.guid,
@@ -68,7 +82,12 @@ local function show(ticket)
68
82
  sequence=identity.sequence,runtimeEpoch=identity.runtimeEpoch,inputReady=ready,
69
83
  },2048)
70
84
  if not receipt then return nil,failure end
71
- return ns.ReceiptView.Show(receipt)
85
+ return receipt
86
+ end
87
+ local function show(ticket)
88
+ local receipt, failure=receiptFor(ticket)
89
+ if not receipt then return nil,failure end
90
+ return ns.ReceiptView.Show(receipt,nil,function() return receiptFor(ticket) end)
72
91
  end
73
92
  local function submit(state,ticket)
74
93
  if not valid(ticket) then return nil,"reload_invalid_ticket" end
@@ -94,6 +113,42 @@ ns.Reentry={
94
113
  if restricted(state.reentry) then return nil,"reload_invalid_ticket" end
95
114
  return state.reentry~=nil
96
115
  end,
116
+ Refresh=function(reloadNonce)
117
+ if submitted then return nil,"reload_already_submitted" end
118
+ if type(reloadNonce)~="string" or #reloadNonce~=32 or not string.match(reloadNonce,"^[0-9a-f]+$") then
119
+ return nil,"reload_invalid_nonce"
120
+ end
121
+ local session,reason=ns.Session.Current()
122
+ if not session then return nil,reason end
123
+ local state,failure=ns.Persistence.Current()
124
+ if not state then return nil,failure end
125
+ if restricted(state.reentry) or state.reentry~=nil then return nil,"reload_ticket_exists" end
126
+ return submit(state,{schema="lycheedev.reentry.v1",standalone=true,
127
+ requestId="RELOAD-"..reloadNonce,sessionNonce=session.sessionNonce,
128
+ reloadNonce=reloadNonce,runtimeEpoch=session.runtimeEpoch,
129
+ character=session.character,realm=session.realm,guid=session.guid,
130
+ release=ns.Release,product=ns.Startup.identity.product,build=ns.Startup.identity.build})
131
+ end,
132
+ Flush=function(requestId,reloadNonce)
133
+ if submitted then return nil,"reload_already_submitted" end
134
+ if type(requestId)~="string" or #requestId==0 or #requestId>128
135
+ or not string.match(requestId,"^[%w_%-]+$") or type(reloadNonce)~="string"
136
+ or #reloadNonce~=32 or not string.match(reloadNonce,"^[0-9a-f]+$") then
137
+ return nil,"reload_invalid_request"
138
+ end
139
+ local session,reason=ns.Session.Current()
140
+ if not session then return nil,reason end
141
+ local state,failure=ns.Persistence.Current()
142
+ if not state then return nil,failure end
143
+ if restricted(state.reentry) or state.reentry~=nil then return nil,"reload_ticket_exists" end
144
+ local receipt,body=ns.ReportStore.Read(requestId)
145
+ if not receipt then return nil,body end
146
+ return submit(state,{schema="lycheedev.reentry.v1",builtin=true,requestId=requestId,
147
+ sessionNonce=session.sessionNonce,reloadNonce=reloadNonce,runtimeEpoch=session.runtimeEpoch,
148
+ character=session.character,realm=session.realm,guid=session.guid,
149
+ release=ns.Release,product=ns.Startup.identity.product,build=ns.Startup.identity.build,
150
+ receipt=receipt,bodyBytes=#body,bodyAdler32=ns.CaptureWriter.DigestBytes(body)})
151
+ end,
97
152
  LoadQueue=function(requestId,reloadNonce)
98
153
  if submitted then return nil,"reload_already_submitted" end
99
154
  local session,reason=ns.Session.Current()
@@ -149,27 +204,40 @@ ns.Reentry={
149
204
  for key,value in pairs(ticket) do copy[key]=value end
150
205
  ticket=copy
151
206
  waiting=frame
207
+ local entered,loadingDone=false,false
152
208
  frame:RegisterEvent("PLAYER_ENTERING_WORLD")
209
+ frame:RegisterEvent("LOADING_SCREEN_DISABLED")
210
+ frame:RegisterEvent("LOADING_SCREEN_ENABLED")
211
+ frame:RegisterEvent("PLAYER_LEAVING_WORLD")
153
212
  frame:SetScript("OnEvent",function(_,event,initialLogin,reloading)
154
- if event~="PLAYER_ENTERING_WORLD" or waiting~=frame then return end
213
+ if waiting~=frame then return end
214
+ if event=="PLAYER_LEAVING_WORLD" then cancel();return end
215
+ if event=="LOADING_SCREEN_ENABLED" then loadingDone=false;return end
216
+ if event=="PLAYER_ENTERING_WORLD" then
217
+ if restricted(initialLogin) or restricted(reloading) or initialLogin~=false or reloading~=true then cancel();return end
218
+ entered=true
219
+ elseif event=="LOADING_SCREEN_DISABLED" then loadingDone=true
220
+ else return end
221
+ -- Neither event alone proves the new world is ready. Their order
222
+ -- varies; retain the exact ticket until both have been observed.
223
+ if not entered or not loadingDone then return end
155
224
  local unchanged=rawequal(state.reentry,ownedTicket) and ns.CaptureWriter.Encode(state.reentry,8192)==ownedBytes
156
225
  cancel()
157
226
  if not unchanged then return end
158
227
  local current=ns.Persistence.Current()
159
228
  if current~=state or not current.options or current.options.bridgeEnabled~=true then return end
160
- if restricted(initialLogin) or restricted(reloading) or initialLogin~=false or reloading~=true then return end
161
229
  if restricted(state.runtimeEpoch) or state.runtimeEpoch~=ticket.runtimeEpoch then return end
162
230
  local actor=ns.Platform.ObserveActor()
163
231
  if not actor or actor.character~=ticket.character or actor.realm~=ticket.realm or actor.guid~=ticket.guid
164
232
  or ns.Release~=ticket.release or ns.Startup.identity.product~=ticket.product or ns.Startup.identity.build~=ticket.build then return end
165
233
  local receipt,body=ns.ReportStore.Read(ticket.requestId)
166
- if ticket.cleanupNonce or ticket.queueReload then
234
+ if ticket.cleanupNonce or ticket.queueReload or ticket.standalone then
167
235
  if receipt~=nil or body~="report_unavailable" then return end
168
236
  elseif receipt~=ticket.receipt or type(body)~="string" or #body~=ticket.bodyBytes or ns.CaptureWriter.DigestBytes(body)~=ticket.bodyAdler32 then return end
169
237
  local bound=ns.Session.Bind(ticket.sessionNonce)
170
238
  if not bound then return end
171
239
  if bound.runtimeEpoch~=ticket.runtimeEpoch+1 then ns.Session.Release(); return end
172
- if not ticket.cleanupNonce then
240
+ if not ticket.cleanupNonce and not ticket.standalone and not ticket.builtin then
173
241
  local scope=ns.ProbeQueue.ReloadScope(ticket.requestId)
174
242
  if not scope then ns.Session.Release(); return end
175
243
  for key,value in pairs(scope) do
@@ -62,7 +62,7 @@ ns.ReportStore = {
62
62
  signal.codeBytes = #code
63
63
  signal.codeAdler32 = ns.CaptureWriter.DigestBytes(code)
64
64
  end
65
- local receipt, encodeFailure = ns.CaptureWriter.Encode(signal, 4096)
65
+ local receipt, encodeFailure = ns.CaptureWriter.EncodeSignal(signal, 4096)
66
66
  if not receipt then return nil, encodeFailure end
67
67
  local count, bytes = 0, #receipt + #body
68
68
  for key, record in pairs(state.reports) do
@@ -107,13 +107,16 @@ ns.ReportStore = {
107
107
  return nil, "bridge_disabled"
108
108
  end
109
109
  if not plain(reported) then return nil, "report_invalid_acknowledgement" end
110
- -- Encoding rejects restricted values, metatables and cycles before any
111
- -- field comparisons. The host returns the archived original fields.
112
- local receipt, encodeFailure = ns.CaptureWriter.Encode(reported, 4096)
113
- if not receipt then return nil, encodeFailure end
114
110
  local requestId, bodyBytes, bodyAdler32 = reported.requestId, reported.reportBytes, reported.reportAdler32
115
- if not requestKey(requestId) or reported.schema ~= "lycheedev.signal.v1" or reported.kind ~= "reported"
116
- or type(reported.sequence) ~= "number" or reported.sequence < 1 or reported.sequence > 9007199254740991
111
+ if not requestKey(requestId) or reported.schema ~= "lycheedev.signal.v1" or reported.kind ~= "reported" then
112
+ return nil, "report_invalid_acknowledgement"
113
+ end
114
+ -- Encoding runs before the numeric shape checks: it rejects restricted
115
+ -- values, metatables and cycles, so a secret field reports that it is
116
+ -- secret instead of failing a type comparison it can never satisfy.
117
+ local receipt, encodeFailure = ns.CaptureWriter.EncodeSignal(reported, 4096)
118
+ if not receipt then return nil, encodeFailure end
119
+ if type(reported.sequence) ~= "number" or reported.sequence < 1 or reported.sequence > 9007199254740991
117
120
  or reported.sequence % 1 ~= 0 or type(bodyBytes) ~= "number" or bodyBytes < 1 or bodyBytes > 512 * 1024
118
121
  or bodyBytes % 1 ~= 0 or type(bodyAdler32) ~= "string" or #bodyAdler32 ~= 8
119
122
  or not string.match(bodyAdler32, "^[0-9a-f]+$") then
@@ -121,11 +124,25 @@ ns.ReportStore = {
121
124
  end
122
125
  local session, sessionFailure = ns.Session.Current()
123
126
  if not session then return nil, sessionFailure end
124
- if reported.sessionNonce ~= session.sessionNonce or reported.character ~= session.character
125
- or reported.realm ~= session.realm or reported.release ~= ns.Release
126
- or reported.product ~= ns.Startup.identity.product or reported.build ~= ns.Startup.identity.build then
127
+ -- The live session is authoritative for the actor and the nonce. The
128
+ -- compact wire form still carries both while a caller can supply them,
129
+ -- so an acknowledgement that contradicts the current session is refused
130
+ -- rather than canonicalized into agreement. The host echoes the fields it
131
+ -- archived, and the archived receipt is the compact form, so a caller
132
+ -- that omits them is consistent and still passes.
133
+ if reported.sessionNonce ~= nil and reported.sessionNonce ~= session.sessionNonce
134
+ or reported.character ~= nil and reported.character ~= session.character
135
+ or reported.realm ~= nil and reported.realm ~= session.realm
136
+ or reported.release ~= nil and reported.release ~= ns.Release
137
+ or reported.product ~= nil and reported.product ~= ns.Startup.identity.product
138
+ or reported.build ~= nil and reported.build ~= ns.Startup.identity.build then
127
139
  return nil, "report_acknowledgement_identity"
128
140
  end
141
+ -- The stored receipt is the canonical wire form. A caller echoes the
142
+ -- fields the host archived, so both sides are projected the same way and
143
+ -- the session nonce, which the wire omits, never has to be restated.
144
+ local receipt, encodeFailure = ns.CaptureWriter.EncodeSignal(reported, 4096)
145
+ if not receipt then return nil, encodeFailure end
129
146
  local storedReceipt, body = ns.ReportStore.Read(requestId)
130
147
  if not storedReceipt then return nil, body end
131
148
  if storedReceipt ~= receipt or #body ~= bodyBytes
@@ -139,7 +156,7 @@ ns.ReportStore = {
139
156
  local signal = {}
140
157
  for key, value in pairs(reported) do signal[key] = value end
141
158
  signal.kind, signal.sequence, signal.inputReady = "acknowledged", identity.sequence, false
142
- local acknowledgement, signalFailure = ns.CaptureWriter.Encode(signal, 2048)
159
+ local acknowledgement, signalFailure = ns.CaptureWriter.EncodeSignal(signal, 2048)
143
160
  if not acknowledgement then return nil, signalFailure end
144
161
  -- Prepare the bounded optical receipt before deletion. The executor must
145
162
  -- have archived and verified the full original report before this call.
@@ -70,7 +70,7 @@ ns.Session = {
70
70
  end
71
71
  local identity, identityFailure = ns.Session.NextIdentity()
72
72
  if not identity then return nil, identityFailure end
73
- return ns.CaptureWriter.Encode({
73
+ return ns.CaptureWriter.EncodeSignal({
74
74
  schema = "lycheedev.signal.v1", release = ns.Release, kind = "ready",
75
75
  sessionNonce = identity.sessionNonce, requestId = "",
76
76
  character = identity.character, realm = identity.realm, guid = identity.guid,
@@ -0,0 +1,31 @@
1
+ local ADDON_NAME, ns = ...
2
+
3
+ -- The single authority for client differences. One TOC serves every supported
4
+ -- build through its multi-interface declaration; the profile below is derived
5
+ -- from the running client's own build observation, never from which TOC file
6
+ -- a particular engine chose to read. Keep every product-specific value in the
7
+ -- baselines table and every product-specific branch behind ns.Client.
8
+ ns.PlatformProfile = nil
9
+ ns.Client = nil
10
+
11
+ local baselines = {
12
+ { product = "forever", version = "1.60.1", interface = 16001 },
13
+ { product = "classic", version = "5.5.4", interface = 50504 },
14
+ { product = "titan", version = "3.80.2", interface = 38002 },
15
+ { product = "retail", version = "12.1.0", interface = 120100 },
16
+ }
17
+
18
+ -- Select strictly by the observed interface number. Unsupported builds stay
19
+ -- unselected: Runtime reports the failure instead of guessing a profile.
20
+ -- GetBuildInfo is guarded so catalog-only loads (hosted test harnesses without
21
+ -- engine stubs) simply leave the client unselected instead of erroring.
22
+ local interface = type(GetBuildInfo) == "function" and select(4, GetBuildInfo()) or nil
23
+ if type(interface) == "number" then
24
+ for _, baseline in ipairs(baselines) do
25
+ if interface == baseline.interface then
26
+ ns.PlatformProfile = baseline
27
+ ns.Client = baseline.product
28
+ break
29
+ end
30
+ end
31
+ end
@@ -25,35 +25,33 @@ ns.Compat = {
25
25
  end
26
26
  local succeeded, foci = pcall(GetMouseFoci)
27
27
  if not succeeded or (issecretvalue and issecretvalue(foci))
28
- or type(foci) ~= "table" or not foci[1]
29
- or (issecretvalue and issecretvalue(foci[1])) then
28
+ or type(foci) ~= "table"
29
+ or (issecretvalue and issecretvalue(foci[1])) or not foci[1] then
30
30
  return nil
31
31
  end
32
32
  return foci[1]
33
33
  end,
34
34
 
35
- -- UI units per physical screen pixel, for screen-space overlays such as
36
- -- the automation status blocks and QR notice. GetPhysicalScreenSize was
37
- -- verified on the Retail 12.1.0 baseline only; other clients use the
38
- -- legacy 768-height approximation until verified.
35
+ -- UI units per physical screen pixel, for screen-space overlays. The
36
+ -- caller multiplies by a physical-pixel target to get UI units.
37
+ --
38
+ -- Only the width ratio is trustworthy: GetScreenWidth and the physical
39
+ -- width are both display measurements. GetScreenHeight is NOT usable as a
40
+ -- fallback, because the engines disagree about what it returns (Retail
41
+ -- reports the UIParent height, Classic the display height), so a ratio
42
+ -- built from it inflates or shrinks an overlay by a large factor on exactly
43
+ -- the clients that lack GetPhysicalScreenSize. When the physical width is
44
+ -- unavailable this reports 1: one UI unit per pixel, the neutral answer.
39
45
  GetPhysicalPixelSize = function()
40
- if GetPhysicalScreenSize then
41
- local succeeded, width, height = pcall(GetPhysicalScreenSize)
42
- if succeeded and not (issecretvalue and (issecretvalue(width) or issecretvalue(height)))
43
- and width and width > 0 and GetScreenWidth then
44
- local uiWidth = GetScreenWidth()
45
- if uiWidth and uiWidth > 0 and not (issecretvalue and issecretvalue(uiWidth)) then
46
- return uiWidth / width
47
- end
46
+ if GetPhysicalScreenSize and GetScreenWidth then
47
+ local succeeded, width = pcall(GetPhysicalScreenSize)
48
+ local uiWidth = GetScreenWidth()
49
+ if succeeded and not (issecretvalue and (issecretvalue(width) or issecretvalue(uiWidth)))
50
+ and type(width) == "number" and width > 0 and width < math.huge
51
+ and type(uiWidth) == "number" and uiWidth > 0 and uiWidth < math.huge then
52
+ return math.min(uiWidth / width, 1)
48
53
  end
49
54
  end
50
- -- Fallback for clients without a verified GetPhysicalScreenSize: the
51
- -- legacy 768-height approximation treats the screen as 768 physical
52
- -- pixels tall, so one physical pixel spans (uiHeight / 768) UI units.
53
- local uiHeight = GetScreenHeight and GetScreenHeight() or nil
54
- if uiHeight and uiHeight > 0 and not (issecretvalue and issecretvalue(uiHeight)) then
55
- return uiHeight / 768
56
- end
57
55
  return 1
58
56
  end,
59
57
  }