singularity-forge/packages/native/src/xxhash
Copilot ce7bde14f3 Fix execute-task loop detection: adaptive reconciliation instead of hard stop (#342)
* Initial plan

* Add adaptive reconciliation, concrete remediation steps, and xxHash32 JS fallback

- auto.ts: final reconciliation pass before halting on loop detection
  (runs skipExecuteTask to write blocker artifacts and advance pipeline)
- auto.ts: adaptive retry on prevCount>=2: write stub summary when still
  missing after two agent sessions, so the agent has a recovery context
- auto.ts: buildLoopRemediationSteps() helper with concrete manual steps
  when automatic reconciliation cannot resolve the unit
- xxhash/index.ts: pure-JS xxHash32 fallback when native addon does not
  export xxHash32 (prevents 'native.xxHash32 is not a function' crash)
- idle-recovery.test.ts: tests for buildLoopRemediationSteps and loop-recovery
  path in skipExecuteTask

Co-authored-by: glittercowboy <186001655+glittercowboy@users.noreply.github.com>

* Address code review feedback

- xxhash/index.ts: extract accumulate() helper to remove duplicate lane
  processing lines in the 16-byte loop
- auto.ts: replace magic number 2 with named constant STUB_RECOVERY_THRESHOLD
- idle-recovery.test.ts: add comment explaining the 3 (== MAX_UNIT_DISPATCHES)
  used in the loop-recovery test

Co-authored-by: glittercowboy <186001655+glittercowboy@users.noreply.github.com>

* Address PR review: verify post-state, fix stub wording, fix checkbox syntax, add fallback test

- auto.ts (MAX branch): check verifyExpectedArtifact() after skipExecuteTask()
  before advancing; annotate both conditions explaining what each validates
- auto.ts (self-repair branch): guard advance with verifyExpectedArtifact() so
  regex mismatches in the slice plan don't silently re-dispatch
- auto.ts (stub-recovery): write stub summary directly with "PARTIAL RECOVERY"
  wording instead of using skipExecuteTask (which would claim "exhausted N attempts")
- auto.ts (remediation): fix checkbox example to "- [x] **${tid}:" (no trailing **)
- xxhash/index.ts: export xxHash32Fallback so CI can test JS path independently
- native/src/index.ts: re-export xxHash32Fallback
- xxhash.test.mjs: add "xxHash32Fallback (pure-JS path)" describe block that
  validates the JS implementation against the reference on all test cases

Co-authored-by: glittercowboy <186001655+glittercowboy@users.noreply.github.com>

* chore: retrigger CI

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: glittercowboy <186001655+glittercowboy@users.noreply.github.com>
Co-authored-by: CI Trigger <noreply@github.com>
2026-03-14 07:26:10 -06:00
..
index.ts Fix execute-task loop detection: adaptive reconciliation instead of hard stop (#342) 2026-03-14 07:26:10 -06:00