// Midnight Sun Digital workflow simulation
export type WorkflowState =
| "discovered"
| "mapped"
| "verified"
| "building"
| "ready";
export interface Requirement {
id: string;
owner: string;
summary: string;
priority: number;
state: WorkflowState;
}
export interface SignalChannel {
id: string;
label: string;
source: string;
confidence: number;
active: boolean;
}
export interface SystemPlan {
requirements: Requirement[];
channels: SignalChannel[];
constraints: ReadonlySet<string>;
createdAt: Date;
}
const requirements: Requirement[] = [
{
id: "REQ-01",
owner: "workflow-01",
summary: "Discovery workflow",
priority: 1,
state: "discovered",
},
{
id: "REQ-02",
owner: "workflow-02",
summary: "Operations workflow",
priority: 2,
state: "mapped",
},
{
id: "REQ-03",
owner: "workflow-03",
summary: "Scheduling workflow",
priority: 3,
state: "verified",
},
{
id: "REQ-04",
owner: "workflow-04",
summary: "Inventory workflow",
priority: 4,
state: "building",
},
{
id: "REQ-05",
owner: "workflow-05",
summary: "Reporting workflow",
priority: 5,
state: "ready",
},
{
id: "REQ-06",
owner: "workflow-06",
summary: "Intake workflow",
priority: 1,
state: "discovered",
},
{
id: "REQ-07",
owner: "workflow-07",
summary: "Routing workflow",
priority: 2,
state: "mapped",
},
{
id: "REQ-08",
owner: "workflow-08",
summary: "Billing workflow",
priority: 3,
state: "verified",
},
{
id: "REQ-09",
owner: "workflow-09",
summary: "Review workflow",
priority: 4,
state: "building",
},
{
id: "REQ-10",
owner: "workflow-10",
summary: "Delivery workflow",
priority: 5,
state: "ready",
},
{
id: "REQ-11",
owner: "workflow-11",
summary: "Support workflow",
priority: 1,
state: "discovered",
},
{
id: "REQ-12",
owner: "workflow-12",
summary: "Security workflow",
priority: 2,
state: "mapped",
},
{
id: "REQ-13",
owner: "workflow-13",
summary: "Analytics workflow",
priority: 3,
state: "verified",
},
{
id: "REQ-14",
owner: "workflow-14",
summary: "Automation workflow",
priority: 4,
state: "building",
},
];
const channels: SignalChannel[] = requirements.map((item, index) => ({
id: "SIG-" + String(index + 1).padStart(2, "0"),
label: item.summary,
source: item.owner,
confidence: 0.72 + (index % 5) * 0.05,
active: item.state !== "ready",
}));
export function mapRequirements(
input: readonly Requirement[],
): Map<string, Requirement> {
return new Map(input.map((item) => [item.id, { ...item }]));
}
export function verifySignals(
input: readonly SignalChannel[],
): SignalChannel[] {
return input.filter((channel) => channel.confidence >= 0.75);
}
export function collectConstraints(
input: readonly Requirement[],
): ReadonlySet<string> {
const constraints = input
.filter((item) => item.priority >= 4)
.map((item) => item.summary);
return new Set(constraints);
}
export async function shapeSystem(): Promise<SystemPlan> {
const mapped = mapRequirements(requirements);
const verified = verifySignals(channels);
const constraints = collectConstraints([...mapped.values()]);
await Promise.resolve();
return {
requirements: [...mapped.values()],
channels: verified,
constraints,
createdAt: new Date(),
};
}
export function readTelemetry(plan: SystemPlan): string[] {
return plan.channels.map((channel) => {
const state = channel.active ? "ACTIVE" : "STABLE";
const confidence = Math.round(channel.confidence * 100);
return channel.id + " / " + state + " / " + confidence + "%";
});
}
export function nextRequirement(
plan: SystemPlan,
): Requirement | undefined {
return [...plan.requirements]
.filter((item) => item.state !== "ready")
.sort((left, right) => right.priority - left.priority)[0];
}
export const systemReady = requirements.every(
(item) => item.state === "ready",
);
// telemetry frame 001 / workflow synchronized
// telemetry frame 002 / workflow synchronized
// telemetry frame 003 / workflow synchronized
// telemetry frame 004 / workflow synchronized
// telemetry frame 005 / workflow synchronized// Midnight Sun Digital workflow simulation
export type WorkflowState =
| "discovered"
| "mapped"
| "verified"
| "building"
| "ready";
export interface Requirement {
id: string;
owner: string;
summary: string;
priority: number;
state: WorkflowState;
}
export interface SignalChannel {
id: string;
label: string;
source: string;
confidence: number;
active: boolean;
}
export interface SystemPlan {
requirements: Requirement[];
channels: SignalChannel[];
constraints: ReadonlySet<string>;
createdAt: Date;
}
const requirements: Requirement[] = [
{
id: "REQ-01",
owner: "workflow-01",
summary: "Discovery workflow",
priority: 1,
state: "discovered",
},
{
id: "REQ-02",
owner: "workflow-02",
summary: "Operations workflow",
priority: 2,
state: "mapped",
},
{
id: "REQ-03",
owner: "workflow-03",
summary: "Scheduling workflow",
priority: 3,
state: "verified",
},
{
id: "REQ-04",
owner: "workflow-04",
summary: "Inventory workflow",
priority: 4,
state: "building",
},
{
id: "REQ-05",
owner: "workflow-05",
summary: "Reporting workflow",
priority: 5,
state: "ready",
},
{
id: "REQ-06",
owner: "workflow-06",
summary: "Intake workflow",
priority: 1,
state: "discovered",
},
{
id: "REQ-07",
owner: "workflow-07",
summary: "Routing workflow",
priority: 2,
state: "mapped",
},
{
id: "REQ-08",
owner: "workflow-08",
summary: "Billing workflow",
priority: 3,
state: "verified",
},
{
id: "REQ-09",
owner: "workflow-09",
summary: "Review workflow",
priority: 4,
state: "building",
},
{
id: "REQ-10",
owner: "workflow-10",
summary: "Delivery workflow",
priority: 5,
state: "ready",
},
{
id: "REQ-11",
owner: "workflow-11",
summary: "Support workflow",
priority: 1,
state: "discovered",
},
{
id: "REQ-12",
owner: "workflow-12",
summary: "Security workflow",
priority: 2,
state: "mapped",
},
{
id: "REQ-13",
owner: "workflow-13",
summary: "Analytics workflow",
priority: 3,
state: "verified",
},
{
id: "REQ-14",
owner: "workflow-14",
summary: "Automation workflow",
priority: 4,
state: "building",
},
];
const channels: SignalChannel[] = requirements.map((item, index) => ({
id: "SIG-" + String(index + 1).padStart(2, "0"),
label: item.summary,
source: item.owner,
confidence: 0.72 + (index % 5) * 0.05,
active: item.state !== "ready",
}));
export function mapRequirements(
input: readonly Requirement[],
): Map<string, Requirement> {
return new Map(input.map((item) => [item.id, { ...item }]));
}
export function verifySignals(
input: readonly SignalChannel[],
): SignalChannel[] {
return input.filter((channel) => channel.confidence >= 0.75);
}
export function collectConstraints(
input: readonly Requirement[],
): ReadonlySet<string> {
const constraints = input
.filter((item) => item.priority >= 4)
.map((item) => item.summary);
return new Set(constraints);
}
export async function shapeSystem(): Promise<SystemPlan> {
const mapped = mapRequirements(requirements);
const verified = verifySignals(channels);
const constraints = collectConstraints([...mapped.values()]);
await Promise.resolve();
return {
requirements: [...mapped.values()],
channels: verified,
constraints,
createdAt: new Date(),
};
}
export function readTelemetry(plan: SystemPlan): string[] {
return plan.channels.map((channel) => {
const state = channel.active ? "ACTIVE" : "STABLE";
const confidence = Math.round(channel.confidence * 100);
return channel.id + " / " + state + " / " + confidence + "%";
});
}
export function nextRequirement(
plan: SystemPlan,
): Requirement | undefined {
return [...plan.requirements]
.filter((item) => item.state !== "ready")
.sort((left, right) => right.priority - left.priority)[0];
}
export const systemReady = requirements.every(
(item) => item.state === "ready",
);
// telemetry frame 001 / workflow synchronized
// telemetry frame 002 / workflow synchronized
// telemetry frame 003 / workflow synchronized
// telemetry frame 004 / workflow synchronized
// telemetry frame 005 / workflow synchronized