@try-works/dsh-memory 0.1.18 → 0.1.19

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/host.js +11 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@try-works/dsh-memory",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "Git-backed, workspace-scoped memory for the DeepSeek Harness (global layer + per-workspace layers)",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/host.js CHANGED
@@ -759,8 +759,17 @@ export function wireHost(ctx, store, cfg) {
759
759
 
760
760
  // session lifecycle: associate workspace + capture on turn end
761
761
  ctx.on('session/event', (session, event) => {
762
- if (event.type === 'turn/start') void resolveKey(session).then(() => publishMemoryMap(session))
763
- else if (event.type === 'turn/end') { maybeCapture(session); publishMemoryMap(session) }
762
+ // DEFERRED, and it has to be. This handler runs INSIDE an append - the harness sets a reentrancy
763
+ // flag for the duration of the session/event emission - and Session.append refuses to reenter:
764
+ // "session append cannot reenter while another append is being published". Measured in the live
765
+ // log, exactly half the publishes failed with that message while the pre-step ones succeeded.
766
+ // A macrotask lands after the append has settled, so the guard is satisfied.
767
+ if (event.type === 'turn/start') {
768
+ void resolveKey(session).then(() => setTimeout(() => publishMemoryMap(session), 0))
769
+ } else if (event.type === 'turn/end') {
770
+ maybeCapture(session)
771
+ setTimeout(() => publishMemoryMap(session), 0)
772
+ }
764
773
  })
765
774
 
766
775
  // Disposal is the LAST chance to capture a session, so it bypasses the throttle.