Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c67b9cb
fix(ai): Resolve issue #2007 - Introduce a resumable goal-session con…
Aug 31, 2026
be4ed9a
feat(ai): Implemented the PR #2017 follow-up without committing.
Aug 31, 2026
2d3ac53
feat(ai): I've completed the corrective implementation from owner com…
Aug 31, 2026
37c2437
feat(ai): All production files are well within the 400-line limit and…
Aug 31, 2026
8d60a45
feat(ai): Implemented bounded Phase A only.
Aug 31, 2026
48c89c5
feat(ai): Implemented the bounded Phase B follow-up from head `8d60a4…
Aug 31, 2026
14b7762
feat(ai): Implemented the bounded Phase B follow-up, left uncommitted…
Aug 31, 2026
988a375
feat(ai): Implemented the bounded PR #2017 follow-up without committing.
Aug 31, 2026
b0c19ba
feat(ai): Implemented the two additional PR #2017 runtime corrections:
Aug 31, 2026
6c561b2
feat(ai): Implemented the PR #2017 owner-validation addendum, scoped …
Aug 31, 2026
c55ceb9
feat(ai): Implemented the consolidated runtime correction and left it…
Aug 31, 2026
b7a8ee6
feat(ai): Implemented all five PR #2017 audit fixes and left them unc…
Aug 31, 2026
10cea2f
feat(ai): Implemented all six follow-up blockers at unchanged head `b…
Aug 31, 2026
20e5354
feat(ai): Implemented all three re-audit blockers at exact head `10ce…
Aug 31, 2026
a001216
feat(ai): Implemented all four HIGH blockers at exact head `20e53540f…
Aug 31, 2026
71ce385
feat(ai): Implemented all five HIGH blockers at unchanged head `a0012…
Aug 31, 2026
9f5fa1f
feat(ai): Implemented the queued owner addendum at exact head `71ce38…
Aug 31, 2026
80591e6
feat(ai): Implemented all seven blockers and left the PR unmerged/unc…
Aug 31, 2026
4722b02
feat(ai): Implemented all five blocking invariants while preserving t…
Aug 31, 2026
8f04732
feat(ai): Implemented all five runtime-foundation corrections:
Aug 31, 2026
a100db2
feat(ai): Implemented the complete eight-item correction from exact h…
Sep 1, 2026
613fff6
feat(ai): Implemented the eight requested runtime-boundary correction…
Sep 1, 2026
24a6816
feat(ai): Implemented the PR #2017 lint correction from exact head `6…
Sep 1, 2026
af3102f
feat(ai): Implemented the six requested correction areas without comm…
Sep 1, 2026
8f2e048
feat(ai): Implemented bounded slice 1 from exact unchanged head `af31…
Sep 2, 2026
4b605c2
feat(ai): Implemented the slice-1 re-audit correction without committ…
Sep 2, 2026
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import type {
GoalModelChangeHistoryPort, GoalProviderEffectStage, GoalProviderFirstEffectPort,
GoalProviderOperationFence, GoalSessionEventSink, GoalSessionMessagePort,
GoalSessionStatePort, GoalSessionTerminalPort, GoalSessionTransitionPort,
GoalStartedProviderEffect,
} from './contract.js';
import type { GoalSessionRecoveryPort, GoalSessionRuntimePorts } from './runtimePorts.js';
import { GoalSessionContractError } from './errors.js';
import {
assertStartedProviderEffect, cleanupStartedProviderEffect, startedProviderEffectCleanup,
} from './providerEffectProtocol.js';

export type GoalProviderEffectClaimResult = 'claimed' | 'already_claimed';

/**
* Control-owned transaction hook. Implementations persist the stage claim before
* `runClaimedProviderEffect`, then revalidate owner/state/fence inside the same
* authoritative transaction that calls the synchronous callback and writes its
* started receipt. A duplicate or abandoned claim is in doubt and is never run.
*/
export interface GoalProviderEffectTransactionDomain {
claimProviderEffect(
fence: GoalProviderOperationFence,
stage: GoalProviderEffectStage,
): Promise<GoalProviderEffectClaimResult>;
runClaimedProviderEffect<T>(
fence: GoalProviderOperationFence,
stage: GoalProviderEffectStage,
effect: () => GoalStartedProviderEffect<T>,
): Promise<GoalStartedProviderEffect<T>>;
}

/** Ports supplied by the one authoritative migrated control repository. */
export interface GoalSessionAuthoritativeTransactionDomain {
state: GoalSessionStatePort;
transitions: GoalSessionTransitionPort;
events: GoalSessionEventSink;
terminal: GoalSessionTerminalPort;
messages: GoalSessionMessagePort;
modelChanges: GoalModelChangeHistoryPort;
providerEffects: GoalProviderEffectTransactionDomain;
}

/**
* Production composition adapter only: it owns no tables or SQLite connection.
* Missing control-domain injection is a construction error; there is no memory
* fallback. The injected domain is responsible for global session ownership.
*/
export class AuthoritativeGoalSessionRuntimePorts implements GoalProviderFirstEffectPort {
constructor(
private readonly domain: GoalSessionAuthoritativeTransactionDomain,
private readonly recovery: GoalSessionRecoveryPort,
) {
if (!domain?.state || !domain.transitions || !domain.events || !domain.terminal
|| !domain.messages || !domain.modelChanges || !domain.providerEffects
|| typeof domain.providerEffects.claimProviderEffect !== 'function'
|| typeof domain.providerEffects.runClaimedProviderEffect !== 'function'
|| typeof recovery?.inspectContainer !== 'function' || typeof recovery.inspectRepository !== 'function') {
throw new GoalSessionContractError(
'Goal runtime requires an authoritative transaction domain', 'AUTHORITATIVE_DOMAIN_MISSING',
);
}
}

asRuntimePorts(): GoalSessionRuntimePorts {
return {
state: this.domain.state,
transitions: this.domain.transitions,
events: this.domain.events,
terminal: this.domain.terminal,
messages: this.domain.messages,
recovery: this.recovery,
modelChanges: this.domain.modelChanges,
providerFirstEffects: this,
};
}

async start<T>(
fence: GoalProviderOperationFence,
stage: GoalProviderEffectStage,
effect: () => GoalStartedProviderEffect<T>,
): Promise<T> {
const claim = await this.domain.providerEffects.claimProviderEffect(fence, stage);
if (claim !== 'claimed') throw new GoalSessionContractError(
'Provider effect stage is already claimed and remains in doubt', 'PROVIDER_EFFECT_IN_DOUBT',
);
let started: GoalStartedProviderEffect<T> | undefined;
let committed: GoalStartedProviderEffect<T>;
let cleanup: GoalStartedProviderEffect<unknown>['cleanup'] | undefined;
try {
committed = await this.domain.providerEffects.runClaimedProviderEffect(fence, stage, () => {
const candidate: unknown = effect();
cleanup = startedProviderEffectCleanup(candidate);
assertStartedProviderEffect<T>(candidate);
started = candidate;
return candidate;
});
assertStartedProviderEffect<T>(committed);
if (committed !== started) throw new GoalSessionContractError(
'Authoritative domain returned a different started-effect handle', 'INVALID_FIRST_EFFECT_HANDLE',
);
} catch (error) {
if (started || cleanup) {
try {
if (started) await cleanupStartedProviderEffect(started);
else await cleanup!.run();
}
catch {
throw new GoalSessionContractError(
'Started provider effect cleanup failed; durable stage remains in doubt',
'PROVIDER_EFFECT_CLEANUP_FAILED',
);
}
}
throw error;
}
return committed.completion;
}
}
Loading
Loading