opencode-swarm 7.163.0 → 7.164.0

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 (87) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/{coder-settlement-g2g5kkv5.js → coder-settlement-84je6bza.js} +8 -8
  3. package/dist/cli/{config-doctor-p16xr78z.js → config-doctor-vfze38e1.js} +2 -2
  4. package/dist/cli/{core-g088v0zt.js → core-q5hv8e2w.js} +1 -1
  5. package/dist/cli/{curation-policy-j12j2gvc.js → curation-policy-a2zty4br.js} +5 -5
  6. package/dist/cli/{curator-3m8a8qsn.js → curator-4pckmmyf.js} +32 -32
  7. package/dist/cli/{curator-drift-g6w4ga1q.js → curator-drift-wy7ejcvw.js} +105 -37
  8. package/dist/cli/{curator-llm-factory-p00hks4v.js → curator-llm-factory-msbj3hpn.js} +32 -32
  9. package/dist/cli/{evidence-summary-service-4ghqakhx.js → evidence-summary-service-b15yes21.js} +14 -14
  10. package/dist/cli/{gate-evidence-4v8apasx.js → gate-evidence-70h0w4tb.js} +5 -5
  11. package/dist/cli/{guardrail-explain-smqenqtm.js → guardrail-explain-kksdy032.js} +33 -33
  12. package/dist/cli/{guardrail-log-mmh4b4k4.js → guardrail-log-7rxbd20p.js} +6 -6
  13. package/dist/cli/{guardrail-reset-zge5hg4p.js → guardrail-reset-3b4gs357.js} +32 -32
  14. package/dist/cli/{hive-promoter-vxez5s7m.js → hive-promoter-s80g1gwb.js} +32 -32
  15. package/dist/cli/index-0515j0cz.js +403 -0
  16. package/dist/cli/{index-t4hs3qk6.js → index-12f1tsn2.js} +3 -3
  17. package/dist/cli/{index-2zgjcmmc.js → index-1b1h770t.js} +3 -3
  18. package/dist/cli/{index-9ss2m4rs.js → index-1hpjwz3s.js} +410 -1
  19. package/dist/cli/{index-4t68xs0p.js → index-1z4jzwja.js} +3 -3
  20. package/dist/cli/{index-0103w5pf.js → index-2s4s9n82.js} +2 -2
  21. package/dist/cli/{index-9crtmnqg.js → index-36nt17m8.js} +1 -1
  22. package/dist/cli/{index-qy2rm1f6.js → index-4afh2cz7.js} +5 -5
  23. package/dist/cli/{index-pykfqsk0.js → index-4jersar8.js} +4 -4
  24. package/dist/cli/{index-n67vx5zw.js → index-70bfj3v1.js} +1 -1
  25. package/dist/cli/{index-eqkdjfqa.js → index-7r9vpkwa.js} +4 -4
  26. package/dist/cli/{index-8ada7ag7.js → index-93sepnc9.js} +2 -2
  27. package/dist/cli/{index-s8c6f9rr.js → index-9sy65e94.js} +3 -3
  28. package/dist/cli/{index-ptsmms01.js → index-bm73pych.js} +6 -6
  29. package/dist/cli/{index-xyhmt813.js → index-c4pynht5.js} +1 -1
  30. package/dist/cli/{index-w1mc7gcm.js → index-c69jbpex.js} +2 -2
  31. package/dist/cli/{index-axx3t3k7.js → index-e3hwzcjv.js} +2 -2
  32. package/dist/cli/{index-453tzvkg.js → index-g64154pd.js} +1 -1
  33. package/dist/cli/{index-f7t5fn4z.js → index-gxd8fwyt.js} +4 -4
  34. package/dist/cli/{index-5hgn302x.js → index-hyq20s2v.js} +118 -296
  35. package/dist/cli/{index-7n9jznv0.js → index-ma8w6pfp.js} +3 -3
  36. package/dist/cli/{index-rqh25ns3.js → index-nhxaa9j5.js} +1 -1
  37. package/dist/cli/{index-zgz81a8x.js → index-nzrhw31r.js} +1 -1
  38. package/dist/cli/{index-4xggfhge.js → index-pvgcex0d.js} +3 -3
  39. package/dist/cli/{index-nwa7ctyf.js → index-qkk2skff.js} +34 -34
  40. package/dist/cli/{index-g4bvsapf.js → index-t5t82jy8.js} +5 -5
  41. package/dist/cli/{index-m4nhy4fp.js → index-t90gjc0k.js} +1 -1
  42. package/dist/cli/{index-3rjxbe1p.js → index-t9rhtvy9.js} +2 -2
  43. package/dist/cli/{index-hm239n1p.js → index-tb1k8jya.js} +1 -1
  44. package/dist/cli/{index-m7yt3xmk.js → index-td6n935w.js} +3 -2
  45. package/dist/cli/{index-w0yn4rmh.js → index-v3a9rmyh.js} +3 -3
  46. package/dist/cli/{index-cqgpvx2d.js → index-wdtckfnf.js} +1 -1
  47. package/dist/cli/{index-7wb2v7jg.js → index-xk0kc1py.js} +522 -358
  48. package/dist/cli/{index-n2mhyect.js → index-ynqp3jb6.js} +1 -1
  49. package/dist/cli/{index-n249fbw7.js → index-zaab1wz9.js} +5 -0
  50. package/dist/cli/{index-3ab9tczn.js → index-zbpcpsk0.js} +8 -8
  51. package/dist/cli/index.js +32 -32
  52. package/dist/cli/{knowledge-escalator-91d1n291.js → knowledge-escalator-sttdnwf8.js} +11 -11
  53. package/dist/cli/{knowledge-events-xrd9es3p.js → knowledge-events-4h88stj7.js} +9 -9
  54. package/dist/cli/{knowledge-link-vmdj5e5d.js → knowledge-link-yykmxdyw.js} +4 -4
  55. package/dist/cli/{knowledge-store-2brg88cx.js → knowledge-store-j832fxpx.js} +5 -5
  56. package/dist/cli/{knowledge-validator-s1v7kry2.js → knowledge-validator-edbg761g.js} +7 -7
  57. package/dist/cli/{pending-delegations-b341397j.js → pending-delegations-sphntrs0.js} +4 -4
  58. package/dist/cli/{pr-subscriptions-2mkdt0ak.js → pr-subscriptions-1a4gcnzv.js} +4 -4
  59. package/dist/cli/{runner-3gw2njnx.js → runner-d294h1by.js} +5 -5
  60. package/dist/cli/{scan-cursor-jm7j3w1c.js → scan-cursor-5frvp7nb.js} +6 -6
  61. package/dist/cli/{schema-6cpgnq4s.js → schema-9xkt5hvd.js} +1 -1
  62. package/dist/cli/{scope-persistence-q713ck5n.js → scope-persistence-gk55h3sp.js} +8 -8
  63. package/dist/cli/{skill-generator-z9bs6vdt.js → skill-generator-sxxf7jbb.js} +13 -13
  64. package/dist/cli/{sqlite-loader-c92413n7.js → sqlite-loader-8zefc142.js} +1 -1
  65. package/dist/cli/{telemetry-x4zggfd7.js → telemetry-q51s6tyt.js} +1 -1
  66. package/dist/cli/{worktree-collision-ownership-drtv7jjp.js → worktree-collision-ownership-7kj2ryt1.js} +4 -4
  67. package/dist/cli/{worktree-isolation-534h3c2f.js → worktree-isolation-67fs6rz9.js} +32 -32
  68. package/dist/db/canonical-project.d.ts +31 -0
  69. package/dist/db/db-errors.d.ts +24 -0
  70. package/dist/db/driver-parity.d.ts +31 -0
  71. package/dist/db/durability.d.ts +40 -0
  72. package/dist/db/group-commit-writer.d.ts +117 -0
  73. package/dist/db/health.d.ts +35 -0
  74. package/dist/db/insight-candidate-store.d.ts +61 -0
  75. package/dist/db/legacy-import.d.ts +77 -0
  76. package/dist/db/phase-report-store.d.ts +45 -0
  77. package/dist/db/project-db.d.ts +35 -8
  78. package/dist/db/qa-gate-profile.d.ts +2 -0
  79. package/dist/hooks/curator-drift.d.ts +9 -5
  80. package/dist/hooks/curator-types.d.ts +1 -0
  81. package/dist/hooks/knowledge-curator.d.ts +5 -3
  82. package/dist/hooks/micro-reflector.d.ts +12 -7
  83. package/dist/index.js +619 -567
  84. package/dist/memory/schema.d.ts +4 -4
  85. package/dist/prm/index.d.ts +3 -1
  86. package/package.json +3 -2
  87. package/dist/cli/index-c8s9a3zh.js +0 -73
@@ -1,4 +1,7 @@
1
1
  // @bun
2
+ import {
3
+ loadDatabaseCtor
4
+ } from "./index-zaab1wz9.js";
2
5
  import {
3
6
  validateSpecContent
4
7
  } from "./index-n832052r.js";
@@ -6,6 +9,9 @@ import {
6
9
  advisoryWarn,
7
10
  init_warning_buffer
8
11
  } from "./index-4rhhvd1a.js";
12
+ import {
13
+ atomicWriteSwarmFileSync
14
+ } from "./index-3b762978.js";
9
15
 
10
16
  // src/sdd/effective-spec.ts
11
17
  import { createHash } from "crypto";
@@ -691,4 +697,407 @@ function validateSpeckit(directory, options = {}) {
691
697
  return { resolution, problems };
692
698
  }
693
699
 
694
- export { detectSpeckit, resolveSpeckitProjection, loadSddStatusSync, buildOpenSpecProjectionSync, readEffectiveSpecSync, writeProjectedSpecSync, validateSpeckit };
700
+ // src/db/durability.ts
701
+ var DURABILITY_CLASSES = {
702
+ qa_gate_profile: "full",
703
+ qa_gate_profile_identity: "full",
704
+ task_checkpoint_receipt: "full",
705
+ insight_candidate: "normal",
706
+ phase_report: "normal",
707
+ project_constraints: "normal",
708
+ migration_failures: "normal",
709
+ schema_migrations: "normal"
710
+ };
711
+ function batchDurabilityClass(classes) {
712
+ for (const cls of classes) {
713
+ if (cls === "full")
714
+ return "full";
715
+ }
716
+ return "normal";
717
+ }
718
+ function applySynchronousForClass(db, cls) {
719
+ db.run(cls === "full" ? "PRAGMA synchronous = FULL;" : "PRAGMA synchronous = NORMAL;");
720
+ }
721
+ function withDurabilityClass(db, cls, fn) {
722
+ applySynchronousForClass(db, cls);
723
+ try {
724
+ return fn();
725
+ } finally {
726
+ applySynchronousForClass(db, "normal");
727
+ }
728
+ }
729
+
730
+ // src/db/canonical-project.ts
731
+ import { realpathSync } from "fs";
732
+ import { resolve as resolve2 } from "path";
733
+ var _internals = {
734
+ realpathSync
735
+ };
736
+ function canonicalProjectKey(directory) {
737
+ const lexical = resolve2(directory);
738
+ let canonical;
739
+ try {
740
+ canonical = _internals.realpathSync(lexical);
741
+ } catch {
742
+ canonical = lexical;
743
+ }
744
+ return process.platform === "win32" ? canonical.toLowerCase() : canonical;
745
+ }
746
+
747
+ // src/db/project-db.ts
748
+ import { existsSync as existsSync2, mkdirSync as mkdirSync2, unlinkSync } from "fs";
749
+ import { join as join2, resolve as resolve3 } from "path";
750
+
751
+ // src/db/db-errors.ts
752
+ class ProjectDbError extends Error {
753
+ category;
754
+ constructor(category, message) {
755
+ super(message);
756
+ this.name = "ProjectDbError";
757
+ this.category = category;
758
+ }
759
+ }
760
+
761
+ class DbWriteError extends Error {
762
+ category;
763
+ constructor(category, message) {
764
+ super(message);
765
+ this.name = "DbWriteError";
766
+ this.category = category;
767
+ }
768
+ }
769
+ function classifyDbWriteError(err) {
770
+ const errno = err?.code;
771
+ if (errno === "ENOSPC")
772
+ return "disk_full";
773
+ if (errno === "EACCES" || errno === "EROFS" || errno === "EPERM")
774
+ return "read_only";
775
+ const message = err instanceof Error ? err.message : String(err);
776
+ const upper = message.toUpperCase();
777
+ if (upper.includes("SQLITE_FULL") || upper.includes("DATABASE OR DISK IS FULL")) {
778
+ return "disk_full";
779
+ }
780
+ if (upper.includes("SQLITE_READONLY") || upper.includes("ATTEMPT TO WRITE A READONLY")) {
781
+ return "read_only";
782
+ }
783
+ if (upper.includes("SQLITE_CORRUPT") || upper.includes("DATABASE DISK IMAGE IS MALFORMED") || upper.includes("NOT A DATABASE")) {
784
+ return "corrupt";
785
+ }
786
+ if (upper.includes("SQLITE_BUSY") || upper.includes("DATABASE IS LOCKED")) {
787
+ return "busy";
788
+ }
789
+ return "unknown";
790
+ }
791
+
792
+ // src/db/project-db.ts
793
+ var MIGRATION_FAILURE_ERROR_MAX_CHARS = 500;
794
+ var MIGRATION_FAILURE_MARKER = "db-migration-failure.json";
795
+ var MIGRATIONS = [
796
+ {
797
+ version: 1,
798
+ name: "create_project_constraints",
799
+ sql: `CREATE TABLE project_constraints (
800
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
801
+ constraint_type TEXT NOT NULL,
802
+ content TEXT NOT NULL,
803
+ created_at TEXT NOT NULL DEFAULT (datetime('now'))
804
+ )`
805
+ },
806
+ {
807
+ version: 2,
808
+ name: "create_qa_gate_profile",
809
+ sql: `CREATE TABLE qa_gate_profile (
810
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
811
+ plan_id TEXT NOT NULL UNIQUE,
812
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
813
+ project_type TEXT,
814
+ gates TEXT NOT NULL DEFAULT '{}',
815
+ locked_at TEXT,
816
+ locked_by_snapshot_seq INTEGER
817
+ )`
818
+ },
819
+ {
820
+ version: 3,
821
+ name: "create_qa_gate_profile_immutability_trigger",
822
+ sql: `CREATE TRIGGER IF NOT EXISTS trg_qa_gate_profile_no_update_after_lock
823
+ BEFORE UPDATE ON qa_gate_profile
824
+ WHEN OLD.locked_at IS NOT NULL
825
+ BEGIN
826
+ SELECT RAISE(ABORT, 'qa_gate_profile row is locked and cannot be modified after critic approval');
827
+ END`
828
+ },
829
+ {
830
+ version: 4,
831
+ name: "add_qa_gate_profile_raw_swarm",
832
+ sql: "ALTER TABLE qa_gate_profile ADD COLUMN raw_swarm TEXT"
833
+ },
834
+ {
835
+ version: 5,
836
+ name: "add_qa_gate_profile_raw_title",
837
+ sql: "ALTER TABLE qa_gate_profile ADD COLUMN raw_title TEXT"
838
+ },
839
+ {
840
+ version: 6,
841
+ name: "add_qa_gate_profile_identity_hash",
842
+ sql: "ALTER TABLE qa_gate_profile ADD COLUMN identity_hash TEXT"
843
+ },
844
+ {
845
+ version: 7,
846
+ name: "create_qa_gate_profile_identity_hash_index",
847
+ sql: `CREATE UNIQUE INDEX IF NOT EXISTS idx_qa_gate_profile_identity_hash
848
+ ON qa_gate_profile(identity_hash)
849
+ WHERE identity_hash IS NOT NULL`
850
+ },
851
+ {
852
+ version: 8,
853
+ name: "create_qa_gate_profile_identity",
854
+ sql: `CREATE TABLE qa_gate_profile_identity (
855
+ identity_hash TEXT PRIMARY KEY,
856
+ profile_id INTEGER NOT NULL UNIQUE REFERENCES qa_gate_profile(id) ON DELETE CASCADE,
857
+ raw_swarm TEXT NOT NULL,
858
+ raw_title TEXT NOT NULL,
859
+ readable_plan_id TEXT NOT NULL
860
+ )`
861
+ },
862
+ {
863
+ version: 9,
864
+ name: "create_qa_gate_profile_identity_readable_plan_index",
865
+ sql: `CREATE INDEX idx_qa_gate_profile_identity_readable_plan_id
866
+ ON qa_gate_profile_identity(readable_plan_id)`
867
+ },
868
+ {
869
+ version: 10,
870
+ name: "backfill_qa_gate_profile_identity_from_legacy_columns",
871
+ sql: `INSERT INTO qa_gate_profile_identity (
872
+ identity_hash,
873
+ profile_id,
874
+ raw_swarm,
875
+ raw_title,
876
+ readable_plan_id
877
+ )
878
+ SELECT
879
+ identity_hash,
880
+ id,
881
+ raw_swarm,
882
+ raw_title,
883
+ plan_id
884
+ FROM qa_gate_profile
885
+ WHERE identity_hash IS NOT NULL
886
+ AND raw_swarm IS NOT NULL
887
+ AND raw_title IS NOT NULL
888
+ AND NOT EXISTS (
889
+ SELECT 1
890
+ FROM qa_gate_profile_identity AS qi
891
+ WHERE qi.profile_id = qa_gate_profile.id
892
+ )`
893
+ },
894
+ {
895
+ version: 11,
896
+ name: "create_task_checkpoint_receipt",
897
+ sql: `CREATE TABLE task_checkpoint_receipt (
898
+ plan_identity_hash TEXT NOT NULL,
899
+ task_id TEXT NOT NULL,
900
+ label TEXT NOT NULL,
901
+ state TEXT NOT NULL CHECK(state IN ('pending', 'committed', 'logged')),
902
+ sha TEXT,
903
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
904
+ updated_at TEXT NOT NULL DEFAULT (datetime('now')),
905
+ PRIMARY KEY(plan_identity_hash, task_id)
906
+ )`
907
+ },
908
+ {
909
+ version: 12,
910
+ name: "add_task_checkpoint_receipt_completion_generation",
911
+ sql: `ALTER TABLE task_checkpoint_receipt
912
+ ADD COLUMN generation INTEGER NOT NULL DEFAULT 1;
913
+ ALTER TABLE task_checkpoint_receipt
914
+ ADD COLUMN completion_active INTEGER NOT NULL DEFAULT 1
915
+ CHECK(completion_active IN (0, 1))`
916
+ },
917
+ {
918
+ version: 13,
919
+ name: "bind_task_checkpoint_receipt_to_completion_ledger_seq",
920
+ sql: `ALTER TABLE task_checkpoint_receipt
921
+ ADD COLUMN completion_ledger_seq INTEGER
922
+ CHECK(completion_ledger_seq IS NULL OR completion_ledger_seq >= 0)`
923
+ },
924
+ {
925
+ version: 14,
926
+ name: "create_migration_failures",
927
+ sql: `CREATE TABLE IF NOT EXISTS migration_failures (
928
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
929
+ version INTEGER NOT NULL,
930
+ name TEXT NOT NULL,
931
+ error TEXT NOT NULL,
932
+ failed_at TEXT NOT NULL DEFAULT (datetime('now'))
933
+ )`
934
+ },
935
+ {
936
+ version: 15,
937
+ name: "create_insight_candidate_stream",
938
+ sql: `CREATE TABLE IF NOT EXISTS insight_candidate (
939
+ stream_id TEXT NOT NULL,
940
+ version INTEGER NOT NULL,
941
+ payload TEXT NOT NULL,
942
+ created_at TEXT NOT NULL,
943
+ consumed_at TEXT,
944
+ PRIMARY KEY(stream_id, version)
945
+ )`
946
+ },
947
+ {
948
+ version: 16,
949
+ name: "create_insight_candidate_pending_index",
950
+ sql: `CREATE INDEX IF NOT EXISTS idx_insight_candidate_pending
951
+ ON insight_candidate(stream_id, version)
952
+ WHERE consumed_at IS NULL`
953
+ },
954
+ {
955
+ version: 17,
956
+ name: "create_phase_report",
957
+ sql: `CREATE TABLE IF NOT EXISTS phase_report (
958
+ kind TEXT NOT NULL CHECK(kind IN ('curator_drift', 'design_doc_drift')),
959
+ phase INTEGER NOT NULL,
960
+ payload TEXT NOT NULL,
961
+ updated_at TEXT NOT NULL DEFAULT (datetime('now')),
962
+ PRIMARY KEY(kind, phase)
963
+ )`
964
+ }
965
+ ];
966
+ var _projectDbs = new Map;
967
+ function recordMigrationFailure(db, migration, err, markerDir) {
968
+ const errorText = String(err instanceof Error ? err.message : err).slice(0, MIGRATION_FAILURE_ERROR_MAX_CHARS);
969
+ try {
970
+ db.run("INSERT INTO migration_failures (version, name, error) VALUES (?, ?, ?)", [migration.version, migration.name, errorText]);
971
+ return;
972
+ } catch {}
973
+ if (!markerDir)
974
+ return;
975
+ try {
976
+ atomicWriteSwarmFileSync(join2(markerDir, MIGRATION_FAILURE_MARKER), JSON.stringify({
977
+ schema_version: 1,
978
+ version: migration.version,
979
+ name: migration.name,
980
+ error: errorText,
981
+ failed_at: new Date().toISOString()
982
+ }, null, 2));
983
+ } catch {}
984
+ }
985
+ function removeMigrationFailureMarker(markerDir) {
986
+ const marker = join2(markerDir, MIGRATION_FAILURE_MARKER);
987
+ if (!existsSync2(marker))
988
+ return;
989
+ try {
990
+ unlinkSync(marker);
991
+ } catch {}
992
+ }
993
+ function isConcurrentMigrationApply(err) {
994
+ const msg = (err instanceof Error ? err.message : String(err)).toLowerCase();
995
+ if (msg.includes("unique constraint failed: schema_migrations"))
996
+ return true;
997
+ return msg.includes("already exists") && (msg.includes("table") || msg.includes("index") || msg.includes("trigger"));
998
+ }
999
+ function currentVersionNowCovers(db, version) {
1000
+ const row = db.query("SELECT MAX(version) as version FROM schema_migrations").get();
1001
+ return (row?.version ?? 0) >= version;
1002
+ }
1003
+ function runProjectMigrations(db, markerDir) {
1004
+ db.run(`CREATE TABLE IF NOT EXISTS schema_migrations (
1005
+ version INTEGER PRIMARY KEY,
1006
+ name TEXT NOT NULL,
1007
+ applied_at TEXT NOT NULL DEFAULT (datetime('now'))
1008
+ )`);
1009
+ const row = db.query("SELECT MAX(version) as version FROM schema_migrations").get();
1010
+ const currentVersion = row?.version ?? 0;
1011
+ for (const migration of MIGRATIONS) {
1012
+ if (migration.version <= currentVersion)
1013
+ continue;
1014
+ const apply = db.transaction(() => {
1015
+ db.run(migration.sql);
1016
+ db.run("INSERT INTO schema_migrations (version, name) VALUES (?, ?)", [
1017
+ migration.version,
1018
+ migration.name
1019
+ ]);
1020
+ });
1021
+ try {
1022
+ apply();
1023
+ } catch (err) {
1024
+ if (isConcurrentMigrationApply(err) && currentVersionNowCovers(db, migration.version)) {
1025
+ continue;
1026
+ }
1027
+ recordMigrationFailure(db, migration, err, markerDir);
1028
+ throw new ProjectDbError("migration_failed", `swarm.db migration v${migration.version} (${migration.name}) failed: ${err instanceof Error ? err.message : String(err)}`);
1029
+ }
1030
+ }
1031
+ if (markerDir)
1032
+ removeMigrationFailureMarker(markerDir);
1033
+ }
1034
+ function projectDbPath(directory) {
1035
+ return join2(resolve3(directory), ".swarm", "swarm.db");
1036
+ }
1037
+ function projectDbExists(directory) {
1038
+ return existsSync2(join2(canonicalProjectKey(directory), ".swarm", "swarm.db"));
1039
+ }
1040
+ function checkpointWalBestEffort(db) {
1041
+ try {
1042
+ const row = db.query("PRAGMA wal_checkpoint(TRUNCATE)").get();
1043
+ if (row && row.busy === 1) {
1044
+ db.run("PRAGMA wal_checkpoint(PASSIVE);");
1045
+ }
1046
+ } catch {
1047
+ try {
1048
+ db.run("PRAGMA wal_checkpoint(PASSIVE);");
1049
+ } catch {}
1050
+ }
1051
+ }
1052
+ function getProjectDb(directory) {
1053
+ const key = canonicalProjectKey(directory);
1054
+ const existing = _projectDbs.get(key);
1055
+ if (existing)
1056
+ return existing;
1057
+ const swarmDir = join2(key, ".swarm");
1058
+ try {
1059
+ mkdirSync2(swarmDir, { recursive: true });
1060
+ } catch (err) {
1061
+ throw new ProjectDbError("mkdir_failed", `Failed to create .swarm/ for project ${key}: ${err instanceof Error ? err.message : String(err)}`);
1062
+ }
1063
+ let db;
1064
+ try {
1065
+ let Db;
1066
+ try {
1067
+ Db = loadDatabaseCtor();
1068
+ } catch (err) {
1069
+ throw new ProjectDbError("driver_unavailable", `Failed to resolve a SQLite driver for project ${key}: ${err instanceof Error ? err.message : String(err)}`);
1070
+ }
1071
+ db = new Db(join2(swarmDir, "swarm.db"));
1072
+ db.run("PRAGMA journal_mode = WAL;");
1073
+ db.run("PRAGMA synchronous = NORMAL;");
1074
+ db.run("PRAGMA busy_timeout = 5000;");
1075
+ db.run("PRAGMA foreign_keys = ON;");
1076
+ runProjectMigrations(db, swarmDir);
1077
+ } catch (err) {
1078
+ if (db) {
1079
+ try {
1080
+ db.close();
1081
+ } catch {}
1082
+ }
1083
+ if (err instanceof ProjectDbError)
1084
+ throw err;
1085
+ throw new ProjectDbError("open_failed", `Failed to open .swarm/swarm.db for project ${key}: ${err instanceof Error ? err.message : String(err)}`);
1086
+ }
1087
+ _projectDbs.set(key, db);
1088
+ return db;
1089
+ }
1090
+ function closeProjectDb(directory) {
1091
+ const key = canonicalProjectKey(directory);
1092
+ const db = _projectDbs.get(key);
1093
+ if (db) {
1094
+ checkpointWalBestEffort(db);
1095
+ try {
1096
+ db.close();
1097
+ } finally {
1098
+ _projectDbs.delete(key);
1099
+ }
1100
+ }
1101
+ }
1102
+
1103
+ export { DURABILITY_CLASSES, batchDurabilityClass, applySynchronousForClass, withDurabilityClass, canonicalProjectKey, DbWriteError, classifyDbWriteError, projectDbPath, projectDbExists, getProjectDb, closeProjectDb, detectSpeckit, resolveSpeckitProjection, loadSddStatusSync, buildOpenSpecProjectionSync, readEffectiveSpecSync, writeProjectedSpecSync, validateSpeckit };
@@ -4,14 +4,14 @@ import {
4
4
  PlanSchema,
5
5
  TaskStatusSchema,
6
6
  init_loader
7
- } from "./index-rqh25ns3.js";
7
+ } from "./index-nhxaa9j5.js";
8
8
  import {
9
9
  assertProjectRoot,
10
10
  withEvidenceLock
11
- } from "./index-9crtmnqg.js";
11
+ } from "./index-36nt17m8.js";
12
12
  import {
13
13
  emit
14
- } from "./index-2zgjcmmc.js";
14
+ } from "./index-1b1h770t.js";
15
15
  import {
16
16
  criticalWarn,
17
17
  init_logger,
@@ -9,11 +9,11 @@ import {
9
9
  } from "./index-txdagbh7.js";
10
10
  import {
11
11
  atomicWriteFile
12
- } from "./index-n67vx5zw.js";
12
+ } from "./index-70bfj3v1.js";
13
13
  import {
14
14
  assertProjectRoot,
15
15
  withEvidenceLock
16
- } from "./index-9crtmnqg.js";
16
+ } from "./index-36nt17m8.js";
17
17
  import {
18
18
  exports_external,
19
19
  init_zod
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  emit
4
- } from "./index-2zgjcmmc.js";
4
+ } from "./index-1b1h770t.js";
5
5
  import {
6
6
  require_proper_lockfile
7
7
  } from "./index-7g4c7s5r.js";
@@ -13,13 +13,13 @@ import {
13
13
  reconcileLandedMerge,
14
14
  withTaskEvidenceTransaction,
15
15
  writeWorkflowWalFile
16
- } from "./index-eqkdjfqa.js";
16
+ } from "./index-7r9vpkwa.js";
17
17
  import {
18
18
  canonicalRootKeyFresh
19
19
  } from "./index-ddszzne4.js";
20
20
  import {
21
21
  appendCoreEventSync
22
- } from "./index-8ada7ag7.js";
22
+ } from "./index-93sepnc9.js";
23
23
  import {
24
24
  isPathWithinDeclaredScope
25
25
  } from "./index-556ja8an.js";
@@ -36,7 +36,7 @@ import {
36
36
  } from "./index-4rhhvd1a.js";
37
37
  import {
38
38
  tryAcquireLock
39
- } from "./index-9crtmnqg.js";
39
+ } from "./index-36nt17m8.js";
40
40
  import {
41
41
  criticalWarn,
42
42
  init_logger
@@ -478,7 +478,7 @@ async function cleanupRecoveredWorktree(directory, descriptor) {
478
478
  awaitingMergeByCallID,
479
479
  cleanupStandardWorktreeForCallId,
480
480
  standardWorktreeByCallID
481
- } = await import("./worktree-isolation-534h3c2f.js");
481
+ } = await import("./worktree-isolation-67fs6rz9.js");
482
482
  standardWorktreeByCallID.delete(descriptor.callID);
483
483
  if (hasResidue)
484
484
  awaitingMergeByCallID.set(descriptor.callID, {
@@ -602,7 +602,7 @@ async function recoverCoderSettlement(directory, taskId) {
602
602
  awaitingMergeByCallID,
603
603
  finishStandardWorktreeDispatch,
604
604
  standardWorktreeByCallID
605
- } = await import("./worktree-isolation-534h3c2f.js");
605
+ } = await import("./worktree-isolation-67fs6rz9.js");
606
606
  const descriptor = wal.worktree;
607
607
  const reconstructedDispatch = {
608
608
  callID: descriptor.callID,
@@ -2,19 +2,19 @@
2
2
  import {
3
3
  computePlanStructureHash,
4
4
  derivePlanId
5
- } from "./index-4t68xs0p.js";
5
+ } from "./index-1z4jzwja.js";
6
6
  import {
7
7
  appendCoreEventSync
8
- } from "./index-8ada7ag7.js";
8
+ } from "./index-93sepnc9.js";
9
9
  import {
10
10
  unsafePathTextReason
11
11
  } from "./index-556ja8an.js";
12
12
  import {
13
13
  PlanSchema
14
- } from "./index-rqh25ns3.js";
14
+ } from "./index-nhxaa9j5.js";
15
15
  import {
16
16
  assertProjectRoot
17
- } from "./index-9crtmnqg.js";
17
+ } from "./index-36nt17m8.js";
18
18
  import {
19
19
  atomicWriteSwarmFile,
20
20
  atomicWriteSwarmFileSync
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  withEvidenceLock
4
- } from "./index-9crtmnqg.js";
4
+ } from "./index-36nt17m8.js";
5
5
  import {
6
6
  atomicWriteFileAnyRoot
7
7
  } from "./index-3b762978.js";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  autoCommitDirty,
4
4
  cleanUntrackedFiles
5
- } from "./index-zgz81a8x.js";
5
+ } from "./index-nzrhw31r.js";
6
6
  import {
7
7
  isPathWithinDeclaredScope,
8
8
  unsafePathTextReason
@@ -26,13 +26,13 @@ import {
26
26
  atomicWriteFile,
27
27
  taskEvidencePath,
28
28
  withTaskEvidenceLock
29
- } from "./index-n67vx5zw.js";
29
+ } from "./index-70bfj3v1.js";
30
30
  import {
31
31
  assertProjectRoot
32
- } from "./index-9crtmnqg.js";
32
+ } from "./index-36nt17m8.js";
33
33
  import {
34
34
  telemetry
35
- } from "./index-2zgjcmmc.js";
35
+ } from "./index-1b1h770t.js";
36
36
  import {
37
37
  exports_external,
38
38
  init_zod
@@ -1,10 +1,10 @@
1
1
  // @bun
2
2
  import {
3
3
  observeStoreHealth
4
- } from "./index-cqgpvx2d.js";
4
+ } from "./index-wdtckfnf.js";
5
5
  import {
6
6
  telemetry
7
- } from "./index-2zgjcmmc.js";
7
+ } from "./index-1b1h770t.js";
8
8
  import {
9
9
  init_logger,
10
10
  warn
@@ -11,16 +11,16 @@ import {
11
11
  import {
12
12
  init_schema,
13
13
  stripKnownSwarmPrefix
14
- } from "./index-m7yt3xmk.js";
14
+ } from "./index-td6n935w.js";
15
15
  import {
16
16
  observeStoreHealth
17
- } from "./index-cqgpvx2d.js";
17
+ } from "./index-wdtckfnf.js";
18
18
  import {
19
19
  init_constants
20
20
  } from "./index-9xd073d4.js";
21
21
  import {
22
22
  telemetry
23
- } from "./index-2zgjcmmc.js";
23
+ } from "./index-1b1h770t.js";
24
24
  import {
25
25
  init_logger,
26
26
  warn
@@ -6,10 +6,10 @@ import {
6
6
  } from "./index-ae75rja9.js";
7
7
  import {
8
8
  resolveKnowledgeStoreDir
9
- } from "./index-n2mhyect.js";
9
+ } from "./index-ynqp3jb6.js";
10
10
  import {
11
11
  atomicWriteFile
12
- } from "./index-n67vx5zw.js";
12
+ } from "./index-70bfj3v1.js";
13
13
  import {
14
14
  init_knowledge_types,
15
15
  isActiveStatus
@@ -713,7 +713,7 @@ async function applyConfidenceFloorAction(directory, touched, options) {
713
713
  const {
714
714
  readAuthoritativeKnowledgeCounterRollups,
715
715
  effectiveRetrievalOutcomes
716
- } = await import("./knowledge-events-xrd9es3p.js");
716
+ } = await import("./knowledge-events-4h88stj7.js");
717
717
  const rollups = await readAuthoritativeKnowledgeCounterRollups(directory);
718
718
  const flagIds = new Set;
719
719
  for (const e of atFloor) {
@@ -780,11 +780,11 @@ async function applyConfidenceFloorAction(directory, touched, options) {
780
780
  });
781
781
  }
782
782
  if (action === "quarantine" && toQuarantine.length > 0) {
783
- const { quarantineEntry } = await import("./knowledge-validator-s1v7kry2.js");
784
- const { KnowledgeConfigSchema } = await import("./schema-6cpgnq4s.js");
783
+ const { quarantineEntry } = await import("./knowledge-validator-edbg761g.js");
784
+ const { KnowledgeConfigSchema } = await import("./schema-9xkt5hvd.js");
785
785
  let config;
786
786
  try {
787
- const { loadPluginConfigWithMeta } = await import("./index-w0yn4rmh.js");
787
+ const { loadPluginConfigWithMeta } = await import("./index-v3a9rmyh.js");
788
788
  const { config: loadedConfig } = loadPluginConfigWithMeta(directory);
789
789
  config = KnowledgeConfigSchema.parse(loadedConfig.knowledge ?? {});
790
790
  } catch {
@@ -9,7 +9,7 @@ import {
9
9
  readEvaluationRun,
10
10
  saveEvaluationRun,
11
11
  saveTaskSetSnapshot
12
- } from "./index-0103w5pf.js";
12
+ } from "./index-2s4s9n82.js";
13
13
  import {
14
14
  canonicalHash,
15
15
  computeCandidateInputContentHash,
@@ -14,14 +14,14 @@ import {
14
14
  detectWindowsWrites,
15
15
  getSharedClassifierGuardrailBlock,
16
16
  resolveWriteTargets
17
- } from "./index-7wb2v7jg.js";
17
+ } from "./index-xk0kc1py.js";
18
18
  import {
19
19
  checkFileAuthority,
20
20
  classifyFile,
21
21
  isInDeclaredScope,
22
22
  redactPath,
23
23
  redactShellCommand
24
- } from "./index-s8c6f9rr.js";
24
+ } from "./index-9sy65e94.js";
25
25
 
26
26
  // src/services/guardrail-explain-service.ts
27
27
  import path from "path";
@@ -2,14 +2,14 @@
2
2
  import {
3
3
  readKnowledge,
4
4
  transactKnowledge
5
- } from "./index-ptsmms01.js";
5
+ } from "./index-bm73pych.js";
6
6
  import {
7
7
  init_git_executable,
8
8
  resolveGitExecutableAsync
9
9
  } from "./index-9e6fdz2h.js";
10
10
  import {
11
11
  resolveKnowledgeStoreDir
12
- } from "./index-n2mhyect.js";
12
+ } from "./index-ynqp3jb6.js";
13
13
  import {
14
14
  init_knowledge_types,
15
15
  isActiveStatus