Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- The MCP bundle now includes `lib/memory-contract.mjs` and `lib/continuity.mjs`; packaging and native materialization include both modules.
- Hoje calls the existing word-presence evaluation “Retrieval checks” to distinguish it from model-answer accuracy.

### Fixed
- macOS KeepMind Corp builds now ad-hoc sign the complete app bundle and fail packaging if strict signature verification fails, fixing inconsistent resource seals.

### Security
- Continuity writes check revisions under a local project lock. Human review, lesson confirmation and feedback cannot be granted through model-supplied arguments.
- Generic MCP writes refuse protected project/fact aliases, evidence cannot use symlinks or cross-space paths, and rejected writes retain audit coverage.
Expand Down
3 changes: 3 additions & 0 deletions electron-builder.corp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ appId: com.keepmind.corp
productName: KeepMind Corp
icon: build/icon
extends: electron-builder.yml
afterSign: scripts/mac-adhoc-sign.cjs
directories:
output: dist-corp
files:
Expand Down Expand Up @@ -29,6 +30,8 @@ publish:
owner: criptogus
repo: keepmind-corp
mac:
# The afterSign hook seals the complete bundle with a deterministic ad-hoc signature.
identity: null
extendInfo:
CFBundleDisplayName: KeepMind Corp
artifactName: KeepMind-Corp-${version}-${arch}-mac.${ext}
Expand Down
16 changes: 16 additions & 0 deletions scripts/mac-adhoc-sign.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { execFileSync } = require('node:child_process')
const { join } = require('node:path')

// Corp only: avoid changing the main app's legacy safeStorage/keychain identity.
// In app-builder-lib 25.1.8 mac signApp returns true even with identity: null,
// so afterSign runs after all resource/plist changes, including for --mac --dir.
module.exports = function macAdhocSign(context) {
if (process.platform !== 'darwin' || context.electronPlatformName !== 'darwin') return

const app = join(context.appOutDir, `${context.packager.appInfo.productFilename}.app`)
// Use argv directly so spaces in the product name/path need no shell quoting.
execFileSync('codesign', ['--force', '--deep', '--sign', '-', app], { stdio: 'inherit' })
execFileSync('codesign', ['--verify', '--deep', '--strict', '--verbose=2', app], { stdio: 'inherit' })
// codesign writes signature details to stderr; retain them in the build log.
execFileSync('codesign', ['-dv', '--verbose=4', app], { stdio: 'inherit' })
}
67 changes: 67 additions & 0 deletions tests/mac-adhoc-sign.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { createRequire } from 'node:module'
import { readFileSync } from 'node:fs'
import { join } from 'node:path'
import { afterEach, describe, expect, it, vi } from 'vitest'

const require = createRequire(import.meta.url)
const childProcess = require('node:child_process')
const { load } = require('js-yaml')
const context = {
electronPlatformName: 'darwin',
appOutDir: '/tmp/corp build/mac-arm64',
packager: { appInfo: { productFilename: 'KeepMind Corp' } }
}

// Spy on the CommonJS builtin used by the builder's CommonJS hook.
function setup(platform = 'darwin') {
vi.spyOn(process, 'platform', 'get').mockReturnValue(platform as NodeJS.Platform)
const exec = vi.spyOn(childProcess, 'execFileSync').mockImplementation(() => Buffer.alloc(0))
const file = require.resolve('../scripts/mac-adhoc-sign.cjs')
delete require.cache[file]
return { exec, hook: require(file) }
}

afterEach(() => vi.restoreAllMocks())

describe('Corp macOS ad-hoc signing', () => {
it('signs the whole product bundle, strictly verifies it, and logs its signature in order', () => {
const { exec, hook } = setup()
hook(context)
const app = join(context.appOutDir, 'KeepMind Corp.app')
expect(exec.mock.calls).toEqual([
['codesign', ['--force', '--deep', '--sign', '-', app], { stdio: 'inherit' }],
['codesign', ['--verify', '--deep', '--strict', '--verbose=2', app], { stdio: 'inherit' }],
['codesign', ['-dv', '--verbose=4', app], { stdio: 'inherit' }]
])
})

it.each(['linux', 'win32'])('skips on a %s host', platform => {
const { exec, hook } = setup(platform)
hook(context)
expect(exec).not.toHaveBeenCalled()
})

it('skips non-mac targets on a mac host', () => {
const { exec, hook } = setup()
hook({ ...context, electronPlatformName: 'win32' })
expect(exec).not.toHaveBeenCalled()
})

it.each([1, 2])('fails the build when codesign call %i fails', call => {
const { exec, hook } = setup()
const failure = new Error('codesign failed')
for (let i = 1; i < call; i++) exec.mockImplementationOnce(() => Buffer.alloc(0))
exec.mockImplementationOnce(() => { throw failure })
expect(() => hook(context)).toThrow(failure)
expect(exec).toHaveBeenCalledTimes(call)
})

it('wires the Corp hook after signing and disables automatic certificate selection', () => {
const config = load(readFileSync('electron-builder.corp.yml', 'utf8'))
expect(config.afterSign).toBe('scripts/mac-adhoc-sign.cjs')
expect(config.mac.identity).toBeNull()
expect(typeof require(join(process.cwd(), config.afterSign))).toBe('function')
const main = load(readFileSync('electron-builder.yml', 'utf8'))
expect(main.afterSign).toBeUndefined()
})
})
Loading