release: native macOS preview, approved graph identity, and guarded CLI failover

This commit is contained in:
public-repo-gate
2026-09-13 16:36:15 +03:00
parent 74c9f07f59
commit 04d0ece7ff
56 changed files with 16087 additions and 4002 deletions
+21 -6
View File
@@ -2,6 +2,7 @@
import { promises as fs } from 'node:fs'
import { existsSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { spawn, spawnSync } from 'node:child_process'
import { resolveVault } from './mnemazine-paths.mjs'
@@ -20,6 +21,7 @@ function arg(name, fallback = '') {
const NEEDS_UPDATE_MAX_DAYS = Number(arg('needs-update-max-days', process.env.MNEMAZINE_NEEDS_UPDATE_MAX_DAYS || '1'))
const STRICT_GRAPH = argv.includes('--strict-graph')
const REQUIRE_DEEP = argv.includes('--require-deep') || process.env.MNEMAZINE_REQUIRE_DEEP === '1'
const BEFORE_ARCHIVE = argv.includes('--before-archive')
// Удаление протухшего маркера графа — только по этому явному флагу.
// Без него маркер остается на месте и ложится в warnings/failures (план П08).
const PRUNE_GRAPH_MARKER = argv.includes('--prune-graph-marker')
@@ -31,6 +33,8 @@ if (argv.includes('--help')) {
Использование: node scripts/mnemazine-complete-check.mjs [флаги]
--vault <путь> корпус (иначе MNEMAZINE_VAULT, last-run.vault или repo-local vault)
--require-deep требовать deep-прогон в last-run (или MNEMAZINE_REQUIRE_DEEP=1)
--before-archive проверить pending_archive перед переносом: inbox ещё полон,
но coverage и остальные гейты обязательны
--strict-graph маркер needs_update — failure, а не warning
--needs-update-max-days N возраст маркера до failure (по умолчанию 1)
--prune-graph-marker удалить протухший маркер graphify-out/needs_update
@@ -115,7 +119,7 @@ function isGraphSemanticFile(file) {
function deepFailures(lastRun) {
const failures = []
if (!lastRun) return ['last run state missing']
if (!lastRun.ok) failures.push(`last run failed: ${(lastRun.failures || [lastRun.failure || 'unknown']).join('; ')}`)
if (!lastRun.ok && !(BEFORE_ARCHIVE && lastRun.phase === 'pending_archive' && lastRun.pre_archive_ready === true)) failures.push(`last run failed: ${(lastRun.failures || [lastRun.failure || 'unknown']).join('; ')}`)
if (lastRun.draft_only) failures.push('last run was draft-only')
if (!lastRun.deep) failures.push('last run was not deep')
if (lastRun.strict_archive_knowledge !== true) failures.push('strict archive knowledge gate was not enabled')
@@ -129,16 +133,26 @@ function deepFailures(lastRun) {
return failures
}
export async function loadSpecCeiling({ root = ROOT, vault, ceiling = process.env.MNEMAZINE_SPEC_CEILING } = {}) {
const file = path.resolve(ceiling || path.join(root, '.mnemazine/state/spec-ceiling.json'))
const baseline = await readJson(file)
if (!baseline) return { file, error: 'spec ceiling has no baseline yet' }
if (typeof baseline.vault !== 'string' || path.resolve(baseline.vault) !== path.resolve(vault)) return { file, error: 'spec ceiling belongs to a different vault' }
return { file, error: null }
}
async function main() {
const failures = []
const warnings = []
const inbox = await activeInboxFiles()
if (inbox.error) failures.push(`inbox unreadable: ${inbox.error}`)
const inboxFiles = inbox.files
if (inboxFiles.length) failures.push(`inbox not empty: ${inboxFiles.length}`)
if (inboxFiles.length && !BEFORE_ARCHIVE) failures.push(`inbox not empty: ${inboxFiles.length}`)
const lastRunFile = path.join(STATE, 'last-run.json')
const lastRun = await readJson(lastRunFile)
if (BEFORE_ARCHIVE && (lastRun?.phase !== 'pending_archive' || lastRun?.pre_archive_ready !== true || lastRun?.archive_pending !== inboxFiles.length)) failures.push('pre-archive state does not match the current inbox')
if (!BEFORE_ARCHIVE && lastRun?.phase === 'pending_archive') failures.push('archive has not completed')
const VAULT = resolveVault({ cli: arg('vault'), env: process.env.MNEMAZINE_VAULT || lastRun?.vault })
const gateEnv = { MNEMAZINE_VAULT: VAULT }
const coverageArgs = ['scripts/mnemazine-coverage-check.mjs', '--vault', VAULT, '--inbox', INBOX, '--json']
@@ -156,12 +170,13 @@ async function main() {
// Потолок провалов спеки в продовом пути (план П06 шаг 6): гейт --spec виден
// приемке, а не только вручную. Ненулевой код прибора потолка → в failures.
const specCeilingFile = path.join(STATE, 'spec-ceiling.json')
if (!existsSync(specCeilingFile)) {
const baseline = await loadSpecCeiling({ vault: VAULT })
const specCeilingFile = baseline.file
if (baseline.error) {
// Свежая установка: потолок спеки — per-machine runtime (план П16, .mnemazine/state
// gitignored), на чистом клоне его нет и сравнивать не с чем. Это «нет данных», а не
// провал: ratchet без базы — no-op. doctor распознает эту строку как no-data (degraded, не fatal).
failures.push('spec ceiling has no baseline yet')
failures.push(baseline.error)
} else {
const specCeiling = await run(process.execPath, ['scripts/mnemazine-spec-ceiling.mjs', '--check', '--vault', VAULT, '--ceiling', specCeilingFile], gateEnv)
if (!specCeiling.ok) failures.push(`spec ceiling failed: ${specCeiling.stderr || specCeiling.stdout}`)
@@ -238,7 +253,7 @@ async function main() {
if (!result.ok) process.exit(1)
}
main().catch(error => {
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) main().catch(error => {
console.error(error.message || error)
process.exit(1)
})