@agentsignalnet/claude-plugin 0.2.92 → 0.2.93
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
package/scripts/inbox-daemon.mjs
CHANGED
|
@@ -768,6 +768,19 @@ const HELD_TOO_LONG_MS = LONGEST_HOLD_MS * 6;
|
|
|
768
768
|
const UNREADABLE_BEFORE_DEBRIS = 10;
|
|
769
769
|
|
|
770
770
|
async function claimStartup() {
|
|
771
|
+
/*
|
|
772
|
+
A BACKSTOP CANNOT BE TESTED WHILE THE THING IN FRONT OF IT WORKS.
|
|
773
|
+
|
|
774
|
+
The reconciliation after registration exists for the case where this lock
|
|
775
|
+
fails -- which has happened on a real machine and which I could not
|
|
776
|
+
reproduce. There is no way to prove that second line holds without
|
|
777
|
+
arranging for the first to be absent, so this switch exists to arrange it.
|
|
778
|
+
|
|
779
|
+
Test-only, and never set by the plugin or documented as a setting. Nothing
|
|
780
|
+
reads it except two-watchers-cannot-both-win.
|
|
781
|
+
*/
|
|
782
|
+
if (process.env.AGENTSIGNAL_NO_STARTUP_LOCK === '1') return () => {};
|
|
783
|
+
|
|
771
784
|
const rest = (ms) => new Promise((done) => setTimeout(done, ms));
|
|
772
785
|
let unreadable = 0;
|
|
773
786
|
|
|
@@ -963,6 +976,54 @@ writeFileSync(myWatcherPath, JSON.stringify(me), { mode: 0o600 });
|
|
|
963
976
|
// whole point of having held it across the decision.
|
|
964
977
|
releaseStartup();
|
|
965
978
|
|
|
979
|
+
/** Undo the registration this process just wrote, before standDown exists. */
|
|
980
|
+
function standDownEarly() {
|
|
981
|
+
try {
|
|
982
|
+
unlinkSync(myWatcherPath);
|
|
983
|
+
} catch {
|
|
984
|
+
/* never written, or already gone */
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* AND RECONCILE, because the lock is not to be trusted on its own.
|
|
990
|
+
*
|
|
991
|
+
* Everything above assumes the startup lock serialised the decision. On
|
|
992
|
+
* 2026-08-21 at 13:50:46 it did not, on a machine running the version that
|
|
993
|
+
* added it -- two daemons superseded the same incumbent seven milliseconds
|
|
994
|
+
* apart and both started, and both were still running hours later. I could not
|
|
995
|
+
* reproduce it: five racers against seeded debris, three rounds, all clean. So
|
|
996
|
+
* the reason the lock failed is still unknown.
|
|
997
|
+
*
|
|
998
|
+
* What is not unknown is the SHAPE of the damage. Two processes get past the
|
|
999
|
+
* lock, both register, and nothing afterwards ever looks again -- so the
|
|
1000
|
+
* duplicate is permanent, and every urgent message interrupts twice until
|
|
1001
|
+
* somebody notices by hand.
|
|
1002
|
+
*
|
|
1003
|
+
* This is the check that does not depend on the lock being right. Both
|
|
1004
|
+
* processes are registered by now, so both can see each other, and a TOTAL
|
|
1005
|
+
* ORDER decides without either needing to know what the other saw.
|
|
1006
|
+
*
|
|
1007
|
+
* LOWEST PID WINS, and the tiebreak matters more than which way it points:
|
|
1008
|
+
* mtime cannot separate two processes running the SAME file -- that is exactly
|
|
1009
|
+
* the case here -- and "equal mtimes stand down" is unusable when it would have
|
|
1010
|
+
* both stand down and leave the machine with no watcher at all. A pid is
|
|
1011
|
+
* unique, present on both sides, and gives the same answer to each.
|
|
1012
|
+
*
|
|
1013
|
+
* Only among rivals sharing this mtime. A genuinely newer build has already
|
|
1014
|
+
* been dealt with above and must not be stood down to on a pid comparison.
|
|
1015
|
+
*/
|
|
1016
|
+
const twins = livingWatchers(lockRoot).filter((rival) => rival.mtime === me.mtime);
|
|
1017
|
+
const usurper = twins.find((rival) => rival.pid < process.pid);
|
|
1018
|
+
if (usurper) {
|
|
1019
|
+
say(
|
|
1020
|
+
`pid ${usurper.pid} is watching the same build; standing down ` +
|
|
1021
|
+
'(the startup lock did not serialise this, which is a separate bug)',
|
|
1022
|
+
);
|
|
1023
|
+
standDownEarly();
|
|
1024
|
+
process.exit(0);
|
|
1025
|
+
}
|
|
1026
|
+
|
|
966
1027
|
// Best effort, and correctness does not depend on it -- a start that finds
|
|
967
1028
|
// this entry checks the pid before believing it. It is here so an ordinary
|
|
968
1029
|
// stop leaves nothing behind, rather than leaving the next start to reason
|