fix: expose HWLAB v03 git mirror status

This commit is contained in:
Codex
2026-06-08 06:50:37 +00:00
parent fb8c1aaebf
commit 10abbc0467
2 changed files with 57 additions and 14 deletions
+49 -13
View File
@@ -4693,14 +4693,21 @@ export function parseGitMirrorStatusRefs(raw: string): { refs: Record<string, st
try {
const parsed = record(JSON.parse(line.slice("refs=".length)) as unknown);
const refs = record(parsed.refs);
const parsedRefs: Record<string, string | null> = {};
for (const [key, value] of Object.entries(refs)) parsedRefs[key] = stringOrNull(value);
return {
refs: {
...parsedRefs,
localV02: stringOrNull(refs.localV02),
githubV02: stringOrNull(refs.githubV02),
localG14: stringOrNull(refs.localG14),
githubG14: stringOrNull(refs.githubG14),
localGitops: stringOrNull(refs.localGitops),
githubGitops: stringOrNull(refs.githubGitops),
localV03: stringOrNull(refs.localV03),
githubV03: stringOrNull(refs.githubV03),
localV03Gitops: stringOrNull(refs.localV03Gitops),
githubV03Gitops: stringOrNull(refs.githubV03Gitops),
},
pendingFlush: typeof parsed.pendingFlush === "boolean" ? parsed.pendingFlush : null,
};
@@ -4730,15 +4737,23 @@ export function gitMirrorStatusSummary(raw: string): Record<string, unknown> {
const githubV02 = refs.refs.githubV02 ?? null;
const localGitops = refs.refs.localGitops ?? null;
const githubGitops = refs.refs.githubGitops ?? null;
const localV03 = refs.refs.localV03 ?? null;
const githubV03 = refs.refs.githubV03 ?? null;
const localV03Gitops = refs.refs.localV03Gitops ?? null;
const githubV03Gitops = refs.refs.githubV03Gitops ?? null;
const sourceInSync = Boolean(localV02 && githubV02 && localV02 === githubV02);
const gitopsInSync = Boolean(localGitops && githubGitops && localGitops === githubGitops);
return {
localV02,
githubV02,
localV03,
githubV03,
localG14: refs.refs.localG14 ?? null,
githubG14: refs.refs.githubG14 ?? null,
localGitops,
githubGitops,
localV03Gitops,
githubV03Gitops,
pendingFlush: refs.pendingFlush,
lastSync: {
status: stringOrNull(lastSync.status) ?? null,
@@ -4759,6 +4774,8 @@ export function gitMirrorStatusSummary(raw: string): Record<string, unknown> {
flushCommand: refs.pendingFlush === true ? "bun scripts/cli.ts hwlab g14 git-mirror flush --confirm" : null,
sourceInSync,
gitopsInSync,
v03SourceInSync: Boolean(localV03 && githubV03 && localV03 === githubV03),
v03GitopsInSync: Boolean(localV03Gitops && githubV03Gitops && localV03Gitops === githubV03Gitops),
githubInSync: sourceInSync && gitopsInSync,
};
}
@@ -5000,6 +5017,10 @@ function waitForV02GitMirrorPreSync(sourceCommit: string, waitMs: number): Recor
}
function gitMirrorCacheProbeScript(): string {
const runtimeLanesJson = JSON.stringify(hwlabRuntimeLaneIds().map((lane) => {
const spec = hwlabRuntimeLaneSpec(lane);
return { lane, sourceBranch: spec.sourceBranch, gitopsBranch: spec.gitopsBranch };
}));
return [
"printf 'lastSync='; cat /cache/HWLAB.last-sync.json 2>/dev/null || true; printf '\\n'",
"printf 'lastWrite='; cat /cache/HWLAB.last-write.json 2>/dev/null || true; printf '\\n'",
@@ -5015,19 +5036,34 @@ function gitMirrorCacheProbeScript(): string {
" return null;",
" }",
"}",
"const localGitops = rev('refs/heads/v0.2-gitops');",
"const githubGitops = rev('refs/mirror-stage/heads/v0.2-gitops');",
"console.log(JSON.stringify({",
" refs: {",
" localV02: rev('refs/heads/v0.2'),",
" githubV02: rev('refs/mirror-stage/heads/v0.2'),",
" localG14: rev('refs/heads/G14'),",
" githubG14: rev('refs/mirror-stage/heads/G14'),",
" localGitops,",
" githubGitops,",
" },",
" pendingFlush: Boolean(localGitops && githubGitops && localGitops !== githubGitops),",
"}));",
`const runtimeLanes = ${runtimeLanesJson};`,
"const refs = {};",
"for (const spec of runtimeLanes) {",
" const key = spec.lane.toUpperCase();",
" const normalized = key.slice(0, 1) + key.slice(1).toLowerCase();",
" const localSource = rev('refs/heads/' + spec.sourceBranch);",
" const githubSource = rev('refs/mirror-stage/heads/' + spec.sourceBranch);",
" const localGitops = rev('refs/heads/' + spec.gitopsBranch);",
" const githubGitops = rev('refs/mirror-stage/heads/' + spec.gitopsBranch);",
" refs['local' + normalized] = localSource;",
" refs['github' + normalized] = githubSource;",
" refs['local' + normalized + 'Gitops'] = localGitops;",
" refs['github' + normalized + 'Gitops'] = githubGitops;",
" if (spec.lane === 'v02') {",
" refs.localV02 = localSource;",
" refs.githubV02 = githubSource;",
" refs.localGitops = localGitops;",
" refs.githubGitops = githubGitops;",
" }",
"}",
"refs.localG14 = rev('refs/heads/G14');",
"refs.githubG14 = rev('refs/mirror-stage/heads/G14');",
"const pendingFlush = runtimeLanes.some((spec) => {",
" const localGitops = rev('refs/heads/' + spec.gitopsBranch);",
" const githubGitops = rev('refs/mirror-stage/heads/' + spec.gitopsBranch);",
" return Boolean(localGitops && githubGitops && localGitops !== githubGitops);",
"});",
"console.log(JSON.stringify({ refs, pendingFlush }));",
"NODE",
].join("\n");
}