@tekmidian/pai 0.34.0 → 0.34.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekmidian/pai",
3
- "version": "0.34.0",
3
+ "version": "0.34.1",
4
4
  "description": "PAI Knowledge OS — Personal AI Infrastructure with federated memory and project management",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",
@@ -122,8 +122,19 @@ housekeeping_due() {
122
122
  [ "$HOUSEKEEP_INTERVAL" = "0" ] && return 0
123
123
  [ -f "$HOUSEKEEP_STAMP" ] || return 0
124
124
  local last now
125
- last=$(cat "$HOUSEKEEP_STAMP" 2>/dev/null || echo 0)
126
- case "$last" in ''|*[!0-9]*) last=0 ;; esac
125
+ # Read the FIRST line and keep only digits.
126
+ #
127
+ # This was `cat` piped into a numeric check that reset to 0 on anything
128
+ # non-numeric — and a stamp file with a stray second value makes the whole
129
+ # read non-numeric, so `last` became 0, every turn looked overdue, and the
130
+ # debounce never once took effect. The guard meant to make this cheap was
131
+ # itself the reason it stayed expensive.
132
+ #
133
+ # Concurrent turns can both write here, so a malformed file is a state to
134
+ # tolerate rather than an impossibility. Taking the first line and stripping
135
+ # to digits cannot be defeated by extra values or trailing whitespace.
136
+ last=$(head -n 1 "$HOUSEKEEP_STAMP" 2>/dev/null | tr -dc '0-9')
137
+ [ -z "$last" ] && last=0
127
138
  now=$(date +%s)
128
139
  [ $((now - last)) -ge "$HOUSEKEEP_INTERVAL" ]
129
140
  }