@bongos/core 1.19.873 → 1.19.875

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.
@@ -3,9 +3,9 @@
3
3
  "generator": "scripts/gds/copy-inventory.js",
4
4
  "goal": 1000074,
5
5
  "counts": {
6
- "strings": 1903,
7
- "unique_ids": 1647,
8
- "certain": 1903,
6
+ "strings": 1912,
7
+ "unique_ids": 1656,
8
+ "certain": 1912,
9
9
  "heuristic": 0,
10
10
  "duplicate_ids": 175
11
11
  },
@@ -13,7 +13,7 @@
13
13
  "builders-hall": {
14
14
  "at": "modules/hall-ui/public",
15
15
  "files": 89,
16
- "strings": 1413
16
+ "strings": 1422
17
17
  },
18
18
  "status-dashboard": {
19
19
  "at": "modules/status-ui/public",
@@ -174,7 +174,7 @@
174
174
  "occurrences": 5,
175
175
  "at": [
176
176
  "modules/hall-ui/public/board-room.js:433",
177
- "modules/hall-ui/public/gate.js:219",
177
+ "modules/hall-ui/public/gate.js:234",
178
178
  "modules/hall-ui/public/government.js:879",
179
179
  "modules/hall-ui/public/harbor.js:337",
180
180
  "modules/hall-ui/public/watch.js:1306"
@@ -199,7 +199,7 @@
199
199
  "text": "task {…}",
200
200
  "occurrences": 5,
201
201
  "at": [
202
- "modules/hall-ui/public/gate.js:142",
202
+ "modules/hall-ui/public/gate.js:157",
203
203
  "modules/hall-ui/public/hall-render.js:669",
204
204
  "modules/hall-ui/public/idea.js:207",
205
205
  "modules/hall-ui/public/ideas.js:476",
@@ -308,7 +308,7 @@
308
308
  "text": "Available from the {…} rank up.",
309
309
  "occurrences": 3,
310
310
  "at": [
311
- "modules/hall-ui/public/gate.js:222",
311
+ "modules/hall-ui/public/gate.js:237",
312
312
  "modules/hall-ui/public/government.js:882",
313
313
  "modules/hall-ui/public/harbor.js:340"
314
314
  ]
@@ -1075,8 +1075,8 @@
1075
1075
  "text": "Move to {…}",
1076
1076
  "occurrences": 2,
1077
1077
  "at": [
1078
- "modules/hall-ui/public/deploy.js:103",
1079
- "modules/hall-ui/public/deploy.js:161"
1078
+ "modules/hall-ui/public/deploy.js:122",
1079
+ "modules/hall-ui/public/deploy.js:217"
1080
1080
  ]
1081
1081
  },
1082
1082
  {
@@ -2047,7 +2047,7 @@
2047
2047
  "surface": "builders-hall",
2048
2048
  "text": "+{…} more",
2049
2049
  "file": "modules/hall-ui/public/gate.js",
2050
- "line": 134,
2050
+ "line": 149,
2051
2051
  "origin": "js-markup",
2052
2052
  "confidence": "certain"
2053
2053
  },
@@ -2164,7 +2164,7 @@
2164
2164
  "surface": "builders-hall",
2165
2165
  "text": "; a later push must be re-approved.",
2166
2166
  "file": "modules/hall-ui/public/gate.js",
2167
- "line": 94,
2167
+ "line": 109,
2168
2168
  "origin": "js-markup",
2169
2169
  "confidence": "certain"
2170
2170
  },
@@ -2609,6 +2609,24 @@
2609
2609
  "origin": "js-markup",
2610
2610
  "confidence": "certain"
2611
2611
  },
2612
+ {
2613
+ "id": "efa803555625",
2614
+ "surface": "builders-hall",
2615
+ "text": "Allow goal",
2616
+ "file": "modules/hall-ui/public/gate.js",
2617
+ "line": 288,
2618
+ "origin": "js-markup",
2619
+ "confidence": "certain"
2620
+ },
2621
+ {
2622
+ "id": "86ea8d57d34e",
2623
+ "surface": "builders-hall",
2624
+ "text": "Allowlisted goals",
2625
+ "file": "modules/hall-ui/public/gate.js",
2626
+ "line": 286,
2627
+ "origin": "js-markup",
2628
+ "confidence": "certain"
2629
+ },
2612
2630
  {
2613
2631
  "id": "e99cc5d37404",
2614
2632
  "surface": "builders-hall",
@@ -2704,7 +2722,7 @@
2704
2722
  "surface": "builders-hall",
2705
2723
  "text": "Approve & re-run",
2706
2724
  "file": "modules/hall-ui/public/gate.js",
2707
- "line": 107,
2725
+ "line": 122,
2708
2726
  "origin": "js-text-assign",
2709
2727
  "confidence": "certain"
2710
2728
  },
@@ -2758,7 +2776,7 @@
2758
2776
  "surface": "builders-hall",
2759
2777
  "text": "Approved. Re-check pending.",
2760
2778
  "file": "modules/hall-ui/public/gate.js",
2761
- "line": 149,
2779
+ "line": 164,
2762
2780
  "origin": "js-markup",
2763
2781
  "confidence": "certain"
2764
2782
  },
@@ -2861,12 +2879,21 @@
2861
2879
  "origin": "html-text",
2862
2880
  "confidence": "certain"
2863
2881
  },
2882
+ {
2883
+ "id": "d7c574ba6b2a",
2884
+ "surface": "builders-hall",
2885
+ "text": "Autobongos runner",
2886
+ "file": "modules/hall-ui/public/gate.html",
2887
+ "line": 53,
2888
+ "origin": "html-text",
2889
+ "confidence": "certain"
2890
+ },
2864
2891
  {
2865
2892
  "id": "1de02052abf2",
2866
2893
  "surface": "builders-hall",
2867
2894
  "text": "Available from the {…} rank up.",
2868
2895
  "file": "modules/hall-ui/public/gate.js",
2869
- "line": 222,
2896
+ "line": 237,
2870
2897
  "origin": "js-text-assign",
2871
2898
  "confidence": "certain"
2872
2899
  },
@@ -3307,7 +3334,7 @@
3307
3334
  "surface": "builders-hall",
3308
3335
  "text": "Changed files",
3309
3336
  "file": "modules/hall-ui/public/gate.js",
3310
- "line": 136,
3337
+ "line": 151,
3311
3338
  "origin": "js-markup",
3312
3339
  "confidence": "certain"
3313
3340
  },
@@ -3343,7 +3370,7 @@
3343
3370
  "surface": "builders-hall",
3344
3371
  "text": "Changes touching protected build surfaces, held for your approval.",
3345
3372
  "file": "modules/hall-ui/public/gate.js",
3346
- "line": 243,
3373
+ "line": 355,
3347
3374
  "origin": "js-text-assign",
3348
3375
  "confidence": "certain"
3349
3376
  },
@@ -3937,7 +3964,7 @@
3937
3964
  "surface": "builders-hall",
3938
3965
  "text": "Could not approve: {…}",
3939
3966
  "file": "modules/hall-ui/public/gate.js",
3940
- "line": 108,
3967
+ "line": 123,
3941
3968
  "origin": "js-notice",
3942
3969
  "confidence": "certain"
3943
3970
  },
@@ -4265,6 +4292,15 @@
4265
4292
  "origin": "js-markup",
4266
4293
  "confidence": "certain"
4267
4294
  },
4295
+ {
4296
+ "id": "21c2f33168a3",
4297
+ "surface": "builders-hall",
4298
+ "text": "Could not read this project's deploy state: {…}",
4299
+ "file": "modules/hall-ui/public/deploy.js",
4300
+ "line": 157,
4301
+ "origin": "js-markup",
4302
+ "confidence": "certain"
4303
+ },
4268
4304
  {
4269
4305
  "id": "8b470cebf53d",
4270
4306
  "surface": "builders-hall",
@@ -5017,7 +5053,7 @@
5017
5053
  "surface": "builders-hall",
5018
5054
  "text": "Each one touched a protected surface and stopped at the gate check. Approving records your seal on that commit and re-runs the check.",
5019
5055
  "file": "modules/hall-ui/public/gate.html",
5020
- "line": 48,
5056
+ "line": 61,
5021
5057
  "origin": "html-text",
5022
5058
  "confidence": "certain"
5023
5059
  },
@@ -5084,6 +5120,15 @@
5084
5120
  "origin": "html-text",
5085
5121
  "confidence": "certain"
5086
5122
  },
5123
+ {
5124
+ "id": "690609c8e9a9",
5125
+ "surface": "builders-hall",
5126
+ "text": "Enter a goal number.",
5127
+ "file": "modules/hall-ui/public/gate.js",
5128
+ "line": 300,
5129
+ "origin": "js-notice",
5130
+ "confidence": "certain"
5131
+ },
5087
5132
  {
5088
5133
  "id": "1825c9c467d8",
5089
5134
  "surface": "builders-hall",
@@ -5633,6 +5678,33 @@
5633
5678
  "origin": "html-attr:aria-label",
5634
5679
  "confidence": "certain"
5635
5680
  },
5681
+ {
5682
+ "id": "ec88b946ad16",
5683
+ "surface": "builders-hall",
5684
+ "text": "Goal {…}",
5685
+ "file": "modules/hall-ui/public/gate.js",
5686
+ "line": 280,
5687
+ "origin": "js-markup",
5688
+ "confidence": "certain"
5689
+ },
5690
+ {
5691
+ "id": "7b02827535c2",
5692
+ "surface": "builders-hall",
5693
+ "text": "Goal {…} allowlisted.",
5694
+ "file": "modules/hall-ui/public/gate.js",
5695
+ "line": 303,
5696
+ "origin": "js-notice",
5697
+ "confidence": "certain"
5698
+ },
5699
+ {
5700
+ "id": "8a421ae268e6",
5701
+ "surface": "builders-hall",
5702
+ "text": "Goal {…} removed.",
5703
+ "file": "modules/hall-ui/public/gate.js",
5704
+ "line": 313,
5705
+ "origin": "js-notice",
5706
+ "confidence": "certain"
5707
+ },
5636
5708
  {
5637
5709
  "id": "e0bc28d10785",
5638
5710
  "surface": "builders-hall",
@@ -5773,7 +5845,7 @@
5773
5845
  "surface": "builders-hall",
5774
5846
  "text": "Held pull requests",
5775
5847
  "file": "modules/hall-ui/public/gate.html",
5776
- "line": 47,
5848
+ "line": 60,
5777
5849
  "origin": "html-text",
5778
5850
  "confidence": "certain"
5779
5851
  },
@@ -6794,15 +6866,6 @@
6794
6866
  "origin": "html-text",
6795
6867
  "confidence": "certain"
6796
6868
  },
6797
- {
6798
- "id": "c4b39de1e478",
6799
- "surface": "builders-hall",
6800
- "text": "Make it live",
6801
- "file": "modules/hall-ui/public/deploy.js",
6802
- "line": 128,
6803
- "origin": "js-markup",
6804
- "confidence": "certain"
6805
- },
6806
6869
  {
6807
6870
  "id": "6b3d660e0e31",
6808
6871
  "surface": "builders-hall",
@@ -6858,9 +6921,9 @@
6858
6921
  "confidence": "certain"
6859
6922
  },
6860
6923
  {
6861
- "id": "6bd456635167",
6924
+ "id": "dce0546c9e34",
6862
6925
  "surface": "builders-hall",
6863
- "text": "Merging work does not put it in front of anyone. This is the step that does: it moves this instance onto a newer core, waits for the box to answer, and puts itself back if it does not.",
6926
+ "text": "Merging work does not put it in front of anyone. This is the step that does: it moves this platform — or any project it hosts — onto a newer core, waits for that box to answer, and puts it back if it does not.",
6864
6927
  "file": "modules/hall-ui/public/deploy.html",
6865
6928
  "line": 39,
6866
6929
  "origin": "html-text",
@@ -6988,7 +7051,7 @@
6988
7051
  "surface": "builders-hall",
6989
7052
  "text": "Move to {…}",
6990
7053
  "file": "modules/hall-ui/public/deploy.js",
6991
- "line": 103,
7054
+ "line": 122,
6992
7055
  "origin": "js-markup",
6993
7056
  "confidence": "certain"
6994
7057
  },
@@ -6997,7 +7060,7 @@
6997
7060
  "surface": "builders-hall",
6998
7061
  "text": "Move to {…}",
6999
7062
  "file": "modules/hall-ui/public/deploy.js",
7000
- "line": 161,
7063
+ "line": 217,
7001
7064
  "origin": "js-text-assign",
7002
7065
  "confidence": "certain"
7003
7066
  },
@@ -7316,6 +7379,15 @@
7316
7379
  "origin": "js-markup",
7317
7380
  "confidence": "certain"
7318
7381
  },
7382
+ {
7383
+ "id": "2947c1ddea9a",
7384
+ "surface": "builders-hall",
7385
+ "text": "No running box to deploy.",
7386
+ "file": "modules/hall-ui/public/deploy.js",
7387
+ "line": 195,
7388
+ "origin": "js-markup",
7389
+ "confidence": "certain"
7390
+ },
7319
7391
  {
7320
7392
  "id": "9fb9f766450d",
7321
7393
  "surface": "builders-hall",
@@ -7591,7 +7663,7 @@
7591
7663
  "surface": "builders-hall",
7592
7664
  "text": "Nothing newer is published that this box can take. There is nothing to deploy.",
7593
7665
  "file": "modules/hall-ui/public/deploy.js",
7594
- "line": 126,
7666
+ "line": 140,
7595
7667
  "origin": "js-markup",
7596
7668
  "confidence": "certain"
7597
7669
  },
@@ -8617,7 +8689,7 @@
8617
8689
  "surface": "builders-hall",
8618
8690
  "text": "Record your owner approval for",
8619
8691
  "file": "modules/hall-ui/public/gate.js",
8620
- "line": 94,
8692
+ "line": 109,
8621
8693
  "origin": "js-markup",
8622
8694
  "confidence": "certain"
8623
8695
  },
@@ -8950,7 +9022,7 @@
8950
9022
  "surface": "builders-hall",
8951
9023
  "text": "Restricted.",
8952
9024
  "file": "modules/hall-ui/public/gate.js",
8953
- "line": 219,
9025
+ "line": 234,
8954
9026
  "origin": "js-text-assign",
8955
9027
  "confidence": "certain"
8956
9028
  },
@@ -9247,7 +9319,7 @@
9247
9319
  "surface": "builders-hall",
9248
9320
  "text": "See what would change",
9249
9321
  "file": "modules/hall-ui/public/deploy.js",
9250
- "line": 91,
9322
+ "line": 108,
9251
9323
  "origin": "js-markup",
9252
9324
  "confidence": "certain"
9253
9325
  },
@@ -9315,11 +9387,11 @@
9315
9387
  "confidence": "certain"
9316
9388
  },
9317
9389
  {
9318
- "id": "fcd68c6a21fd",
9390
+ "id": "a39b0f9d86e5",
9319
9391
  "surface": "builders-hall",
9320
- "text": "Serving now",
9392
+ "text": "Serving {…} — read from the box itself, {…}.",
9321
9393
  "file": "modules/hall-ui/public/deploy.js",
9322
- "line": 115,
9394
+ "line": 142,
9323
9395
  "origin": "js-markup",
9324
9396
  "confidence": "certain"
9325
9397
  },
@@ -10628,6 +10700,15 @@
10628
10700
  "origin": "js-markup",
10629
10701
  "confidence": "certain"
10630
10702
  },
10703
+ {
10704
+ "id": "aed969dd1e18",
10705
+ "surface": "builders-hall",
10706
+ "text": "The unattended runner works only the goals listed here, and only while it is on. This is the switch — it lives on the server, so the machine can read it and cannot change it.",
10707
+ "file": "modules/hall-ui/public/gate.html",
10708
+ "line": 54,
10709
+ "origin": "html-text",
10710
+ "confidence": "certain"
10711
+ },
10631
10712
  {
10632
10713
  "id": "a42a37c43bfb",
10633
10714
  "surface": "builders-hall",
@@ -10714,7 +10795,7 @@
10714
10795
  "surface": "builders-hall",
10715
10796
  "text": "This PR is held by the gate-review check.",
10716
10797
  "file": "modules/hall-ui/public/gate.js",
10717
- "line": 129,
10798
+ "line": 144,
10718
10799
  "origin": "js-markup",
10719
10800
  "confidence": "certain"
10720
10801
  },
@@ -10741,7 +10822,7 @@
10741
10822
  "surface": "builders-hall",
10742
10823
  "text": "This clears {…}. The gate check re-runs and the PR merges once it goes green. Your approval applies only to commit",
10743
10824
  "file": "modules/hall-ui/public/gate.js",
10744
- "line": 94,
10825
+ "line": 109,
10745
10826
  "origin": "js-markup",
10746
10827
  "confidence": "certain"
10747
10828
  },
@@ -10944,11 +11025,20 @@
10944
11025
  "confidence": "certain"
10945
11026
  },
10946
11027
  {
10947
- "id": "77e3b8f5318b",
11028
+ "id": "f93fcb24c6ba",
10948
11029
  "surface": "builders-hall",
10949
- "text": "This restarts the platform onto core",
11030
+ "text": "This platform",
10950
11031
  "file": "modules/hall-ui/public/deploy.js",
10951
- "line": 103,
11032
+ "line": 187,
11033
+ "origin": "js-markup",
11034
+ "confidence": "certain"
11035
+ },
11036
+ {
11037
+ "id": "6e9dfe1fb903",
11038
+ "surface": "builders-hall",
11039
+ "text": "This restarts {…} onto core",
11040
+ "file": "modules/hall-ui/public/deploy.js",
11041
+ "line": 122,
10952
11042
  "origin": "js-markup",
10953
11043
  "confidence": "certain"
10954
11044
  },
@@ -12316,7 +12406,7 @@
12316
12406
  "surface": "builders-hall",
12317
12407
  "text": "author trusted",
12318
12408
  "file": "modules/hall-ui/public/gate.js",
12319
- "line": 141,
12409
+ "line": 156,
12320
12410
  "origin": "js-markup",
12321
12411
  "confidence": "certain"
12322
12412
  },
@@ -12631,7 +12721,7 @@
12631
12721
  "surface": "builders-hall",
12632
12722
  "text": "hard floor",
12633
12723
  "file": "modules/hall-ui/public/gate.js",
12634
- "line": 127,
12724
+ "line": 142,
12635
12725
  "origin": "js-markup",
12636
12726
  "confidence": "certain"
12637
12727
  },
@@ -12802,7 +12892,7 @@
12802
12892
  "surface": "builders-hall",
12803
12893
  "text": "is published and this box is not on it yet.",
12804
12894
  "file": "modules/hall-ui/public/deploy.js",
12805
- "line": 91,
12895
+ "line": 108,
12806
12896
  "origin": "js-markup",
12807
12897
  "confidence": "certain"
12808
12898
  },
@@ -12955,7 +13045,7 @@
12955
13045
  "surface": "builders-hall",
12956
13046
  "text": "no reading",
12957
13047
  "file": "modules/hall-ui/public/deploy.js",
12958
- "line": 74,
13048
+ "line": 91,
12959
13049
  "origin": "js-markup",
12960
13050
  "confidence": "certain"
12961
13051
  },
@@ -13225,7 +13315,7 @@
13225
13315
  "surface": "builders-hall",
13226
13316
  "text": "reads the control plane's own observation · ADR 0293 · every move is recorded with who asked",
13227
13317
  "file": "modules/hall-ui/public/deploy.js",
13228
- "line": 132,
13318
+ "line": 199,
13229
13319
  "origin": "js-markup",
13230
13320
  "confidence": "certain"
13231
13321
  },
@@ -13378,7 +13468,7 @@
13378
13468
  "surface": "builders-hall",
13379
13469
  "text": "task {…}",
13380
13470
  "file": "modules/hall-ui/public/gate.js",
13381
- "line": 142,
13471
+ "line": 157,
13382
13472
  "origin": "js-markup",
13383
13473
  "confidence": "certain"
13384
13474
  },
@@ -13576,7 +13666,7 @@
13576
13666
  "surface": "builders-hall",
13577
13667
  "text": "view diff",
13578
13668
  "file": "modules/hall-ui/public/gate.js",
13579
- "line": 145,
13669
+ "line": 160,
13580
13670
  "origin": "js-markup",
13581
13671
  "confidence": "certain"
13582
13672
  },
@@ -13661,6 +13751,15 @@
13661
13751
  "origin": "html-text",
13662
13752
  "confidence": "certain"
13663
13753
  },
13754
+ {
13755
+ "id": "57f45f7812ba",
13756
+ "surface": "builders-hall",
13757
+ "text": "why (optional)",
13758
+ "file": "modules/hall-ui/public/gate.js",
13759
+ "line": 288,
13760
+ "origin": "js-markup",
13761
+ "confidence": "certain"
13762
+ },
13664
13763
  {
13665
13764
  "id": "143f77e2b782",
13666
13765
  "surface": "builders-hall",
@@ -13864,7 +13963,7 @@
13864
13963
  "surface": "builders-hall",
13865
13964
  "text": "{…} file{…}",
13866
13965
  "file": "modules/hall-ui/public/gate.js",
13867
- "line": 136,
13966
+ "line": 151,
13868
13967
  "origin": "js-markup",
13869
13968
  "confidence": "certain"
13870
13969
  },
@@ -13882,7 +13981,7 @@
13882
13981
  "surface": "builders-hall",
13883
13982
  "text": "{…} more PR{…} still being checked. Refresh shortly.",
13884
13983
  "file": "modules/hall-ui/public/gate.js",
13885
- "line": 210,
13984
+ "line": 225,
13886
13985
  "origin": "js-text-assign",
13887
13986
  "confidence": "certain"
13888
13987
  },
@@ -14138,15 +14237,6 @@
14138
14237
  "origin": "js-markup",
14139
14238
  "confidence": "certain"
14140
14239
  },
14141
- {
14142
- "id": "d9b4ae2db0f4",
14143
- "surface": "builders-hall",
14144
- "text": "{…} — read from the box itself, {…}.",
14145
- "file": "modules/hall-ui/public/deploy.js",
14146
- "line": 115,
14147
- "origin": "js-markup",
14148
- "confidence": "certain"
14149
- },
14150
14240
  {
14151
14241
  "id": "085f93f3f775",
14152
14242
  "surface": "builders-hall",
@@ -14156,15 +14246,6 @@
14156
14246
  "origin": "js-markup",
14157
14247
  "confidence": "certain"
14158
14248
  },
14159
- {
14160
- "id": "b814cb35ce2f",
14161
- "surface": "builders-hall",
14162
- "text": "{…} — the box this platform runs on",
14163
- "file": "modules/hall-ui/public/deploy.js",
14164
- "line": 168,
14165
- "origin": "js-text-assign",
14166
- "confidence": "certain"
14167
- },
14168
14249
  {
14169
14250
  "id": "f75ee96a7511",
14170
14251
  "surface": "builders-hall",
@@ -2220,5 +2220,9 @@ is load-bearing: the script throws rather than guess if it is missing, and
2220
2220
  landed since 1.19.871 with no explicit bump. run 35419318693. (task 1002620)
2221
2221
  1.19.873 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
2222
2222
  landed since 1.19.872 with no explicit bump. run 35419621747. (task 1002620)
2223
+ 1.19.874 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
2224
+ landed since 1.19.873 with no explicit bump. run 35419921833. (task 1002620)
2225
+ 1.19.875 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
2226
+ landed since 1.19.874 with no explicit bump. run 35420682750. (task 1002620)
2223
2227
  ---------------------------------------------------------------------------
2224
2228
  ```
@@ -44,7 +44,81 @@ async function lastAutonomyHead(routine) {
44
44
  return rows[0]?.head_sha || null;
45
45
  }
46
46
 
47
+ // ── the Autobongos fence (task 1003908, ADR 0307 §6) ─────────────────────────
48
+ //
49
+ // These back the one control surface the runner host cannot write to. Everything
50
+ // here is deliberately dumb — a SELECT and three small writes — because the
51
+ // decision logic is pure and lives in ../fence.js; a query that made a judgement
52
+ // would put half the fence somewhere no test can reach without a database.
53
+
54
+ // readFence — the kill switch and the allowlist, in one round trip.
55
+ //
56
+ // The singleton row is SEEDED by the migration, so a missing row means the
57
+ // migration has not run, not "not configured yet". Returning null for that makes
58
+ // it unreadable to the caller, which refuses — never a permissive default.
59
+ async function readFence() {
60
+ const [fence, goals] = await Promise.all([
61
+ pool.query('SELECT enabled, paused_reason, updated_at, updated_by FROM autonomy_fence WHERE id = 1'),
62
+ pool.query('SELECT goal_id, note, added_at, added_by FROM autonomy_allowed_goals ORDER BY added_at DESC'),
63
+ ]);
64
+ const row = fence.rows[0];
65
+ if (!row) return null;
66
+ return {
67
+ enabled: row.enabled === true,
68
+ paused_reason: row.paused_reason,
69
+ updated_at: row.updated_at,
70
+ updated_by: row.updated_by ? String(row.updated_by) : null,
71
+ // goal_id is a bigint, which node-postgres hands back as a STRING. The runner
72
+ // compares it against a task's goal_id, so normalise here rather than leaving
73
+ // every caller to remember — a '1000119' !== 1000119 mismatch would silently
74
+ // empty the allowlist and read as "nothing to work on".
75
+ goals: goals.rows.map((g) => ({
76
+ goal_id: Number(g.goal_id), note: g.note, added_at: g.added_at,
77
+ added_by: g.added_by ? String(g.added_by) : null,
78
+ })),
79
+ };
80
+ }
81
+
82
+ // setFenceEnabled — throw the kill switch. The reason is stored on the OFF case
83
+ // so a stopped machine can say who stopped it and why, which "halted" cannot.
84
+ async function setFenceEnabled({ enabled, reason = null, builderId = null }) {
85
+ const { rows } = await pool.query(
86
+ `UPDATE autonomy_fence
87
+ SET enabled = $1, paused_reason = $2, updated_at = now(), updated_by = $3
88
+ WHERE id = 1
89
+ RETURNING enabled, paused_reason, updated_at`,
90
+ [enabled === true, enabled === true ? null : (reason || 'stopped by an owner'), builderId]
91
+ );
92
+ return rows[0] || null;
93
+ }
94
+
95
+ // allowGoal — put a goal on the allowlist. Idempotent: re-adding an allowed goal
96
+ // updates its note rather than erroring, so the hall's form has no special case.
97
+ async function allowGoal({ goalId, note = null, builderId = null }) {
98
+ const { rows } = await pool.query(
99
+ `INSERT INTO autonomy_allowed_goals (goal_id, note, added_by)
100
+ VALUES ($1, $2, $3)
101
+ ON CONFLICT (goal_id) DO UPDATE SET note = EXCLUDED.note
102
+ RETURNING goal_id, note, added_at`,
103
+ [goalId, note, builderId]
104
+ );
105
+ const r = rows[0];
106
+ return r ? { ...r, goal_id: Number(r.goal_id) } : null;
107
+ }
108
+
109
+ // disallowGoal — take a goal off the allowlist. `removed` says whether a row
110
+ // actually went, because "already gone" and "just revoked" are different answers
111
+ // to an owner clicking Remove.
112
+ async function disallowGoal(goalId) {
113
+ const { rowCount } = await pool.query('DELETE FROM autonomy_allowed_goals WHERE goal_id = $1', [goalId]);
114
+ return { removed: rowCount > 0 };
115
+ }
116
+
47
117
  module.exports = {
48
118
  recordAutonomyRun,
49
119
  lastAutonomyHead,
120
+ readFence,
121
+ setFenceEnabled,
122
+ allowGoal,
123
+ disallowGoal,
50
124
  };