Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
80bdc21
test(architecture): require runtime bounded-context map
seonghobae Sep 1, 2026
87017d5
arch: establish Noema runtime context map
seonghobae Sep 1, 2026
f6ee520
docs: link runtime context map
seonghobae Sep 1, 2026
ef4fabb
test(architecture): bind context map to canonical authority
seonghobae Sep 1, 2026
91a5c5f
test(runtime): define fail-closed execution lifecycle
seonghobae Sep 1, 2026
89beb96
feat(runtime): add fail-closed execution lifecycle
seonghobae Sep 1, 2026
37b9470
docs(changelog): record runtime bounded-context gate
seonghobae Sep 1, 2026
50472c1
test(runtime): pin immutable released-contract boundary
seonghobae Sep 1, 2026
689b007
test(state-checkpoint): define fail-closed checkpoint admission
seonghobae Sep 1, 2026
09dbd43
feat(state-checkpoint): admit monotonic idempotent checkpoints
seonghobae Sep 1, 2026
6334fc8
test(state-checkpoint): reject ambiguous execution identities
seonghobae Sep 1, 2026
63d1996
fix(state-checkpoint): bound canonical execution identity
seonghobae Sep 1, 2026
04467e5
docs(runtime): mark checkpoint admission as candidate truth
seonghobae Sep 1, 2026
47be313
test(state-checkpoint): detach admitted checkpoint state
seonghobae Sep 1, 2026
8ca448b
fix(state-checkpoint): freeze admitted checkpoint snapshots
seonghobae Sep 1, 2026
efe918d
test(agent-runtime): require idempotent duplicate lifecycle delivery
seonghobae Sep 1, 2026
2b8d3de
feat(agent-runtime): make duplicate lifecycle signals idempotent
seonghobae Sep 1, 2026
416fa79
test(architecture): require runtime PRD and ADR authority
seonghobae Sep 1, 2026
6bab0b8
docs(adr): define runtime orchestration bounded contexts
seonghobae Sep 1, 2026
b1f57e7
docs(prd): define candidate runtime orchestration requirements
seonghobae Sep 1, 2026
e379e6e
docs(adr): index runtime orchestration decision
seonghobae Sep 1, 2026
6b82542
test(agent-runtime): bind lifecycle signals to execution identity
seonghobae Sep 1, 2026
d425318
test(state-checkpoint): snapshot accessor-backed authority once
seonghobae Sep 1, 2026
8609bf1
refactor(runtime): share canonical execution identity contract
seonghobae Sep 1, 2026
b71b24f
fix(agent-runtime): bind transitions to execution identity
seonghobae Sep 1, 2026
0c81b00
fix(state-checkpoint): snapshot authority before validation
seonghobae Sep 1, 2026
a9cba35
docs(runtime): bind FR-022 to released context contracts
seonghobae Sep 1, 2026
cb45285
docs(runtime): keep candidate truth explicit
seonghobae Sep 1, 2026
2e99118
fix(docs): scope release requirement to Context Graph boundary
seonghobae Sep 1, 2026
9afedfd
test(runtime): reject coerced execution identities
seonghobae Sep 1, 2026
b977984
fix(runtime): reject coerced execution identities
seonghobae Sep 1, 2026
03c8802
test(checkpoint): reject coerced state digests
seonghobae Sep 1, 2026
109f30a
fix(checkpoint): reject coerced state digests
seonghobae Sep 1, 2026
2e09b23
test(runtime): reject coerced lifecycle state and signal
seonghobae Sep 1, 2026
abe9b80
fix(runtime): reject coerced lifecycle state and signal
seonghobae Sep 1, 2026
31030a3
test(context-fabric): require immutable released contract admission
seonghobae Sep 1, 2026
88c6782
feat(context-fabric): admit immutable released contract evidence
seonghobae Sep 1, 2026
e2f8a4e
test(context): reject self-asserted release authority
seonghobae Sep 1, 2026
5a98721
fix(context): fail closed on unverified release claims
seonghobae Sep 1, 2026
cd1e4f3
test(context): require trusted release authority admission
seonghobae Sep 1, 2026
1f43aed
fix(context): authenticate pinned release authority
seonghobae Sep 1, 2026
15a5768
merge(main): restack runtime bounded-context work on current protecte…
seonghobae Sep 1, 2026
5cdec7a
test(context-fabric): require promotion evidence
seonghobae Sep 1, 2026
497be28
fix(context-fabric): bind promotion evidence
seonghobae Sep 1, 2026
272d75a
test(context-fabric): reject prerelease production pins
seonghobae Sep 1, 2026
0833d0e
docs(changelog): record runtime promotion boundary
seonghobae Sep 1, 2026
7cf66d5
test(context-fabric): require exact assertion profile identity
seonghobae Sep 1, 2026
8443133
feat(context-fabric): bind exact assertion profile identity
seonghobae Sep 1, 2026
f47cf62
docs(changelog): record exact Context Graph profile admission
seonghobae Sep 1, 2026
cf063d6
merge: converge runtime bounded contexts onto current main
seonghobae Sep 1, 2026
dfd4fdf
docs(runtime): satisfy public lifecycle API contract
seonghobae Sep 1, 2026
22bd732
docs(context): document release admission API contracts
seonghobae Sep 1, 2026
2ca6bc5
docs(runtime): document execution identity validator
seonghobae Sep 1, 2026
0c016b4
docs(checkpoint): document admission API contract
seonghobae Sep 1, 2026
4dabc98
test(context-fabric): cover immutable release authority boundaries
seonghobae Sep 1, 2026
d2b6bbf
fix(context-fabric): expose immutable release snapshots
seonghobae Sep 1, 2026
5f74d47
merge: converge runtime bounded-context lane with current protected main
seonghobae Sep 1, 2026
8316b8e
test(checkpoint): freeze admission authority envelope
seonghobae Sep 2, 2026
8e41e4a
fix(checkpoint): freeze admission authority envelope
seonghobae Sep 2, 2026
1bbe959
docs(changelog): record immutable checkpoint admission
seonghobae Sep 2, 2026
31db5c7
test(context): reject null release candidates through admission error
seonghobae Sep 2, 2026
c39f967
fix(context): type malformed release evidence
seonghobae Sep 2, 2026
c5bac0c
test(runtime): define workflow task execution contract RED
seonghobae Sep 2, 2026
0cc21c8
feat(runtime): admit bounded workflow task plans
seonghobae Sep 2, 2026
60fc7f9
test(runtime): reject workflow admission accessor races
seonghobae Sep 2, 2026
2b16283
fix(runtime): snapshot workflow admission authority once
seonghobae Sep 2, 2026
f477338
docs(runtime): record bounded workflow task candidate
seonghobae Sep 2, 2026
911e552
test(workflow): bind state and bound untrusted iteration
seonghobae Sep 2, 2026
6a34316
fix(workflow): snapshot bounded task execution evidence
seonghobae Sep 2, 2026
d5e974d
test(workflow): bind existing state fixtures to execution
seonghobae Sep 2, 2026
6202198
test(checkpoint): snapshot retained authority before candidate
seonghobae Sep 2, 2026
fddfec8
test(checkpoint): keep retained-order regression single-shot
seonghobae Sep 2, 2026
99684f0
fix(checkpoint): snapshot retained authority before candidate
seonghobae Sep 2, 2026
73cddc6
test(context-fabric): normalize hostile release accessors
seonghobae Sep 2, 2026
c546d7e
fix(context-fabric): normalize hostile release evidence reads
seonghobae Sep 2, 2026
687e6dc
test(workflow): bind state evidence to plan identity
seonghobae Sep 2, 2026
a9f0d6a
test(workflow): require plan identity on plans and states
seonghobae Sep 2, 2026
bf7584c
fix(workflow): bind task state to exact plan identity
seonghobae Sep 2, 2026
edb9157
test(runtime): lock workflow state admission regressions
seonghobae Sep 2, 2026
2f73728
docs(runtime): define selector reservation boundary
seonghobae Sep 2, 2026
72a6dea
test(runtime): cover hostile plan evidence and causal state gaps
seonghobae Sep 2, 2026
3d1c444
fix(runtime): reject causal state gaps and hostile plan accessors
seonghobae Sep 2, 2026
63ff638
test(runtime): cover malformed checkpoint boundary access
seonghobae Sep 2, 2026
0d1c749
test(runtime): cover malformed lifecycle boundary access
seonghobae Sep 2, 2026
a5275a1
fix(runtime): normalize hostile checkpoint boundary errors
seonghobae Sep 2, 2026
557bcde
fix(runtime): normalize hostile lifecycle boundary errors
seonghobae Sep 2, 2026
b6dda53
fix(runtime): preserve concurrency evidence precedence
seonghobae Sep 2, 2026
26403ac
docs(changelog): record workflow runtime admission behavior
seonghobae Sep 2, 2026
dd0843f
test(runtime): cover nested hostile workflow accessors
seonghobae Sep 2, 2026
84520f5
docs(workflow-task-execution): satisfy public API JSDoc contract for …
claude Sep 2, 2026
a93d08a
Merge remote-tracking branch 'origin/chatgpt/runtime-bounded-context-…
claude Sep 2, 2026
5726c8b
ci(temp): normalize hostile capability proxy failures
seonghobae Sep 2, 2026
07a9f50
ci(temp): repair PR528 source-fix parse failure
seonghobae Sep 2, 2026
29444b1
Merge remote-tracking branch 'origin/chatgpt/runtime-bounded-context-…
claude Sep 2, 2026
e9673b3
ci(temp): retire stale PR528 repair workflow
seonghobae Sep 2, 2026
db3b33d
test(context-fabric): cover hostile capability proxy metadata
seonghobae Sep 2, 2026
3444274
ci(temp): green hostile capability proxy regression
seonghobae Sep 2, 2026
0bb8666
chore(ci): remove temporary self-modifying PR528 repair workflow
seonghobae Sep 2, 2026
7be64a0
fix(context-fabric): normalize capability proxy failures
seonghobae Sep 2, 2026
288d7b0
test(context-fabric): bound capability release metadata
seonghobae Sep 2, 2026
6f5d800
fix(context-fabric): bound capability release metadata
seonghobae Sep 2, 2026
10d6d82
fix(context-fabric): normalize hostile capability-array proxy failures
claude Sep 2, 2026
5abd360
fix(runtime-shared): widen isCanonicalExecutionId to accept unknown
claude Sep 2, 2026
9aec7b2
test(workflow-task-execution): close task-plan.ts coverage gap to 100%
claude Sep 2, 2026
fa6fece
Merge remote-tracking branch 'origin/chatgpt/runtime-bounded-context-…
claude Sep 2, 2026
2f42c99
test(workflow): reject unadmitted plan before state mutation
seonghobae Sep 2, 2026
f9f9971
fix(workflow): require admitted plan authority for selection
seonghobae Sep 2, 2026
037bb4c
test(workflow): exercise forged admitted-plan runtime input
seonghobae Sep 2, 2026
5b34e85
Merge protected main into runtime bounded-context fitness
seonghobae 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
101 changes: 101 additions & 0 deletions docs/CONTEXT_MAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Noema Context Map

## Status

This document separates protected behavior from the runtime-orchestration direction. Protected `main` remains the authority for what is shipped. A bounded context listed as a target does not become implemented merely because it appears here.

Noema currently owns an evidence-producing credential and maintenance control plane. Expansion into agent/application runtime orchestration must reuse those existing authority boundaries rather than turning Noema into a model router, a foreign product system of record, or an arbitrary command runner.

## Current protected contexts

### Credential Exchange

Owns GitHub Actions OIDC verification, exact reusable-workflow source identity, replay/rate controls, repository-scoped GitHub App capability minting, and the `/health`, `/ready`, `/exchange` HTTP boundary. Credential evidence is not review, merge, release, deployment, or legal authority.

### Maintenance Control

Owns exact-head/live-base observation, check/review/security evidence separation, short-lived maintainer capability handoff, stale-target refusal, work-conserving repository maintenance, and buyer/audit receipts. It does not own organization governance settings or foreign repository source.

### Isolation Integration

Owns Noema's caller-side contract for bounded quarantine and validator execution. Wardnet, EgressWeave, or another canonical isolation/security product remains authoritative for its own runtime when used. Noema consumes a versioned port/ACL and never copies the security owner's implementation.

### Policy / Approval

Owns the distinction between technical evidence and authority. Model judgement, scanner output, status/check results, sandbox evidence, and generated proposals cannot silently become formal approval or mutation authority.

### Observability

Owns bounded operational evidence for Noema behavior, exact source/run identity, readiness, KPI integrity, and buyer-verifiable receipts. Telemetry must not contain raw bearer tokens, App private keys, unnecessary reasoning payloads, or foreign product state.

### Recovery

Owns bounded retry/timeout/cancellation semantics, fail-closed recovery evidence, rollback preconditions, and stale-target revalidation. Silent retry of side-effecting operations is forbidden.

## Runtime-orchestration target contexts

The following contexts are accepted decomposition targets for new runtime behavior. They are not claims that protected `main` already implements a general-purpose agent runtime.

### Agent Runtime

Owns the lifecycle of one Noema agent/application execution: accepted execution identity, lifecycle state, cancellation, completion, and recovery routing. It does not discover or route models.

### Workflow / Task Execution

Owns explicit workflow/task dependency and execution order, bounded concurrency, idempotent step identity, and side-effect classification. Recursive/unbounded task creation and implicit duplicate side effects are forbidden.

### Tool / Capability Boundary

Owns versioned allowlisted tool/capability descriptors, least-authority invocation, expiry, input/output bounds, and capability provenance. Arbitrary caller/model shell or network authority is not a Noema tool contract.

### State / Checkpoint

Owns versioned runtime checkpoint semantics needed for restart/cancellation/idempotency. Checkpoints contain only Noema runtime state and canonical foreign references; they must not copy another product's domain truth, provider credential state, or unrestricted reasoning/tool payloads.

## Upstream and downstream boundaries

### contextual-orchestrator

`ContextualWisdomLab/contextual-orchestrator` owns model discovery, routing, test-time compute, provider failover, and upstream provider credentials. Noema consumes its versioned gateway contract. Noema must not add direct provider SDKs, provider keys, fallback lists, or model-routing policy as a local substitute.

### context-graph-contracts

`ContextualWisdomLab/context-graph-contracts` is the provider-neutral Shared Kernel for canonical object/authority references, truth status/origin, valid/system time, provenance, Context Assertion, CloudEvents/schema, conformance, and admission contracts.

Noema may integrate only against an immutable released contract package/profile. It must not import sibling repository implementation source or guess a future schema from an open Draft. Runtime/service/API/worker, integration technology, lifecycle/risk/ownership/remediation, and transformation changes can be projected only through the released versioned contract. Agent task/result/reasoning/tool payloads do not become authoritative architecture facts merely by being emitted as events.

### enterprise-architecture-core

`ContextualWisdomLab/enterprise-architecture-core` is the authoritative Enterprise Architecture Decision Plane. Noema publishes or exposes versioned evidence/proposals through the released Context Graph boundary; EA Core decides authoritative architecture state. Noema does not write EA application tables or reinterpret EA truth locally.

### Security and isolation owners

Wardnet, EgressWeave, AppGuardrail, governance-risk-compliance, and other dedicated products retain their own domain truth. Noema integrates via explicit released API/event/evidence contracts and an Anti-Corruption Layer where translation is required.

## Data and integration rules

- cross-service SQL is forbidden; another product's database is never a Noema integration API;
- foreign records are held as canonical references plus bounded provenance/evidence, not copied as Noema-owned truth;
- contract/profile version, provenance, truth status, valid time, and system time remain distinct where the released shared contract defines them;
- absent, unreleased, stale, or non-conformant shared-contract evidence fails closed rather than triggering a source-copy workaround;
- Noema runtime state, model/provider routing state, enterprise-architecture truth, and product-domain truth remain separately authoritative.

## Dependency direction

```text
Noema Agent Runtime / Workflow / Capability / Checkpoint
| | |
| | +--> canonical isolation/security ports
| +-----------------> contextual-orchestrator gateway
+------------------------------> released context-graph-contracts
|
v
enterprise-architecture-core
(authoritative EA decisions)
```

No dependency arrow grants source-write authority to the upstream or downstream repository. Each repository retains its dedicated writer and release/governance process.

## Acceptance for a new runtime slice

A new runtime slice is acceptable only when it has a named owning context, realistic cancellation/restart/checkpoint/idempotency/tool-policy/concurrency/isolation tests as applicable, bounded side effects, exact observability, and an explicit foreign-authority contract. A feature that requires direct provider routing, arbitrary tool authority, ambient secret propagation, unbounded recursion, silent retry, cross-service SQL, or unreleased Context Graph source is outside the accepted Noema boundary.
3 changes: 2 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
| --- | --- |
| 제품이 누구를 위해 무엇을 해야 하는가 | [PRD](./PRD.md) |
| 기술적으로 어떤 invariant를 지켜야 하는가 | [TRD](./TRD.md) |
| bounded context와 외부 authority 관계 | [Context Map](./CONTEXT_MAP.md) |
| runtime/MSA/trust boundary | [Architecture](../ARCHITECTURE.md) |
| 왜 이 결정을 했는가 | [ADR index](./adr/README.md) |
| component/sequence/state/topology 그림 | [UML](./UML.md) |
Expand Down Expand Up @@ -57,4 +58,4 @@ These documents describe **requirements and evidence locations**. Missing real p

## Update rule

A material product/security/authority change should update the smallest complete set among PRD, TRD, Architecture, ADR, UML/ERD, threat models, API, Operability, Test Strategy, Traceability, documentation-gap audit and CHANGELOG. Do not duplicate the same mutable status in many documents when a canonical owner already exists. Remove obsolete PR numbers and transient check conclusions rather than preserving them as timeless architecture facts.
A material product/security/authority change should update the smallest complete set among PRD, TRD, Context Map, Architecture, ADR, UML/ERD, threat models, API, Operability, Test Strategy, Traceability, documentation-gap audit and CHANGELOG. Do not duplicate the same mutable status in many documents when a canonical owner already exists. Remove obsolete PR numbers and transient check conclusions rather than preserving them as timeless architecture facts.
71 changes: 71 additions & 0 deletions src/agent-runtime/execution-lifecycle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/** Lifecycle states owned by Noema's Agent Runtime bounded context. */
Comment thread
seonghobae marked this conversation as resolved.
Resolved
export type ExecutionState =
| "accepted"
| "running"
| "cancellation_requested"
| "succeeded"
| "failed"
| "cancelled";

/** Signals that may advance one execution without creating retry or side-effect authority. */
export type ExecutionSignal =
| "start"
| "request_cancellation"
| "complete_success"
| "complete_failure"
| "confirm_cancelled";

const TERMINAL_EXECUTION_STATES = new Set<ExecutionState>(["succeeded", "failed", "cancelled"]);

const EXECUTION_TRANSITIONS: Readonly<
Partial<Record<ExecutionState, Readonly<Partial<Record<ExecutionSignal, ExecutionState>>>>>
> = {
accepted: {
start: "running",
request_cancellation: "cancellation_requested",
},
running: {
request_cancellation: "cancellation_requested",
complete_success: "succeeded",
complete_failure: "failed",
},
cancellation_requested: {
confirm_cancelled: "cancelled",
},
};
Comment thread
seonghobae marked this conversation as resolved.
Resolved

/** Raised when a caller attempts to manufacture an execution state outside the lifecycle contract. */
export class ExecutionLifecycleError extends Error {
/** State from which the invalid transition was attempted. */
readonly currentState: ExecutionState;

/** Signal rejected by the lifecycle authority. */
readonly signal: ExecutionSignal;

constructor(currentState: ExecutionState, signal: ExecutionSignal) {
super(`invalid execution lifecycle transition: ${currentState} -> ${signal}`);
this.name = "ExecutionLifecycleError";
this.currentState = currentState;
this.signal = signal;
}
}

/** Returns whether an execution has reached an immutable terminal outcome. */
export function isTerminalExecutionState(state: ExecutionState): boolean {
return TERMINAL_EXECUTION_STATES.has(state);
}

/**
* Applies one explicit lifecycle signal.
*
* Cancellation is authoritative once requested: success/failure arriving afterward is rejected as
* stale instead of silently overriding the cancellation decision. Retry/recovery creates a separate
* execution identity and therefore is intentionally outside this state machine.
*/
export function transitionExecutionLifecycle(currentState: ExecutionState, signal: ExecutionSignal): ExecutionState {
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Resolved
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Resolved
const nextState = EXECUTION_TRANSITIONS[currentState]?.[signal];
if (nextState === undefined) {
throw new ExecutionLifecycleError(currentState, signal);
}
return nextState;
Comment thread
seonghobae marked this conversation as resolved.
Resolved
}
47 changes: 47 additions & 0 deletions test/agent-runtime-execution-lifecycle.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { describe, expect, it } from "vitest";

import {
ExecutionLifecycleError,
isTerminalExecutionState,
transitionExecutionLifecycle,
type ExecutionSignal,
type ExecutionState,
} from "../src/agent-runtime/execution-lifecycle";

describe("Agent Runtime execution lifecycle", () => {
it.each<[ExecutionState, ExecutionSignal, ExecutionState]>([
["accepted", "start", "running"],
["accepted", "request_cancellation", "cancellation_requested"],
["running", "request_cancellation", "cancellation_requested"],
["running", "complete_success", "succeeded"],
["running", "complete_failure", "failed"],
["cancellation_requested", "confirm_cancelled", "cancelled"],
])("transitions %s with %s to %s", (current, signal, expected) => {
expect(transitionExecutionLifecycle(current, signal)).toBe(expected);
});

it.each<ExecutionState>(["succeeded", "failed", "cancelled"])("keeps terminal state %s terminal", (state) => {
expect(isTerminalExecutionState(state)).toBe(true);
expect(() => transitionExecutionLifecycle(state, "start")).toThrow(ExecutionLifecycleError);
});

it.each<ExecutionState>(["accepted", "running", "cancellation_requested"])(
"recognizes non-terminal state %s",
(state) => {
expect(isTerminalExecutionState(state)).toBe(false);
},
);

it("rejects completion that arrives after cancellation authority has been recorded", () => {
expect(() => transitionExecutionLifecycle("cancellation_requested", "complete_success")).toThrowError(
/invalid execution lifecycle transition: cancellation_requested -> complete_success/,
);
expect(() => transitionExecutionLifecycle("cancellation_requested", "complete_failure")).toThrowError(
/invalid execution lifecycle transition: cancellation_requested -> complete_failure/,
);
});

it("rejects completion before an accepted execution starts", () => {
expect(() => transitionExecutionLifecycle("accepted", "complete_success")).toThrowError(ExecutionLifecycleError);
});
});
104 changes: 104 additions & 0 deletions test/runtime-bounded-context-fitness.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { readFileSync, readdirSync, statSync } from "node:fs";
import { join, relative } from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";

const ROOT = fileURLToPath(new URL("..", import.meta.url));
const SOURCE_ROOT = join(ROOT, "src");
const DOCS_ROOT = join(ROOT, "docs");

const FORBIDDEN_PROVIDER_DEPENDENCIES = [
"openai",
"@anthropic-ai/sdk",
"@google/generative-ai",
"@google/genai",
"litellm",
] as const;

const FORBIDDEN_FOREIGN_IMPLEMENTATION_MARKERS = [
"ContextualWisdomLab/contextual-orchestrator/src",
"ContextualWisdomLab/context-graph-contracts/src",
"ContextualWisdomLab/enterprise-architecture-core/src",
"ContextualWisdomLab/naruon/src",
"ContextualWisdomLab/wardnet/src",
] as const;
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Resolved

function filesRecursively(directory: string): string[] {
const files: string[] = [];
for (const entry of readdirSync(directory)) {
const path = join(directory, entry);
if (statSync(path).isDirectory()) {
files.push(...filesRecursively(path));
continue;
}
files.push(path);
}
return files;
}

function productionSourceFiles(): string[] {
return filesRecursively(SOURCE_ROOT).filter((path) => path.endsWith(".ts") || path.endsWith(".mjs"));
}

describe("Noema bounded-context fitness", () => {
it("keeps provider routing and foreign product implementation outside Noema production source", () => {
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Resolved
const packageJson = JSON.parse(readFileSync(join(ROOT, "package.json"), "utf8")) as {
dependencies?: Record<string, string>;
devDependencies?: Record<string, string>;
};
const packageNames = new Set([
...Object.keys(packageJson.dependencies ?? {}),
...Object.keys(packageJson.devDependencies ?? {}),
]);

for (const dependency of FORBIDDEN_PROVIDER_DEPENDENCIES) {
expect(packageNames.has(dependency), `${dependency} must remain owned by contextual-orchestrator`).toBe(false);
}

const violations: string[] = [];
for (const file of productionSourceFiles()) {
const source = readFileSync(file, "utf8");
for (const marker of FORBIDDEN_FOREIGN_IMPLEMENTATION_MARKERS) {
if (source.includes(marker)) violations.push(`${relative(ROOT, file)} -> ${marker}`);
}
}
expect(violations).toEqual([]);
Comment thread
seonghobae marked this conversation as resolved.
Resolved
});

it("keeps one canonical Context Map aligned with the PRD current authority", () => {
const canonicalRelativePath = "docs/CONTEXT_MAP.md";
const contextMapPaths = filesRecursively(DOCS_ROOT)
.map((path) => relative(ROOT, path).replaceAll("\\", "/"))
.filter((path) => /(^|\/)CONTEXT_MAP\.md$/i.test(path));
expect(contextMapPaths).toEqual([canonicalRelativePath]);

const contextMap = readFileSync(join(ROOT, canonicalRelativePath), "utf8");
const docsIndex = readFileSync(join(DOCS_ROOT, "README.md"), "utf8");
const prd = readFileSync(join(DOCS_ROOT, "PRD.md"), "utf8");
const currentAuthority = "evidence-producing credential and maintenance control plane";
const requiredBoundaries = [
"Credential Exchange",
"Maintenance Control",
"Agent Runtime",
"Workflow / Task Execution",
"Tool / Capability Boundary",
"State / Checkpoint",
"Isolation Integration",
"Policy / Approval",
"Observability",
"Recovery",
"contextual-orchestrator",
"context-graph-contracts",
"enterprise-architecture-core",
];

expect((docsIndex.match(/\[Context Map\]\(\.\/CONTEXT_MAP\.md\)/g) ?? [])).toHaveLength(1);
expect(contextMap).toContain(currentAuthority);
expect(prd).toContain(currentAuthority);
for (const boundary of requiredBoundaries) {
expect(contextMap).toContain(boundary);
}
expect(contextMap).toContain("released");
expect(contextMap).toContain("cross-service SQL");
Comment thread
seonghobae marked this conversation as resolved.
Resolved
});
});
Loading