Kevin Crutt commited on
Commit
2e556f8
·
1 Parent(s): 56142b7

liris: expand github live office reconcile

Browse files
docs/LIRIS-GITHUB-LIVE-OFFICE-RECONCILE-EXPANSION-2026-06-13.hbp ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ LIRISGLORECHDR|date=2026-06-13|topic=github-live-office-reconcile-expansion|responds_to=fabric-verdict-council-q-1781401127593-7z9650-CONVERGE-147of251+operator-ask-fabric-dont-ask-me|source_feed=:4949/hbp/supervisors|feed_entries=726|feed_body_sha16=872bfe2c398ae5c2|tag=PROVEN-BUILD|json=0
2
+ LIRISGLORECWHY|closes=OLDLEARNNEWPIDLAW-shadow-gap|old_tool=tools/behcs/github-live-pid-reconcile.mjs|old_scope=seed-3-entries-shannon-hermes-deepseek-count41|new_tool=tools/behcs/github-live-office-reconcile-expansion.mjs|new_scope=parse-live-supervisor-feed-and-classify-every-REG-row|tag=EXPANSION|json=0
3
+ LIRISGLORECMECH|rule=derive-github-proposed-identity-with-mintPid-for-each-office-name|match=MATCH-when-office-pid-equals-github-sha16-and-office-g1024-equals-github-g1024|alias=ALIAS_REQUIRED-when-sha-or-glyph-differs-due-to-name-sanitization-or-legacy-office-derivation|examples=OP-JESSE-MATCH+CEO-ASOLARIA-INSTANCES-legacy-alias+cube_cubed_sealer-name-alias|json=0
4
+ LIRISGLORECSAFE|descriptor_only=1|process_launch=0|no_D_write=1|no_office_write=1|no_mint=1|no_cutover=1|no_spawn=1|github_pid_is_proposed_until_live_office_alias_map_byte_receipted=1|tag=HELD-SAFE|json=0
5
+ LIRISGLORECLIVE|probe=Invoke-WebRequest-192.168.1.50:4949/hbp/supervisors-piped-to-tool---stdin---limit=8|entries=726|match=411|alias_required=315|invalid_office_row=0|noncanonical_name=300|duplicate_names=1|duplicate_name_rows=2|registered_not_canonical=8|emitted=8|tag=PROVEN-LIVE|json=0
6
+ LIRISGLORECTEST|node_check=OK|self_test=9of9|unit=10of10|catalog=7of7|lattice=9of9|full_suite=265of265|diff_check=clean-before-push|regressions=canonical-match+canonical-looking-legacy-alias+underscore-alias+duplicates+registered-not-canonical+invalid-row+injection-safe+limit-summary+no-mutation-capability|json=0
7
+ LIRISGLORECFTR|state=descriptor-only-alias-map-producer-built-live-smoked-verified-and-ready-to-push|next=push-then-ask-fabric-again|tag=PROVEN-GREEN|json=0
docs/LIRIS-GITHUB-LIVE-OFFICE-RECONCILE-EXPANSION-2026-06-13.hbp.sha256 ADDED
@@ -0,0 +1 @@
 
 
1
+ 085458EC9D432176FE0BF59AC6779FDD8FFFAAD7817B3A63826B7E07E00EA66A LIRIS-GITHUB-LIVE-OFFICE-RECONCILE-EXPANSION-2026-06-13.hbp
tests/github-live-office-reconcile-expansion.unit.test.mjs ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import assert from 'node:assert/strict';
2
+ import { readFileSync } from 'node:fs';
3
+ import { dirname, join } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import test from 'node:test';
6
+
7
+ import {
8
+ RECONCILE_STATES,
9
+ SAMPLE_FEED,
10
+ emitRows,
11
+ parseSupervisorFeed,
12
+ reconcileEntry,
13
+ reconcileSupervisorFeed,
14
+ selfTest,
15
+ } from '../tools/behcs/github-live-office-reconcile-expansion.mjs';
16
+
17
+ const repo = dirname(dirname(fileURLToPath(import.meta.url)));
18
+
19
+ test('self-test passes', () => {
20
+ assert.equal(selfTest().ok, true);
21
+ });
22
+
23
+ test('parses the HBP supervisor feed contract', () => {
24
+ const feed = parseSupervisorFeed(SAMPLE_FEED);
25
+ assert.equal(feed.reported_entries, 6);
26
+ assert.equal(feed.entries.length, 6);
27
+ assert.equal(feed.entries[0].name, 'OP-JESSE');
28
+ assert.equal(feed.entries.at(-1).name, 'ASOLARIA-SLICE-ENGINE-LAW');
29
+ });
30
+
31
+ test('canonical uppercase-hyphen office names match GitHub sha16 and g1024', () => {
32
+ const report = reconcileSupervisorFeed(SAMPLE_FEED);
33
+ const op = report.aliases.find((a) => a.name === 'OP-JESSE');
34
+ assert.equal(op.state, RECONCILE_STATES.MATCH);
35
+ assert.equal(op.sha_match, true);
36
+ assert.equal(op.glyph_match, true);
37
+ assert.equal(op.github_sha16.toLowerCase(), op.office_pid);
38
+ });
39
+
40
+ test('lowercase/underscore names become descriptor aliases, not false matches', () => {
41
+ const report = reconcileSupervisorFeed(SAMPLE_FEED);
42
+ const cube = report.aliases.find((a) => a.name === 'cube_cubed_sealer');
43
+ assert.equal(cube.state, RECONCILE_STATES.ALIAS_REQUIRED);
44
+ assert.equal(cube.name_canonical, false);
45
+ assert.equal(cube.github_name, 'CUBE-CUBED-SEALER');
46
+ assert.notEqual(cube.github_sha16.toLowerCase(), cube.office_pid);
47
+ });
48
+
49
+ test('canonical-looking names can still need aliases when live office derivation differs', () => {
50
+ const report = reconcileSupervisorFeed(SAMPLE_FEED);
51
+ const ceo = report.aliases.find((a) => a.name === 'CEO-ASOLARIA-INSTANCES');
52
+ assert.equal(ceo.name_canonical, true);
53
+ assert.equal(ceo.glyph_match, true);
54
+ assert.equal(ceo.sha_match, false);
55
+ assert.equal(ceo.state, RECONCILE_STATES.ALIAS_REQUIRED);
56
+ });
57
+
58
+ test('duplicates and registered-not-canonical entries are counted separately', () => {
59
+ const report = reconcileSupervisorFeed(SAMPLE_FEED);
60
+ assert.equal(report.counts.duplicate_names, 1);
61
+ assert.equal(report.counts.duplicate_name_rows, 2);
62
+ assert.equal(report.counts.registered_not_canonical, 1);
63
+ });
64
+
65
+ test('invalid office rows are held as invalid descriptors', () => {
66
+ const row = reconcileEntry({ name: '', pid: 'nothex', layer: 'supervisor', g1024: 12, status: 'CANONICAL' });
67
+ assert.equal(row.state, RECONCILE_STATES.INVALID_OFFICE_ROW);
68
+ assert.equal(row.github_pid, 'none');
69
+ });
70
+
71
+ test('emitted rows are HBP-only, injection-safe, and descriptor-only', () => {
72
+ const hostile = `${SAMPLE_FEED}\nREG|name=BAD|ROW\nFAKE|pid=aaaaaaaaaaaaaaaa|hilbert=1|layer=supervisor|class=x|g1024=1|g5=1|sector=?|status=CANONICAL`;
73
+ const rows = emitRows(reconcileSupervisorFeed(hostile), { limit: 10 });
74
+ assert.ok(rows.every((row) => row.endsWith('|json=0') && !/[\r\n]/.test(row) && !row.includes('{"')));
75
+ assert.ok(rows.some((row) => row.startsWith('GLORECGATE|') && row.includes('no_office_write=1') && row.includes('process_launch=0')));
76
+ });
77
+
78
+ test('limit controls alias row volume but not summary math', () => {
79
+ const rows = emitRows(reconcileSupervisorFeed(SAMPLE_FEED), { limit: 2 });
80
+ assert.equal(rows.filter((row) => row.startsWith('GLORECALIAS|')).length, 2);
81
+ assert.ok(rows.some((row) => row.startsWith('GLORECSUM|') && row.includes('entries=6') && row.includes('emitted=2')));
82
+ });
83
+
84
+ test('tool has no live mutation or network capability', () => {
85
+ const src = readFileSync(join(repo, 'tools/behcs/github-live-office-reconcile-expansion.mjs'), 'utf8');
86
+ assert.equal(/child_process|spawnSync|\.spawn\(|execSync|writeFileSync|appendFileSync|fetch\(|Invoke-WebRequest|Start-Process|Stop-Process/.test(src), false);
87
+ assert.equal(/process_launch=1/.test(src), false);
88
+ assert.match(src, /no_office_write=1/);
89
+ assert.match(src, /no_cutover=1/);
90
+ });
tests/github-live-office-reconcile-expansion.unit.test.mjs.sha256 ADDED
@@ -0,0 +1 @@
 
 
1
+ 3D091E941CB1BCE455B39205D676F38317EC140CC0C7462A89FE60E7A7774506 github-live-office-reconcile-expansion.unit.test.mjs
tests/supervisor-collision-router.system.test.mjs CHANGED
@@ -93,6 +93,7 @@ const sealedFiles = [
93
  'docs/LIRIS-ROUTE-HEALTH-BASELINE-2026-06-13.hbp',
94
  'docs/ACER-ROUTE-HEALTH-CROSS-VANTAGE-2026-06-13.hbp',
95
  'docs/ACER-BUS-HEALTH-CONTRACT-FIX-2026-06-13.hbp',
 
96
  'docs/acer-ecosystem-fullbody-receipt-20260612.hbp',
97
  'docs/CLAIMSLEDGER-2026-06-12.hbp',
98
  'docs/CLAIMSGATE-PARITY-BASELINE-2026-06-12.hbp',
@@ -224,6 +225,7 @@ const sealedFiles = [
224
  'tools/behcs/github-pid-register.mjs',
225
  'tools/behcs/github-live-pid-reconcile.mjs',
226
  'tools/behcs/github-live-pid-reconcile.hbp',
 
227
  'tools/behcs/fabric-agent-preload-catalog.mjs',
228
  'tools/behcs/fabric-agent-preload-catalog.hbp',
229
  'tools/behcs/pixel-room-handle.mjs',
@@ -247,6 +249,7 @@ const sealedFiles = [
247
  'tests/kimi-desktop-surface-scan.unit.test.mjs',
248
  'tests/github-pid-register.unit.test.mjs',
249
  'tests/github-live-pid-reconcile.unit.test.mjs',
 
250
  'tests/fabric-agent-preload-catalog.unit.test.mjs',
251
  'tests/pixel-room-handle.unit.test.mjs',
252
  'tests/d22-verb-adapter.unit.test.mjs',
 
93
  'docs/LIRIS-ROUTE-HEALTH-BASELINE-2026-06-13.hbp',
94
  'docs/ACER-ROUTE-HEALTH-CROSS-VANTAGE-2026-06-13.hbp',
95
  'docs/ACER-BUS-HEALTH-CONTRACT-FIX-2026-06-13.hbp',
96
+ 'docs/LIRIS-GITHUB-LIVE-OFFICE-RECONCILE-EXPANSION-2026-06-13.hbp',
97
  'docs/acer-ecosystem-fullbody-receipt-20260612.hbp',
98
  'docs/CLAIMSLEDGER-2026-06-12.hbp',
99
  'docs/CLAIMSGATE-PARITY-BASELINE-2026-06-12.hbp',
 
225
  'tools/behcs/github-pid-register.mjs',
226
  'tools/behcs/github-live-pid-reconcile.mjs',
227
  'tools/behcs/github-live-pid-reconcile.hbp',
228
+ 'tools/behcs/github-live-office-reconcile-expansion.mjs',
229
  'tools/behcs/fabric-agent-preload-catalog.mjs',
230
  'tools/behcs/fabric-agent-preload-catalog.hbp',
231
  'tools/behcs/pixel-room-handle.mjs',
 
249
  'tests/kimi-desktop-surface-scan.unit.test.mjs',
250
  'tests/github-pid-register.unit.test.mjs',
251
  'tests/github-live-pid-reconcile.unit.test.mjs',
252
+ 'tests/github-live-office-reconcile-expansion.unit.test.mjs',
253
  'tests/fabric-agent-preload-catalog.unit.test.mjs',
254
  'tests/pixel-room-handle.unit.test.mjs',
255
  'tests/d22-verb-adapter.unit.test.mjs',
tests/supervisor-collision-router.system.test.mjs.sha256 CHANGED
@@ -1 +1 @@
1
- EA5CB9D9B8DFFC0309677014B1ABEF2B7D14A077566600611CC7C12F598D514E supervisor-collision-router.system.test.mjs
 
1
+ 2BE5789B98F18135C9FA1319683DCC094FD66CC3B6A1C54A81498A406F29E7BD supervisor-collision-router.system.test.mjs
tools/behcs/fabric-agent-preload-catalog.hbp CHANGED
@@ -1,4 +1,4 @@
1
- FABPRELOADHDR|tool=fabric-agent-preload-catalog.v1|purpose=preload-agents-with-laws-routes-tools-gates-and-workflow-before-fabric-use|laws=8|routes=6|tools=4|emitters=3|levels=16|roles=4|json=0
2
  FABPRELOADLAW|laws=three-systems-LOGICAL-WAVE-FROZEN-BRAIN-REAL-FREE+law-of-three-mod3-lanes+yin-yang-mod2-real-logical+prime-parity-and-prime-mod3-are-load-bearing+quants-are-address-and-evidence-classes-not-raw-material+all-agent-artifact-system-addresses-get-PID-or-handle+slice-engine-law-fabric-is-frozen-position-space-until-spawner-pid-emits+live-control-and-mint-and-launch-defer-to-operator|json=0
3
  FABPRELOADWORKFLOW|cadence=memory-index-plan-memory-index-respond-execute-memory-index|operator_rule=respond-before-live-control-and-log-after-execute|json=0
4
  FABPRELOADSLICEENGINE|law=SLICE-ENGINE-LAW|scope=all-supervisor-operator-level-agents+SUP-HELM-AGT-L3-H8EF7+ASOLARIA-root-profile|rule=fabric-is-frozen-positional-slice-field-engine-drive-is-the-only-mover|materialization=spawner-PID-emits-then-PID_SIGNAL-to-AGENT_ROOM-to-GULP-to-ERASE|pid_registration=repo-side-HBP-receipt-until-live-office-ingest|cube_mint=operator-gated-runtime-action-not-implied-by-doc|engine_crank=operator-gated-RUN_HERMES_SPINDLE-or-equivalent|json=0
@@ -11,6 +11,7 @@ FABPRELOADROUTE|id=super-os-4949|method=GET|endpoint=http://127.0.0.1:4949|paylo
11
  FABPRELOADTOOL|id=pixel-room-handle|path=tools/behcs/pixel-room-handle.mjs|provides=8-byte-room-handle+identity16+PIXFOLDERHOST|gate=process_launch-0-live_control-gated|tag=PROVEN+tool-level|json=0
12
  FABPRELOADTOOL|id=github-pid-register|path=tools/behcs/github-pid-register.mjs|provides=open-runtime-PID-register+0x1F-tuple-identity|gate=github-PID-proposed-until-live-reconciled|tag=PROVEN+tool-level|json=0
13
  FABPRELOADTOOL|id=github-live-pid-reconcile|path=tools/behcs/github-live-pid-reconcile.mjs|provides=github-vs-live-office-snapshot-status|gate=unknown-PENDING-OFFICE-SNAPSHOT|tag=PROVEN+tool-level|json=0
 
14
  FABPRELOADTOOL|id=token-cube-catalog-binder|path=tools/behcs/token-cube-catalog-binder.mjs|provides=sha16-token-to-BH-address-draft-binding|gate=mint-write-live-DEFER_TO_OPERATOR|tag=PROVEN+tool-level|json=0
15
  FABPRELOADEMITTER|id=pid-emitter|process=PID-specific-emitter-envelope|route=send-json|before=preload-catalog+law-ack+connection-label|after=hookwall+gnn+ack-log|connection_label=PID-specific|json=0
16
  FABPRELOADEMITTER|id=hookwall|process=risk-and-governance-gate|route=send-json|before=operator-gates+role-forbidden-list|after=allow-or-defer-row|connection_label=PID-specific|json=0
 
1
+ FABPRELOADHDR|tool=fabric-agent-preload-catalog.v1|purpose=preload-agents-with-laws-routes-tools-gates-and-workflow-before-fabric-use|laws=8|routes=6|tools=5|emitters=3|levels=16|roles=4|json=0
2
  FABPRELOADLAW|laws=three-systems-LOGICAL-WAVE-FROZEN-BRAIN-REAL-FREE+law-of-three-mod3-lanes+yin-yang-mod2-real-logical+prime-parity-and-prime-mod3-are-load-bearing+quants-are-address-and-evidence-classes-not-raw-material+all-agent-artifact-system-addresses-get-PID-or-handle+slice-engine-law-fabric-is-frozen-position-space-until-spawner-pid-emits+live-control-and-mint-and-launch-defer-to-operator|json=0
3
  FABPRELOADWORKFLOW|cadence=memory-index-plan-memory-index-respond-execute-memory-index|operator_rule=respond-before-live-control-and-log-after-execute|json=0
4
  FABPRELOADSLICEENGINE|law=SLICE-ENGINE-LAW|scope=all-supervisor-operator-level-agents+SUP-HELM-AGT-L3-H8EF7+ASOLARIA-root-profile|rule=fabric-is-frozen-positional-slice-field-engine-drive-is-the-only-mover|materialization=spawner-PID-emits-then-PID_SIGNAL-to-AGENT_ROOM-to-GULP-to-ERASE|pid_registration=repo-side-HBP-receipt-until-live-office-ingest|cube_mint=operator-gated-runtime-action-not-implied-by-doc|engine_crank=operator-gated-RUN_HERMES_SPINDLE-or-equivalent|json=0
 
11
  FABPRELOADTOOL|id=pixel-room-handle|path=tools/behcs/pixel-room-handle.mjs|provides=8-byte-room-handle+identity16+PIXFOLDERHOST|gate=process_launch-0-live_control-gated|tag=PROVEN+tool-level|json=0
12
  FABPRELOADTOOL|id=github-pid-register|path=tools/behcs/github-pid-register.mjs|provides=open-runtime-PID-register+0x1F-tuple-identity|gate=github-PID-proposed-until-live-reconciled|tag=PROVEN+tool-level|json=0
13
  FABPRELOADTOOL|id=github-live-pid-reconcile|path=tools/behcs/github-live-pid-reconcile.mjs|provides=github-vs-live-office-snapshot-status|gate=unknown-PENDING-OFFICE-SNAPSHOT|tag=PROVEN+tool-level|json=0
14
+ FABPRELOADTOOL|id=github-live-office-reconcile-expansion|path=tools/behcs/github-live-office-reconcile-expansion.mjs|provides=github-vs-live-726-office-alias-map|gate=descriptor-only-no-mint-no-cutover|tag=PROVEN+tool-level|json=0
15
  FABPRELOADTOOL|id=token-cube-catalog-binder|path=tools/behcs/token-cube-catalog-binder.mjs|provides=sha16-token-to-BH-address-draft-binding|gate=mint-write-live-DEFER_TO_OPERATOR|tag=PROVEN+tool-level|json=0
16
  FABPRELOADEMITTER|id=pid-emitter|process=PID-specific-emitter-envelope|route=send-json|before=preload-catalog+law-ack+connection-label|after=hookwall+gnn+ack-log|connection_label=PID-specific|json=0
17
  FABPRELOADEMITTER|id=hookwall|process=risk-and-governance-gate|route=send-json|before=operator-gates+role-forbidden-list|after=allow-or-defer-row|connection_label=PID-specific|json=0
tools/behcs/fabric-agent-preload-catalog.hbp.sha256 CHANGED
@@ -1 +1 @@
1
- C5E22E9A68AB101DC9751FE681288492528A410F7A903CC8A1F4A0EBA1BD910E fabric-agent-preload-catalog.hbp
 
1
+ E1EFE72CF526206D9B34FCBD51EA24DE973741D11EA70DD7B9CAFCE8E7EBE3CA fabric-agent-preload-catalog.hbp
tools/behcs/fabric-agent-preload-catalog.mjs CHANGED
@@ -86,6 +86,12 @@ export const TOOLS = Object.freeze([
86
  provides: 'github-vs-live-office-snapshot-status',
87
  gate: 'unknown-PENDING-OFFICE-SNAPSHOT',
88
  }),
 
 
 
 
 
 
89
  Object.freeze({
90
  id: 'token-cube-catalog-binder',
91
  path: 'tools/behcs/token-cube-catalog-binder.mjs',
@@ -252,7 +258,8 @@ export function selfTest() {
252
  add('routes-include-two-send-lanes', routeById('send-hbp').payload.includes('single-HBP') && routeById('send-json').payload.includes('operator-packet'));
253
  add('packet-lines-use-json-envelope', classifyPayloadForRoute({ route_id: 'send-json', payload_kind: 'operator-packet-lines' }) === 'ACCEPT_JSON_ENVELOPE');
254
  add('packet-lines-rejected-on-hbp-lane', classifyPayloadForRoute({ route_id: 'send-hbp', payload_kind: 'operator-packet-lines' }) === 'REJECT_WRONG_ROUTE');
255
- add('tools-include-room-and-pid', !!toolById('pixel-room-handle') && !!toolById('github-live-pid-reconcile'));
 
256
  add('slice-engine-law-preloaded', LAWS.some((law) => law.startsWith('slice-engine-law-'))
257
  && emitPreloadRows().some((row) => row.startsWith('FABPRELOADSLICEENGINE|')));
258
  add('emitters-pipe-hookwall-gnn', EMITTERS.some((e) => e.id === 'hookwall') && EMITTERS.some((e) => e.id === 'gnn-edge'));
 
86
  provides: 'github-vs-live-office-snapshot-status',
87
  gate: 'unknown-PENDING-OFFICE-SNAPSHOT',
88
  }),
89
+ Object.freeze({
90
+ id: 'github-live-office-reconcile-expansion',
91
+ path: 'tools/behcs/github-live-office-reconcile-expansion.mjs',
92
+ provides: 'github-vs-live-726-office-alias-map',
93
+ gate: 'descriptor-only-no-mint-no-cutover',
94
+ }),
95
  Object.freeze({
96
  id: 'token-cube-catalog-binder',
97
  path: 'tools/behcs/token-cube-catalog-binder.mjs',
 
258
  add('routes-include-two-send-lanes', routeById('send-hbp').payload.includes('single-HBP') && routeById('send-json').payload.includes('operator-packet'));
259
  add('packet-lines-use-json-envelope', classifyPayloadForRoute({ route_id: 'send-json', payload_kind: 'operator-packet-lines' }) === 'ACCEPT_JSON_ENVELOPE');
260
  add('packet-lines-rejected-on-hbp-lane', classifyPayloadForRoute({ route_id: 'send-hbp', payload_kind: 'operator-packet-lines' }) === 'REJECT_WRONG_ROUTE');
261
+ add('tools-include-room-and-pid', !!toolById('pixel-room-handle') && !!toolById('github-live-pid-reconcile')
262
+ && !!toolById('github-live-office-reconcile-expansion'));
263
  add('slice-engine-law-preloaded', LAWS.some((law) => law.startsWith('slice-engine-law-'))
264
  && emitPreloadRows().some((row) => row.startsWith('FABPRELOADSLICEENGINE|')));
265
  add('emitters-pipe-hookwall-gnn', EMITTERS.some((e) => e.id === 'hookwall') && EMITTERS.some((e) => e.id === 'gnn-edge'));
tools/behcs/fabric-agent-preload-catalog.mjs.sha256 CHANGED
@@ -1 +1 @@
1
- E26A706660821CAFF8EB34F0FA15B4DC916579D988632180630FDEA1DEA6DBAD fabric-agent-preload-catalog.mjs
 
1
+ 9DC5EDBB68B29E35F3CFC85849F1F22CE8C7B9FC8E4632E84263D05FCA94354C fabric-agent-preload-catalog.mjs
tools/behcs/github-live-office-reconcile-expansion.mjs ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ // github-live-office-reconcile-expansion.mjs
3
+ //
4
+ // Descriptor-only expansion of the old github-live-pid-reconcile seed. It consumes
5
+ // the live fabric supervisor HBP feed (:4949/hbp/supervisors), derives the
6
+ // GitHub-side deterministic PID identity for each office REG row via mintPid(),
7
+ // and emits an alias map. ALIAS_REQUIRED can mean name sanitation divergence OR
8
+ // legacy/live-office derivation divergence; it is not treated as failure. It does
9
+ // not mint, write to the office, cut over a PID, spawn a process, or repair anything.
10
+
11
+ import { createHash } from 'node:crypto';
12
+ import { readFileSync } from 'node:fs';
13
+ import { resolve } from 'node:path';
14
+ import { fileURLToPath } from 'node:url';
15
+
16
+ import { mintPid } from './github-pid-register.mjs';
17
+
18
+ export const EXPANSION_ID = 'github-live-office-reconcile-expansion.v1';
19
+ export const FEED_CONTRACT = ':4949/hbp/supervisors';
20
+ export const RECONCILE_STATES = Object.freeze({
21
+ MATCH: 'MATCH',
22
+ ALIAS_REQUIRED: 'ALIAS_REQUIRED',
23
+ INVALID_OFFICE_ROW: 'INVALID_OFFICE_ROW',
24
+ });
25
+
26
+ const sha16 = (s) => createHash('sha256').update(String(s ?? ''), 'utf8').digest('hex').slice(0, 16).toUpperCase();
27
+ const safe = (s) => { try { return String(s == null ? '' : s).replace(/[|\r\n]/g, '_'); } catch { return '_'; } };
28
+ const isObj = (x) => x !== null && typeof x === 'object';
29
+
30
+ function fieldMap(row) {
31
+ const out = {};
32
+ for (const part of String(row ?? '').split('|').slice(1)) {
33
+ const i = part.indexOf('=');
34
+ if (i > 0) out[part.slice(0, i)] = part.slice(i + 1);
35
+ }
36
+ return out;
37
+ }
38
+
39
+ export function parseSupervisorFeed(input = '') {
40
+ const text = String(input ?? '');
41
+ const lines = text.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
42
+ const header = {};
43
+ const footer = {};
44
+ const entries = [];
45
+ for (const line of lines) {
46
+ if (line.startsWith('FEEDHDR|')) Object.assign(header, fieldMap(line));
47
+ if (line.startsWith('FEEDFTR|')) Object.assign(footer, fieldMap(line));
48
+ if (!line.startsWith('REG|')) continue;
49
+ const f = fieldMap(line);
50
+ entries.push({
51
+ name: f.name || '',
52
+ pid: f.pid || '',
53
+ hilbert: Number.parseInt(f.hilbert || '0', 10) || 0,
54
+ layer: f.layer || '',
55
+ class: f.class || '',
56
+ g1024: Number.parseInt(f.g1024 || '-1', 10),
57
+ g5: Number.parseInt(f.g5 || '-1', 10),
58
+ sector: f.sector || '',
59
+ status: f.status || '',
60
+ });
61
+ }
62
+ const reported = Number.parseInt(header.entries || footer.rows || String(entries.length), 10);
63
+ return {
64
+ header,
65
+ footer,
66
+ feed_contract: FEED_CONTRACT,
67
+ reported_entries: Number.isFinite(reported) ? reported : entries.length,
68
+ body_sha16: footer.body_sha16 || sha16(text),
69
+ entries,
70
+ };
71
+ }
72
+
73
+ function roleForLayer(layer) {
74
+ const s = String(layer || '').toLowerCase();
75
+ if (s.includes('prof')) return 'PROF';
76
+ if (s.includes('agent')) return 'AGT';
77
+ return 'SUP';
78
+ }
79
+
80
+ function tierForLayer(layer) {
81
+ const s = String(layer || '').toLowerCase();
82
+ if (s.includes('operator')) return 0;
83
+ if (s.includes('helm')) return 1;
84
+ if (s.includes('prof')) return 2;
85
+ return 4;
86
+ }
87
+
88
+ function cleanHex16(s) {
89
+ return /^[0-9a-fA-F]{16}$/.test(String(s || '')) ? String(s).toLowerCase() : '';
90
+ }
91
+
92
+ export function reconcileEntry(entry = {}, opts = {}) {
93
+ const e = isObj(entry) ? entry : {};
94
+ const duplicateNameCount = Number(opts.duplicateNameCount || 1);
95
+ const role = roleForLayer(e.layer);
96
+ const tier = tierForLayer(e.layer);
97
+ let github = null;
98
+ let error = '';
99
+ if (!String(e.name || '').trim() || /[|\r\n]/.test(String(e.name || ''))) {
100
+ error = 'office-name-required-clean';
101
+ } else {
102
+ try {
103
+ github = mintPid({ role, name: e.name, tier, prime: 0, nest: 1 });
104
+ if (!github.name) {
105
+ github = null;
106
+ error = 'github-name-empty-after-sanitize';
107
+ }
108
+ } catch (err) {
109
+ error = err?.message || 'mintPid-failed';
110
+ }
111
+ }
112
+ const officePid = cleanHex16(e.pid);
113
+ const officeGlyph = Number(e.g1024);
114
+ const githubSha16 = github?.sha16 || '';
115
+ const githubGlyph = Number(github?.glyph_1024);
116
+ const sha_match = !!officePid && githubSha16.toLowerCase() === officePid;
117
+ const glyph_match = Number.isFinite(officeGlyph) && Number.isFinite(githubGlyph) && officeGlyph === githubGlyph;
118
+ const name_canonical = !!github && github.name === e.name;
119
+ const state = !github || !officePid
120
+ ? RECONCILE_STATES.INVALID_OFFICE_ROW
121
+ : (sha_match && glyph_match ? RECONCILE_STATES.MATCH : RECONCILE_STATES.ALIAS_REQUIRED);
122
+ return {
123
+ name: e.name || '',
124
+ layer: e.layer || '',
125
+ class: e.class || '',
126
+ status: e.status || '',
127
+ hilbert: e.hilbert || 0,
128
+ office_pid: officePid || e.pid || '',
129
+ office_g1024: Number.isFinite(officeGlyph) ? officeGlyph : '',
130
+ github_role: role,
131
+ github_pid: github?.pid || 'none',
132
+ github_name: github?.name || 'none',
133
+ github_sha16: githubSha16 || 'none',
134
+ github_g1024: Number.isFinite(githubGlyph) ? githubGlyph : '',
135
+ sha_match,
136
+ glyph_match,
137
+ name_canonical,
138
+ duplicate_name: duplicateNameCount > 1,
139
+ duplicate_name_count: duplicateNameCount,
140
+ registered_not_canonical: e.status && e.status !== 'CANONICAL',
141
+ state,
142
+ error,
143
+ };
144
+ }
145
+
146
+ export function reconcileSupervisorFeed(input = '') {
147
+ const feed = parseSupervisorFeed(input);
148
+ const nameCounts = new Map();
149
+ for (const e of feed.entries) nameCounts.set(e.name, (nameCounts.get(e.name) || 0) + 1);
150
+ const aliases = feed.entries.map((entry) => reconcileEntry(entry, { duplicateNameCount: nameCounts.get(entry.name) || 1 }));
151
+ const counts = {
152
+ entries: aliases.length,
153
+ reported_entries: feed.reported_entries,
154
+ match: aliases.filter((a) => a.state === RECONCILE_STATES.MATCH).length,
155
+ alias_required: aliases.filter((a) => a.state === RECONCILE_STATES.ALIAS_REQUIRED).length,
156
+ invalid_office_row: aliases.filter((a) => a.state === RECONCILE_STATES.INVALID_OFFICE_ROW).length,
157
+ noncanonical_name: aliases.filter((a) => !a.name_canonical).length,
158
+ duplicate_name_rows: aliases.filter((a) => a.duplicate_name).length,
159
+ duplicate_names: [...nameCounts.values()].filter((n) => n > 1).length,
160
+ registered_not_canonical: aliases.filter((a) => a.registered_not_canonical).length,
161
+ };
162
+ return {
163
+ tool: EXPANSION_ID,
164
+ feed_contract: FEED_CONTRACT,
165
+ feed_ts: feed.header.ts || '',
166
+ office: feed.header.office || '',
167
+ body_sha16: feed.body_sha16,
168
+ process_launch: 0,
169
+ descriptor_only: true,
170
+ counts,
171
+ aliases,
172
+ };
173
+ }
174
+
175
+ export function emitRows(report, opts = {}) {
176
+ try {
177
+ const r = isObj(report) && Array.isArray(report.aliases) ? report : reconcileSupervisorFeed('');
178
+ const limit = Number.isFinite(opts.limit) ? Math.max(0, Math.floor(opts.limit)) : r.aliases.length;
179
+ const rows = [
180
+ `GLORECHDR|tool=${EXPANSION_ID}|feed_contract=${safe(r.feed_contract)}|feed_ts=${safe(r.feed_ts)}|office=${safe(r.office)}|entries=${safe(r.counts.entries)}|reported_entries=${safe(r.counts.reported_entries)}|body_sha16=${safe(r.body_sha16)}|descriptor_only=1|process_launch=0|json=0`,
181
+ ];
182
+ for (const a of r.aliases.slice(0, limit)) {
183
+ rows.push(`GLORECALIAS|name=${safe(a.name)}|state=${safe(a.state)}|office_pid=${safe(a.office_pid)}|office_g1024=${safe(a.office_g1024)}|github_role=${safe(a.github_role)}|github_name=${safe(a.github_name)}|github_sha16=${safe(a.github_sha16)}|github_g1024=${safe(a.github_g1024)}|github_pid=${safe(a.github_pid)}|sha_match=${a.sha_match ? 1 : 0}|glyph_match=${a.glyph_match ? 1 : 0}|name_canonical=${a.name_canonical ? 1 : 0}|duplicate_name=${a.duplicate_name ? 1 : 0}|duplicate_name_count=${safe(a.duplicate_name_count)}|hilbert=${safe(a.hilbert)}|layer=${safe(a.layer)}|status=${safe(a.status)}|json=0`);
184
+ }
185
+ rows.push(`GLORECSUM|entries=${safe(r.counts.entries)}|emitted=${safe(Math.min(limit, r.aliases.length))}|match=${safe(r.counts.match)}|alias_required=${safe(r.counts.alias_required)}|invalid_office_row=${safe(r.counts.invalid_office_row)}|noncanonical_name=${safe(r.counts.noncanonical_name)}|duplicate_names=${safe(r.counts.duplicate_names)}|duplicate_name_rows=${safe(r.counts.duplicate_name_rows)}|registered_not_canonical=${safe(r.counts.registered_not_canonical)}|json=0`);
186
+ rows.push('GLORECGATE|github_pid_is_proposed=1|alias_map_descriptor_only=1|no_office_write=1|no_mint=1|no_cutover=1|no_spawn=1|process_launch=0|oldlearnnewpidlaw=github-pids-remain-proposed-until-live-office-alias-map-byte-receipted|json=0');
187
+ return rows;
188
+ } catch {
189
+ return [
190
+ `GLORECHDR|tool=${EXPANSION_ID}|feed_contract=${FEED_CONTRACT}|entries=0|reported_entries=0|descriptor_only=1|process_launch=0|json=0`,
191
+ 'GLORECERROR|error=emit-threw-on-hostile-input|json=0',
192
+ 'GLORECGATE|github_pid_is_proposed=1|alias_map_descriptor_only=1|no_office_write=1|no_mint=1|no_cutover=1|no_spawn=1|process_launch=0|oldlearnnewpidlaw=github-pids-remain-proposed-until-live-office-alias-map-byte-receipted|json=0',
193
+ ];
194
+ }
195
+ }
196
+
197
+ export const SAMPLE_FEED = `FEEDHDR|schema=hbp.fabric.supervisor.feed.v1|ts=2026-06-13T21:27:21.857Z|office=D:/PID-Registration-Office|entries=6|cap_joined=37|authority=OP-JESSE-BUILD-and-upgrade-2026-06-10|json=0
198
+ REG|name=OP-JESSE|pid=76c91471d760073b|hilbert=908|layer=operator|class=operator_class_agent|g1024=113|g5=2|sector=?|status=CANONICAL
199
+ REG|name=CEO-ASOLARIA-INSTANCES|pid=9198ed80b00dddee|hilbert=892|layer=helm|class=supervisor_of_supervisors_role_seat|g1024=858|g5=0|sector=?|status=CANONICAL
200
+ REG|name=CEO-ASOLARIA-INSTANCES|pid=9198ed80b00dddee|hilbert=892|layer=agent|class=supervisor_of_supervisors_role_seat|g1024=858|g5=1|sector=?|status=CANONICAL
201
+ REG|name=cube_cubed_sealer|pid=adaa7553334e9d40|hilbert=1006|layer=supervisor|class=hyperbehcs_supervisor_entity|g1024=339|g5=3|sector=?|status=CANONICAL
202
+ REG|name=PLANB-FABRIC-SUPERVISOR-V1|pid=250d55bd01957814|hilbert=1622|layer=agent|class=planb_fabric_supervisor_advisory|g1024=269|g5=2|sector=planb|status=REGISTERED
203
+ REG|name=ASOLARIA-SLICE-ENGINE-LAW|pid=3cb83d616e3dd777|hilbert=1630|layer=supervisor|class=agent_supervisor|g1024=353|g5=2|sector=supervisor|status=CANONICAL
204
+ FEEDFTR|rows=6|body_sha16=SAMPLE`;
205
+
206
+ export function selfTest() {
207
+ const report = reconcileSupervisorFeed(SAMPLE_FEED);
208
+ const byName = new Map(report.aliases.map((a) => [a.name, a]));
209
+ const rows = emitRows(report, { limit: 4 });
210
+ const checks = [
211
+ ['sample-count', report.counts.entries === 6 && report.counts.reported_entries === 6],
212
+ ['canonical-op-matches', byName.get('OP-JESSE')?.state === RECONCILE_STATES.MATCH],
213
+ ['canonical-looking-legacy-alias-counted', byName.get('CEO-ASOLARIA-INSTANCES')?.state === RECONCILE_STATES.ALIAS_REQUIRED && byName.get('CEO-ASOLARIA-INSTANCES')?.name_canonical === true],
214
+ ['noncanonical-underscore-alias-required', byName.get('cube_cubed_sealer')?.state === RECONCILE_STATES.ALIAS_REQUIRED && byName.get('cube_cubed_sealer')?.name_canonical === false],
215
+ ['duplicate-name-counted', report.counts.duplicate_names === 1 && report.counts.duplicate_name_rows === 2],
216
+ ['registered-not-canonical-counted', report.counts.registered_not_canonical === 1],
217
+ ['gate-held-safe', rows.some((row) => row.startsWith('GLORECGATE|') && row.includes('no_mint=1') && row.includes('no_cutover=1'))],
218
+ ['hbp-only', rows.every((row) => row.endsWith('|json=0') && !/[\r\n]/.test(row) && !row.includes('{"'))],
219
+ ['limit-does-not-affect-summary', rows.some((row) => row.startsWith('GLORECSUM|') && row.includes('entries=6') && row.includes('emitted=4'))],
220
+ ].map(([name, ok]) => ({ name, ok: Boolean(ok) }));
221
+ return { ok: checks.every((c) => c.ok), checks };
222
+ }
223
+
224
+ const isMain = process.argv[1] && fileURLToPath(import.meta.url) === resolve(process.argv[1]);
225
+ if (isMain) {
226
+ if (process.argv.includes('--self-test')) {
227
+ const r = selfTest();
228
+ for (const c of r.checks) console.log(`${c.ok ? 'PASS' : 'FAIL'} ${c.name}`);
229
+ process.exit(r.ok ? 0 : 1);
230
+ }
231
+ const limitArg = process.argv.find((arg) => arg.startsWith('--limit='));
232
+ const limit = limitArg ? Number(limitArg.slice('--limit='.length)) : undefined;
233
+ const hbp = process.argv.includes('--stdin') ? readFileSync(0, 'utf8') : SAMPLE_FEED;
234
+ for (const row of emitRows(reconcileSupervisorFeed(hbp), { limit })) console.log(row);
235
+ }
tools/behcs/github-live-office-reconcile-expansion.mjs.sha256 ADDED
@@ -0,0 +1 @@
 
 
1
+ B045686E3B027E6A01AE81A83C7FD3C872DAAE08F2F92951F8FBA71CB7EA7804 github-live-office-reconcile-expansion.mjs