lycheedev 3.0.2 → 3.1.1

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 (37) hide show
  1. package/THIRD_PARTY_NOTICES +27 -0
  2. package/native/windows-amd64/lycheedev.exe +0 -0
  3. package/package.json +1 -1
  4. package/payload/addon/Bridge/InputProtection.lua +18 -5
  5. package/payload/addon/Bridge/InputState.lua +25 -11
  6. package/payload/addon/Bridge/MemoryProtocol.lua +2 -2
  7. package/payload/addon/Bridge/ReceiverBindings.lua +85 -16
  8. package/payload/addon/Bridge/SlotProtocol.lua +48 -4
  9. package/payload/addon/Bridge/SlotRuntime.lua +63 -10
  10. package/payload/addon/Core/Controls.lua +6 -1
  11. package/payload/addon/Core/Locale.lua +7 -0
  12. package/payload/addon/Core/Locale_enUS.lua +7 -0
  13. package/payload/addon/Core/Runtime.lua +1 -1
  14. package/payload/addon/Lychee Dev.toc +1 -1
  15. package/payload/skill/SKILL.md +73 -75
  16. package/payload/skill/agents/openai.yaml +2 -2
  17. package/payload/skill/references/addon-validation.md +33 -9
  18. package/payload/skill/references/asset-export.md +37 -4
  19. package/payload/skill/references/commands.md +7 -3
  20. package/payload/skill/references/data-hotfix.md +13 -0
  21. package/payload/skill/references/data-investigation.md +9 -0
  22. package/payload/skill/references/data-query-recipes.md +19 -0
  23. package/payload/skill/references/data-recovery.md +12 -0
  24. package/payload/skill/references/data-tables.md +21 -1
  25. package/payload/skill/references/data-targets.md +4 -0
  26. package/payload/skill/references/error-diagnosis.md +33 -2
  27. package/payload/skill/references/installation.md +34 -15
  28. package/payload/skill/references/live-investigation.md +79 -82
  29. package/payload/skill/references/live-probes.md +34 -9
  30. package/payload/skill/references/live-recovery.md +62 -21
  31. package/payload/skill/references/live-startup.md +27 -14
  32. package/payload/skill/references/runtime-investigations.md +23 -4
  33. package/payload/skill/references/source-preparation.md +4 -1
  34. package/payload/skill/references/source-relations.md +14 -0
  35. package/payload/skill/references/source-research.md +30 -0
  36. package/payload/skill/references/source-value-flow.md +19 -0
  37. package/release.json +71 -71
@@ -764,3 +764,30 @@ documentation; source mirror wow-ui-source
764
764
  generated CatalogData_*.lua file header. World of Warcraft and Blizzard
765
765
  Battle.net are trademarks or registered trademarks of Blizzard Entertainment,
766
766
  Inc. in the U.S. and/or other countries.
767
+
768
+
769
+ ============================================================
770
+ github.com/Microsoft/go-winio v0.6.2
771
+ https://github.com/microsoft/go-winio/tree/v0.6.2
772
+ ============================================================
773
+ The MIT License (MIT)
774
+
775
+ Copyright (c) 2015 Microsoft
776
+
777
+ Permission is hereby granted, free of charge, to any person obtaining a copy
778
+ of this software and associated documentation files (the "Software"), to deal
779
+ in the Software without restriction, including without limitation the rights
780
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
781
+ copies of the Software, and to permit persons to whom the Software is
782
+ furnished to do so, subject to the following conditions:
783
+
784
+ The above copyright notice and this permission notice shall be included in all
785
+ copies or substantial portions of the Software.
786
+
787
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
788
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
789
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
790
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
791
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
792
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
793
+ SOFTWARE.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lycheedev",
3
- "version": "3.0.2",
3
+ "version": "3.1.1",
4
4
  "private": false,
5
5
  "description": "Unified native World of Warcraft development toolkit",
6
6
  "license": "MIT",
@@ -2,10 +2,10 @@ local _, ns = ...
2
2
 
3
3
  -- One short, runtime-local lease. No UI or event work until explicitly acquired.
4
4
  -- This shields this game's UI; it is not a system-wide keyboard/mouse lock.
5
- local frame, active, unavailable
5
+ local frame, active, unavailable, activeBindings
6
6
  local function release(token, reason)
7
7
  if not active or active ~= token then return false end
8
- local prior=active;active=nil
8
+ local prior=active;active=nil;activeBindings=nil
9
9
  if prior.timer then pcall(prior.timer.Cancel,prior.timer) end
10
10
  frame:Hide();frame:UnregisterAllEvents();frame:SetScript("OnEvent",nil)
11
11
  if ns.ActivityView then pcall(ns.ActivityView.Receiving,false) end
@@ -20,6 +20,19 @@ ns.InputProtection={
20
20
  or seconds~=seconds or seconds<=0 or seconds==math.huge then return nil,"input_protection_invalid_budget" end
21
21
  if ns.Platform.ObserveInputState(transport==true)~=true then return nil,"input_protection_not_ready" end
22
22
  if not C_Timer or type(C_Timer.NewTimer)~="function" then return nil,"input_protection_timer_unavailable" end
23
+ local bindings
24
+ if transport==true then
25
+ if not ns.ReceiverBindings or type(ns.ReceiverBindings.Current)~="function" then return nil,"input_protection_not_ready" end
26
+ local ok,profile=pcall(ns.ReceiverBindings.Current)
27
+ if not ok or (issecretvalue and issecretvalue(profile)) or type(profile)~="table" then return nil,"input_protection_not_ready" end
28
+ for _,action in ipairs({"wake","submit","close"}) do
29
+ if issecretvalue and issecretvalue(profile[action]) then return nil,"input_protection_not_ready" end
30
+ end
31
+ if profile.close~="ALT-CTRL-[" or not
32
+ ((profile.wake=="ALT-CTRL-F12" and profile.submit=="ALT-CTRL-SHIFT-F12")
33
+ or (profile.wake=="ALT-CTRL-F11" and profile.submit=="ALT-CTRL-SHIFT-F11")) then return nil,"input_protection_not_ready" end
34
+ bindings={wake=profile.wake,submit=profile.submit,close=profile.close}
35
+ end
23
36
  if not frame then
24
37
  local candidate
25
38
  local created=pcall(function()
@@ -31,8 +44,8 @@ ns.InputProtection={
31
44
  local token=active
32
45
  self:SetPropagateKeyboardInput(false)
33
46
  if chord=="ALT-CTRL-[" then release(token,"input_protection_cancelled");return end
34
- if token and token.transport then
35
- self:SetPropagateKeyboardInput(chord=="ALT-CTRL-F12" or chord=="ALT-CTRL-SHIFT-F12")
47
+ if token and activeBindings then
48
+ self:SetPropagateKeyboardInput(chord==activeBindings.wake or chord==activeBindings.submit)
36
49
  end
37
50
  end)
38
51
  end)
@@ -44,7 +57,7 @@ ns.InputProtection={
44
57
  frame=candidate
45
58
  end
46
59
  local token={interrupted=interrupted,transport=transport==true}
47
- active=token
60
+ active=token;activeBindings=bindings
48
61
  local ok=pcall(function()
49
62
  token.timer=C_Timer.NewTimer(seconds,function()release(token,"input_protection_timeout")end)
50
63
  assert(token.timer,"input_protection_timer_unavailable")
@@ -2,20 +2,22 @@ local _, ns = ...
2
2
 
3
3
  -- Owner-approved native transport telemetry. One sampler/display, no input
4
4
  -- hooks or focus mutation. Explicit bridge-off removes all recurring work.
5
- local frame, provider, record, last, sequence, lastTick
5
+ local frame, provider, record, last, sequence, lastTick,mailbox
6
6
  local loading,leaving,refreshing,heartbeat
7
7
  local zero=string.rep("0",32)
8
- local function nativeBindingsReady()
9
- if not ns.SlotRuntime then return true end
10
- if not ns.ReceiverBindings or type(ns.ReceiverBindings.Current)~="function" then return false end
8
+ local function nativeBindings()
9
+ if not ns.ReceiverBindings or type(ns.ReceiverBindings.Current)~="function" then return nil end
11
10
  local ok,profile=pcall(ns.ReceiverBindings.Current)
12
- if not ok or (issecretvalue and issecretvalue(profile)) or type(profile)~="table" then return false end
11
+ if not ok or (issecretvalue and issecretvalue(profile)) or type(profile)~="table" then return nil end
13
12
  for _,key in ipairs({"wake","submit","close"}) do
14
- if issecretvalue and issecretvalue(profile[key]) then return false end
13
+ if issecretvalue and issecretvalue(profile[key]) then return nil end
15
14
  end
16
- return profile.wake=="ALT-CTRL-F12" and profile.submit=="ALT-CTRL-SHIFT-F12" and profile.close=="ALT-CTRL-["
15
+ if profile.close~="ALT-CTRL-[" or not
16
+ ((profile.wake=="ALT-CTRL-F12" and profile.submit=="ALT-CTRL-SHIFT-F12")
17
+ or (profile.wake=="ALT-CTRL-F11" and profile.submit=="ALT-CTRL-SHIFT-F11")) then return nil end
18
+ return {wake=profile.wake,submit=profile.submit,close=profile.close}
17
19
  end
18
- local function hide()record=nil;ns.InputSignal.Hide() end
20
+ local function hide()record=nil;if mailbox then rawset(mailbox,"input",nil) end;ns.InputSignal.Hide() end
19
21
  local function sample()
20
22
  if loading or leaving or ns.Compat.InWorld()~=true then hide();return end
21
23
  local identity=provider and provider()
@@ -25,14 +27,19 @@ local function sample()
25
27
  lastTick=tick
26
28
  local ready,reason=ns.Platform.ObserveInputState()
27
29
  if issecretvalue and (issecretvalue(ready) or issecretvalue(reason)) then ready,reason=nil,"input_observation_unavailable" end
28
- if not nativeBindingsReady() then ready,reason=false,"input_binding_unavailable" end
30
+ local bindings=nativeBindings()
31
+ if not bindings then ready,reason=false,"input_binding_unavailable" end
29
32
  if ready~=true and (type(reason)~="string" or reason=="") then reason="input_observation_unavailable" end
30
33
  sequence=sequence+1
31
34
  if sequence>=4294967295 then ns.InputState.Stop();return end
32
- identity.schema="lycheedev.input.v1"
35
+ identity.schema="lycheedev.input.v3"
36
+ identity.bindings=bindings or {wake="",submit="",close=""}
33
37
  identity.sampleMillis=math.floor(tick*1000)
34
38
  identity.inputBlocked=ready~=true
35
39
  identity.reason=reason or ""
40
+ -- Always obtain a detached private snapshot; public mailbox values never
41
+ -- drive the attempt sequence or any input/receipt authorization.
42
+ if ns.SlotRuntime and ns.SlotRuntime.InputDiagnostic then identity.inputAttempt=ns.SlotRuntime.InputDiagnostic() end
36
43
  local text=ns.CaptureWriter.Encode(identity,2048)
37
44
  if not text then hide();return end
38
45
  record=ns.MemoryProtocol.Encode(identity.runtime,identity.runtime,zero,5,1,sequence,text)
@@ -41,6 +48,7 @@ local function sample()
41
48
  local nextHeartbeat=not heartbeat
42
49
  if not ns.InputSignal.Render(state,nextHeartbeat) then hide();return end
43
50
  heartbeat=nextHeartbeat
51
+ if mailbox then rawset(mailbox,"input",record) end
44
52
  end
45
53
  local function refresh()
46
54
  if refreshing or not provider or not frame or not frame:GetScript("OnUpdate") then return end
@@ -50,7 +58,12 @@ local function refresh()
50
58
  if not ok then hide() end
51
59
  end
52
60
  ns.InputState={
53
- Start=function(observe)
61
+ Start=function(observe,publication)
62
+ if mailbox~=publication then
63
+ if mailbox then rawset(mailbox,"input",nil) end
64
+ mailbox=publication
65
+ if mailbox then rawset(mailbox,"input",nil) end
66
+ end
54
67
  provider=observe
55
68
  if frame and frame:GetScript("OnUpdate") then return true end
56
69
  sequence,last=sequence or 0,0
@@ -86,6 +99,7 @@ ns.InputState={
86
99
  end
87
100
  provider,record,lastTick=nil,nil,nil
88
101
  hide()
102
+ mailbox=nil
89
103
  if frame then frame:Hide() end
90
104
  if ns.StartupBeacon then ns.StartupBeacon.Stop() end
91
105
  end,
@@ -24,8 +24,8 @@ ns.MemoryProtocol = {
24
24
  or type(sequence)~="number" or sequence<0 or sequence>=4294967296 or sequence%1~=0 then
25
25
  return nil,"memory_record_invalid"
26
26
  end
27
- local header="LYCMEM05"..raw(nonce)..raw(runtime)..raw(ticket)
27
+ local header="LYCMEM06"..raw(nonce)..raw(runtime)..raw(ticket)
28
28
  ..string.char(kind,state,0,0)..u32(sequence)..u32(#payload)..u32(checksum(payload))..u32(80)
29
- return header..u32(checksum(header))..payload.."LYCEND05"..raw(nonce)..raw(runtime)
29
+ return header..u32(checksum(header))..payload.."LYCEND06"..raw(nonce)..raw(runtime)
30
30
  end,
31
31
  }
@@ -3,8 +3,11 @@ local _, ns = ...
3
3
  -- These are runtime override bindings. Only our SavedVariables option is
4
4
  -- written; the player's account key bindings are never saved or replaced.
5
5
  local defaults = { wake = "ALT-CTRL-]", submit = "ALT-CTRL-SHIFT-]", close = "ALT-CTRL-[" }
6
+ local nativePrimary = { wake = "ALT-CTRL-F12", submit = "ALT-CTRL-SHIFT-F12", close = "ALT-CTRL-[" }
7
+ local nativeFallback = { wake = "ALT-CTRL-F11", submit = "ALT-CTRL-SHIFT-F11", close = "ALT-CTRL-[" }
6
8
  local actions = { "wake", "submit", "close" }
7
9
  local owner, buttons, handlers, effective
10
+ local nativeWarningPrinted = false
8
11
  local function restricted(value) return issecretvalue and issecretvalue(value) end
9
12
  local function copy(profile)
10
13
  return { wake = profile.wake, submit = profile.submit, close = profile.close }
@@ -46,8 +49,12 @@ local function noncombat()
46
49
  if combat then return nil, "receiver_combat" end
47
50
  return true
48
51
  end
49
- local function ownAction(value)
50
- return type(value) == "string" and string.find(value, "LycheeDevReceiver", 1, true) ~= nil
52
+ local function bindingAction(action)
53
+ return "CLICK LycheeDevReceiver" .. string.upper(string.sub(action, 1, 1)) .. string.sub(action, 2) .. ":LeftButton"
54
+ end
55
+ local function bindingDetail(value)
56
+ if restricted(value) or type(value) ~= "string" then return nil end
57
+ return string.sub(value, 1, 128):gsub("[%z\1-\31\127]", "?")
51
58
  end
52
59
  local function conflict(profile)
53
60
  if type(GetBindingAction) ~= "function" then return nil, "receiver_bindings_unavailable" end
@@ -58,8 +65,8 @@ local function conflict(profile)
58
65
  if not ok or restricted(bound) or (bound ~= nil and type(bound) ~= "string") then
59
66
  return nil, "receiver_bindings_unavailable"
60
67
  end
61
- if bound and bound ~= "" and bound ~= "NONE" and not ownAction(bound) then
62
- return nil, "receiver_binding_conflict:" .. action .. ":" .. chord
68
+ if bound and bound ~= "" and bound ~= "NONE" and bound ~= bindingAction(action) then
69
+ return nil, "receiver_binding_conflict:" .. action .. ":" .. chord, bindingDetail(bound)
63
70
  end
64
71
  end
65
72
  end
@@ -96,9 +103,9 @@ local function install(profile)
96
103
  for _, action in ipairs(actions) do
97
104
  local ok, resolved = pcall(GetBindingAction, profile[action], true)
98
105
  if not ok or restricted(resolved) or type(resolved) ~= "string"
99
- or not string.find(resolved, buttons[action]:GetName(), 1, true) then
106
+ or resolved ~= bindingAction(action) then
100
107
  clear()
101
- return nil, "receiver_binding_ineffective:" .. action .. ":" .. profile[action]
108
+ return nil, "receiver_binding_ineffective:" .. action .. ":" .. profile[action], bindingDetail(resolved)
102
109
  end
103
110
  end
104
111
  return true
@@ -106,13 +113,13 @@ end
106
113
  local function apply(profile)
107
114
  local valid, failure = validate(profile)
108
115
  if not valid then return nil, failure end
109
- local ready
116
+ local ready, detail
110
117
  ready, failure = noncombat()
111
118
  if not ready then return nil, failure end
112
- ready, failure = conflict(valid)
113
- if not ready then return nil, failure end
119
+ ready, failure, detail = conflict(valid)
120
+ if not ready then return nil, failure, detail end
114
121
  local prior = effective and copy(effective)
115
- ready, failure = install(valid)
122
+ ready, failure, detail = install(valid)
116
123
  if not ready then
117
124
  if prior then
118
125
  local restored = install(prior)
@@ -120,11 +127,60 @@ local function apply(profile)
120
127
  else
121
128
  effective = nil
122
129
  end
123
- return nil, failure
130
+ return nil, failure, detail
124
131
  end
125
132
  effective = valid
126
133
  return copy(valid)
127
134
  end
135
+ local function nativeConflict(reason)
136
+ for _, action in ipairs(actions) do
137
+ local suffix = action .. ":" .. nativePrimary[action]
138
+ if reason == "receiver_binding_conflict:" .. suffix
139
+ or reason == "receiver_binding_ineffective:" .. suffix then return true end
140
+ end
141
+ return false
142
+ end
143
+ local function displayChord(chord)
144
+ return chord:gsub("ALT%-CTRL%-SHIFT%-", "Ctrl+Alt+Shift+"):gsub("ALT%-CTRL%-", "Ctrl+Alt+")
145
+ end
146
+ local function nativeFailureText(reason, profile)
147
+ local locale = ns.L or {}
148
+ for _, action in ipairs(actions) do
149
+ local suffix = action .. ":" .. profile[action]
150
+ local label = locale["NATIVE_RECEIVER_BINDING_" .. string.upper(action)] or action
151
+ if reason == "receiver_binding_conflict:" .. suffix then
152
+ return string.format(locale.NATIVE_RECEIVER_BINDING_CONFLICT or "%s shortcut %s is occupied", label, displayChord(profile[action]))
153
+ elseif reason == "receiver_binding_ineffective:" .. suffix then
154
+ return string.format(locale.NATIVE_RECEIVER_BINDING_INEFFECTIVE or "%s shortcut %s is ineffective", label, displayChord(profile[action]))
155
+ end
156
+ end
157
+ return tostring(reason)
158
+ end
159
+ local function applyNative(warn)
160
+ local profile, failure, detail = apply(nativePrimary)
161
+ if profile or not nativeConflict(failure) then return profile, failure end
162
+ local primaryFailure, primaryDetail = failure, detail
163
+ profile, failure, detail = apply(nativeFallback)
164
+ if warn and not nativeWarningPrinted then
165
+ nativeWarningPrinted = true
166
+ local locale = ns.L or {}
167
+ local unknown = locale.NOT_AVAILABLE or "unavailable"
168
+ local text
169
+ if profile then
170
+ text = string.format(locale.NATIVE_RECEIVER_BINDING_FALLBACK
171
+ or "%s (binding action: %s). Selected fallback shortcuts: wake %s, submit %s, close %s.",
172
+ nativeFailureText(primaryFailure, nativePrimary), primaryDetail or unknown,
173
+ displayChord(profile.wake), displayChord(profile.submit), displayChord(profile.close))
174
+ else
175
+ text = string.format(locale.NATIVE_RECEIVER_BINDING_BLOCKED
176
+ or "Primary and fallback shortcuts are unavailable; input is blocked. Primary: %s (binding action: %s); fallback: %s (binding action: %s). Existing bindings were preserved.",
177
+ nativeFailureText(primaryFailure, nativePrimary), primaryDetail or unknown,
178
+ nativeFailureText(failure, nativeFallback), detail or unknown)
179
+ end
180
+ print("|cffd83b4eLychee Dev:|r " .. text)
181
+ end
182
+ return profile, failure
183
+ end
128
184
  local function stored()
129
185
  if ns.SlotRuntime then return copy(defaults) end
130
186
  local state, failure = ns.Persistence.Current()
@@ -140,7 +196,7 @@ local function current()
140
196
  local ok, resolved = pcall(GetBindingAction, effective[action], true)
141
197
  if not ok or restricted(resolved) or type(resolved) ~= "string"
142
198
  or not buttons or not buttons[action]
143
- or not string.find(resolved, buttons[action]:GetName(), 1, true) then
199
+ or resolved ~= bindingAction(action) then
144
200
  return nil, "receiver_binding_ineffective:" .. action .. ":" .. effective[action]
145
201
  end
146
202
  end
@@ -152,7 +208,10 @@ local function defer(event)
152
208
  self:UnregisterAllEvents(); self:SetScript("OnEvent", nil)
153
209
  local profile, failure = stored()
154
210
  local ready
155
- if profile then ready, failure = apply(profile) end
211
+ if profile then
212
+ if ns.SlotRuntime then ready, failure = applyNative(true)
213
+ else ready, failure = apply(profile) end
214
+ end
156
215
  if not ready and failure == "receiver_combat" then defer("PLAYER_REGEN_ENABLED")
157
216
  elseif not ready then ns.Startup.receiverFailure = failure end
158
217
  end)
@@ -203,10 +262,16 @@ ns.ReceiverBindings = {
203
262
  return copy(applied)
204
263
  end,
205
264
  Reset = function()
265
+ if ns.SlotRuntime and ns.SlotRuntime.IsActive and ns.SlotRuntime.IsActive() then
266
+ return nil, "receiver_active"
267
+ end
206
268
  if ns.Receiver and type(ns.Receiver.IsActive) == "function" and ns.Receiver.IsActive() then
207
269
  return nil, "receiver_active"
208
270
  end
209
271
  if not owner then return nil, "receiver_bindings_unavailable" end
272
+ -- Native keys are fixed; explicit recovery reapplies only our runtime
273
+ -- overrides and preserves the saved legacy profile.
274
+ if ns.SlotRuntime then return applyNative(true) end
210
275
  local state, failure = ns.Persistence.Current()
211
276
  if not state then return nil, failure end
212
277
  local applied
@@ -217,7 +282,10 @@ ns.ReceiverBindings = {
217
282
  return copy(applied)
218
283
  end,
219
284
  Register = function(callbacks)
220
- if owner then return true end
285
+ if owner then
286
+ local profile, failure = current()
287
+ return profile and true or nil, failure
288
+ end
221
289
  if not ns.Startup.ready then return nil, "addon_not_ready" end
222
290
  if type(callbacks) ~= "table" or type(callbacks.wake) ~= "function"
223
291
  or type(callbacks.submit) ~= "function" or type(callbacks.close) ~= "function" then
@@ -227,7 +295,7 @@ ns.ReceiverBindings = {
227
295
  return nil, "receiver_bindings_unavailable"
228
296
  end
229
297
  if ns.SlotRuntime then
230
- defaults = {wake="ALT-CTRL-F12",submit="ALT-CTRL-SHIFT-F12",close="ALT-CTRL-["}
298
+ defaults = copy(nativePrimary)
231
299
  end
232
300
  handlers = callbacks
233
301
  owner = CreateFrame("Frame", nil, UIParent)
@@ -240,7 +308,8 @@ ns.ReceiverBindings = {
240
308
  local profile, failure = stored()
241
309
  if not profile then return nil, failure end
242
310
  local ready
243
- ready, failure = apply(profile)
311
+ if ns.SlotRuntime then ready, failure = applyNative(true)
312
+ else ready, failure = apply(profile) end
244
313
  if not ready and failure == "receiver_combat" then return defer("PLAYER_REGEN_ENABLED") end
245
314
  return ready and true or nil, failure
246
315
  end,
@@ -7,6 +7,17 @@ local LIMIT=200
7
7
  local MAX_OPERATIONS=math.floor((LIMIT-16)/4)
8
8
  local function plain(v)return not (issecretvalue and issecretvalue(v)) and type(v)=="table" and getmetatable(v)==nil end
9
9
  local function safe(v)return not (issecretvalue and issecretvalue(v))end
10
+ local envelopeFields={"schema","index","runtime","owner","fence","nonce","ticket","action","guid","build",
11
+ "challenge","preparedNonce","reportBytes","reportChecksum","codeBytes","codeChecksum","budget"}
12
+ local function copyEnvelope(e,withCode)
13
+ local copy={}
14
+ for _,key in ipairs(envelopeFields) do
15
+ local value=e[key]
16
+ if safe(value) and (type(value)=="string" or type(value)=="number" or type(value)=="boolean") then copy[key]=value end
17
+ end
18
+ if withCode then copy.code=e.code end
19
+ return copy
20
+ end
10
21
 
11
22
  ns.SlotProtocol = { Count=LIMIT, Create=function(adapter)
12
23
  assert(plain(adapter) and ns.MemoryProtocol.Token(adapter.runtime),"invalid slot adapter")
@@ -15,7 +26,19 @@ ns.SlotProtocol = { Count=LIMIT, Create=function(adapter)
15
26
  local sequence,count,cursor=0,0,1
16
27
  local consumed,operations,receipts={},{},{}
17
28
  local descriptor
29
+ -- Passive copies only. Public maps must never alias protocol state: callers
30
+ -- may inspect or overwrite them without changing nonce/owner decisions.
31
+ local mailbox,mailboxReceipts,mailboxBodies
18
32
  local api={}
33
+ function api.AttachMailbox(publication)
34
+ assert(plain(publication) and publication.schema=="lycheedev.mailbox.v1"
35
+ and publication.runtime==adapter.runtime and publication.release==adapter.release,"invalid slot mailbox")
36
+ mailbox,mailboxReceipts,mailboxBodies=publication,{},{}
37
+ rawset(mailbox,"receipts",mailboxReceipts);rawset(mailbox,"bodies",mailboxBodies)
38
+ rawset(mailbox,"identity",descriptor)
39
+ for nonce,record in pairs(receipts) do rawset(mailboxReceipts,nonce,record) end
40
+ for ticket,op in pairs(operations) do if op.body then rawset(mailboxBodies,ticket,op.body) end end
41
+ end
19
42
  local function observe(op)
20
43
  if adapter.observe then
21
44
  local ok,result,reason=pcall(adapter.observe,op)
@@ -41,7 +64,7 @@ ns.SlotProtocol = { Count=LIMIT, Create=function(adapter)
41
64
  if sequence>=4294967295 then return nil,"slot_sequence_exhausted" end
42
65
  local a=actor();if not a then return nil,"slot_actor_unavailable" end
43
66
  sequence=sequence+1
44
- local value={schema="lycheedev.slot.v2",runtime=adapter.runtime,owner=owner or "",fence=fence or 0,
67
+ local value={schema="lycheedev.slot.v3",runtime=adapter.runtime,owner=owner or "",fence=fence or 0,
45
68
  nonce=e.nonce,ticket=e.ticket or ZERO,action=e.action,state=state,sequence=sequence,
46
69
  nextSlot=nextSlot(),slots=LIMIT,character=a.character,realm=a.realm,guid=a.guid,
47
70
  build=adapter.build,product=adapter.product,release=adapter.release,inventory=adapter.inventory,inputState=adapter.inputState}
@@ -50,15 +73,17 @@ ns.SlotProtocol = { Count=LIMIT, Create=function(adapter)
50
73
  local record;record,reason=wire.Encode(e.nonce,adapter.runtime,e.ticket or ZERO,kind or 2,1,sequence,text)
51
74
  if not record then return nil,reason end
52
75
  receipts[e.nonce]=record
76
+ if mailboxReceipts then rawset(mailboxReceipts,e.nonce,record) end
53
77
  return record,value
54
78
  end
55
79
  function api.Describe()
56
80
  local a=actor();if not a then return nil,"slot_actor_unavailable" end
57
- local text=encode({schema="lycheedev.slot.identity.v1",runtime=adapter.runtime,owner=owner or "",fence=fence or 0,
81
+ local text=encode({schema="lycheedev.slot.identity.v2",runtime=adapter.runtime,owner=owner or "",fence=fence or 0,
58
82
  nextSlot=nextSlot(),slots=LIMIT,character=a.character,realm=a.realm,guid=a.guid,
59
83
  build=adapter.build,product=adapter.product,release=adapter.release,inventory=adapter.inventory,inputState=adapter.inputState},16384)
60
84
  if not text then return nil,"slot_identity_encoding" end
61
85
  descriptor=wire.Encode(ZERO,adapter.runtime,ZERO,1,1,sequence,text)
86
+ if mailbox then rawset(mailbox,"identity",descriptor) end
62
87
  return descriptor
63
88
  end
64
89
  local function finish(op,ok,value,metadata)
@@ -70,6 +95,7 @@ ns.SlotProtocol = { Count=LIMIT, Create=function(adapter)
70
95
  -- Store body and outcome before constructing its public response.
71
96
  op.payload=text;op.bytes=#text;op.checksum=wire.Checksum(text)
72
97
  op.body=assert(wire.Encode(op.envelope.nonce,adapter.runtime,op.envelope.ticket,3,3,op.sequence,text))
98
+ if mailboxBodies then rawset(mailboxBodies,op.envelope.ticket,op.body) end
73
99
  op.state="reported";op.ok=ok
74
100
  observe(op)
75
101
  local record,value=publish(op.envelope,"reported",{reportBytes=op.bytes,reportChecksum=op.checksum,challenge=op.challenge})
@@ -88,7 +114,7 @@ ns.SlotProtocol = { Count=LIMIT, Create=function(adapter)
88
114
  if not plain(e) then return nil,"slot_envelope_invalid" end
89
115
  -- Never inspect or execute encoded business code before these checks.
90
116
  for _,key in ipairs({"schema","index","runtime","owner","fence","nonce","ticket","action","guid","build","challenge","preparedNonce","reportBytes","reportChecksum"}) do if not safe(e[key]) then return nil,"slot_secret_envelope" end end
91
- if e.schema~="lycheedev.slot.v2" or e.index~=index or not wire.Token(e.nonce)
117
+ if e.schema~="lycheedev.slot.v3" or e.index~=index or not wire.Token(e.nonce)
92
118
  or not wire.Token(e.ticket) or not wire.Token(e.owner) or not wire.Token(e.runtime) then return nil,"slot_envelope_invalid" end
93
119
  if e.runtime~=adapter.runtime then
94
120
  if type(e.guid)~="string" or type(e.build)~="string"
@@ -114,6 +140,9 @@ ns.SlotProtocol = { Count=LIMIT, Create=function(adapter)
114
140
  if not safe(e.code) or type(e.code)~="string" or #e.code<1 or #e.code>262144 or e.code:byte(1)==27
115
141
  or not safe(e.codeBytes) or e.codeBytes~=#e.code or not safe(e.codeChecksum) or e.codeChecksum~=wire.Checksum(e.code)
116
142
  or not safe(e.budget) or type(e.budget)~="number" or e.budget%1~=0 or e.budget<1 or e.budget>120 then return reject(e,"slot_code_invalid") end
143
+ -- The loading addon owns e. Retain only checked immutable values,
144
+ -- never its mutable table or unknown fields, before adapter calls.
145
+ e=copyEnvelope(e,true)
117
146
  local fn,reason=adapter.compile(e.code)
118
147
  local challenge=adapter.runtime:sub(1,24)..string.format("%08x",sequence+1)
119
148
  if not fn then
@@ -148,6 +177,7 @@ ns.SlotProtocol = { Count=LIMIT, Create=function(adapter)
148
177
  or e.reportBytes~=op.bytes or e.reportChecksum~=op.checksum then return reject(e,"slot_release_mismatch") end
149
178
  if op.resourcesReleased==false then return reject(e,"slot_resources_pending") end
150
179
  op.payload=nil;op.body=nil;op.fn=nil;op.state="released"
180
+ if mailboxBodies then rawset(mailboxBodies,e.ticket,nil) end
151
181
  -- Retain identity/digest tombstone; never re-admit its ticket.
152
182
  op.envelope.code=nil
153
183
  observe(op)
@@ -167,6 +197,20 @@ ns.SlotProtocol = { Count=LIMIT, Create=function(adapter)
167
197
  return {runtime=adapter.runtime,owner=owner or "",fence=fence or 0,nextSlot=nextSlot(),
168
198
  guid=a.guid,build=adapter.build,character=a.character,realm=a.realm}
169
199
  end
170
- function api.Snapshot()return {descriptor=descriptor,receipts=receipts,operations=operations,owner=owner,fence=fence,consumed=consumed}end
200
+ function api.Snapshot()
201
+ -- At most 200 receipts/consumed bits and 46 operation fact objects.
202
+ -- Immutable strings may be shared; execution functions, callbacks,
203
+ -- code and writable private tables never leave the engine.
204
+ local result={descriptor=descriptor,receipts={},operations={},owner=owner,fence=fence,consumed={}}
205
+ for nonce,record in pairs(receipts) do result.receipts[nonce]=record end
206
+ for i=1,LIMIT do if consumed[i] then result.consumed[i]=true end end
207
+ for ticket,op in pairs(operations) do
208
+ result.operations[ticket]={envelope=copyEnvelope(op.envelope,false),challenge=op.challenge,
209
+ sequence=op.sequence,state=op.state,body=op.body,bytes=op.bytes,checksum=op.checksum,
210
+ ok=op.ok,resourcesReleased=op.resourcesReleased}
211
+ end
212
+ return result
213
+ end
214
+ if adapter.mailbox then api.AttachMailbox(adapter.mailbox) end
171
215
  return api
172
216
  end }