Skip to content
Merged
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
17 changes: 14 additions & 3 deletions models/intersection/queue.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ export function runQueue(model, arrivals) {
const arrival = arrivals[index];
const capacity = model.service[phase];
if (!validCounts(arrival) || !validCounts(capacity)) throw new Error(`Invalid arrivals or phase at slot ${index + 1}.`);
const waitingNS = queue.NS + arrival.NS;
const waitingEW = queue.EW + arrival.EW;
const opening_queue = queue;
const waitingNS = opening_queue.NS + arrival.NS;
const waitingEW = opening_queue.EW + arrival.EW;
const departures = { NS: Math.min(waitingNS, capacity.NS), EW: Math.min(waitingEW, capacity.EW) };
queue = { NS: waitingNS - departures.NS, EW: waitingEW - departures.EW };
return { slot: index + 1, phase, arrival, departures, queue };
return { slot: index + 1, phase, opening_queue, arrival, departures, queue };
});
}

Expand All @@ -37,3 +38,13 @@ export function moveArrival(arrivals, group, from, to) {
edited[to - 1][group]++;
return edited;
}

/** Repeat one scenario's phases and arrivals without reinitializing its queues.
* @param {QueueModel} model @param {Counts[]} arrivals */
export function runTwoCycles(model, arrivals) {
return runQueue({
...model,
horizon_slots: model.horizon_slots * 2,
phase_sequence: [...model.phase_sequence, ...model.phase_sequence],
}, [...arrivals, ...arrivals]);
}
33 changes: 32 additions & 1 deletion models/intersection/queue.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { execFileSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import { readFileSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
import inputs from '../../project/v3/case-study/model-inputs-v1.json';
import { moveArrival, runQueue } from './queue.mjs';
import { moveArrival, runQueue, runTwoCycles } from './queue.mjs';

const trace = readFileSync(new URL('../../project/v3/case-study/trace-v1.csv', import.meta.url), 'utf8')
.trim().split(/\r?\n/).slice(1);
Expand All @@ -15,6 +17,35 @@ describe('fixed-phase intersection experiment', () => {
expect(calculated).toEqual(trace);
});

it('preserves the reference cycle and carries both queues through the second cycle', () => {
const firstCycle: string[] = [];
for (const scenario of inputs.scenarios) {
const rows = runTwoCycles(inputs, scenario.arrivals);
for (const { slot, phase, arrival, departures, queue } of rows.slice(0, 8)) {
firstCycle.push([scenario.id, slot, phase, arrival.NS, arrival.EW, departures.NS, departures.EW, queue.NS, queue.EW].join(','));
}
expect(rows).toHaveLength(16);
expect(rows[8].opening_queue).toEqual(rows[7].queue);
expect(rows[8].opening_queue).toEqual({ NS: scenario.id === 'A' ? 1 : 2, EW: 0 });
expect(rows[8].departures).toEqual({ NS: 1, EW: 0 });
expect(rows[8].queue).toEqual({ NS: 1, EW: scenario.id === 'A' ? 0 : 2 });
expect(rows[15].queue).toEqual({ NS: scenario.id === 'A' ? 1 : 2, EW: 0 });
}
expect(firstCycle).toEqual(trace);
// Both published scenarios clear EW by slot 8. Leave EW waiting to test its carry too.
const lateEW = clustered.map(row => ({ ...row }));
lateEW[7].EW = 3;
const ninth = runTwoCycles(inputs, lateEW)[8];
expect(ninth.opening_queue).toEqual({ NS: 2, EW: 3 });
expect(ninth.queue).toEqual({ NS: 1, EW: 5 });
});

it('reproduces the published two-cycle record from its identified sources', () => {
const runner = new URL('../../project/v3/case-study/run-two-cycles.mjs', import.meta.url);
const saved = new URL('../../project/v3/case-study/two-cycle-run.json', import.meta.url);
expect(execFileSync(process.execPath, [fileURLToPath(runner)], { encoding: 'utf8' })).toBe(readFileSync(saved, 'utf8'));
});

it('moves one NS arrival to the last NS green and preserves the baseline', () => {
const edited = moveArrival(clustered, 'NS', 3, 2);
expect(runQueue(inputs, edited).at(-1)?.queue).toEqual({ NS: 1, EW: 0 });
Expand Down
12 changes: 6 additions & 6 deletions project/CURRICULUM-MAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

**Single case:** One fictional four-way traffic intersection, introduced in Chapter 2 and used for the technical progression. Chapter 1 stands alone as the engineering-paradigm overview.

**Title status:** The proposed capstone title *Choosing the Next Engineering Capability* appears in the owner-accepted fourteen-chapter plan. Retain the existing Chapter 06 title *Spec-Driven Development Without Waterfall* for now; the independent review's alternative *Specifying the Next Engineering Increment* remains a separate editorial naming decision. Older 13-chapter text remains preserved as source material and must not be silently renumbered.
**Title status:** The proposed capstone title *Choosing the Next Engineering Capability* appears in the owner-accepted fourteen-chapter plan. Retain the existing Chapter 07 title *Spec-Driven Development Without Waterfall* for now; the independent review's alternative *Specifying the Next Engineering Increment* remains a separate editorial naming decision. Older 13-chapter text remains preserved as source material and must not be silently renumbered.

| Part | # | Chapter | Distinct learning gain | Primary intersection teaching view |
|---|---:|---|---|---|
Expand All @@ -12,11 +12,11 @@
| I | 03 | Planning Under Uncertainty | Revise the next increment when a prototype changes what the team knows | Reconcile two readings of the same queue before requesting arrival data |
| II — Build and Test Knowledge | 04 | Engineering Knowledge as Code | Use typed relationships to check a proposed change against engineering sources | Trace a phase-selection change to the queue model that represents the function |
| II | 05 | Learning Through Models and Prototypes | Run an experiment and save what it taught the team about the model | Move one arrival, compare the queue traces and record the result against the model revision |
| II | 06 | Engineering Data: From Measurements to Decisions | Curate, annotate, inspect and reuse engineering observations | Original, checked and derived records |
| II | 07 | Spec-Driven Development Without Waterfall | Define a bounded next increment while leaving other uncertainties open | Progressive specification and decisions |
| III — Develop an Integrated Product | 08 | Directing AI Engineering Agents | Bound, observe and review delegated engineering work | Illustrative task context, tool actions and handover |
| III | 09 | Engineering in Small, Reviewable Increments | Establish useful review boundaries and cross-discipline dependencies | Thin vertical improvement and dependent interface change |
| III | 10 | From Models to an Integrated Product | Bridge model/software work to product interfaces, physical integration and intended use | Interface semantics mismatch and integration questions |
| II | 06 | Engineering Data: From Measurements to Decisions | Decide what the next measurement can settle and keep the model runnable | Follow both queues across a cycle boundary and qualify the result |
| II | 07 | Spec-Driven Development Without Waterfall | Turn an engineering request into a brief an engineer can approve | Specify the boundary behavior, reference and acceptance outputs |
| II | 08 | Directing AI Engineering Agents | Choose between task support and a delegated outcome | Give an agent the sources, permissions and independent check for a comparison |
| II | 09 | Planning and Controlling Agents | Choose a first increment and decide when to expand a delegated plan | Trace the carry-over rule from its rationale to a result and back |
| III — Develop an Integrated Product | 10 | From Models to an Integrated Product | Turn prototype learning into a product requirement and select evidence for the claim | Compare command receipt with an independently observed signal indication |
| IV — Establish Trust and Sustain Change | 11 | Verification, Validation and Engineering Evidence | Qualify claims against the integrated configuration and intended use | Claim, method, result and applicability |
| IV | 12 | Governance and Engineering Authority | Identify controls, authority, technical integrity and residual risks | One deferred change with evidence gaps |
| IV | 13 | Continuously Integrated Engineering | Design and operate an engineering factory for controlled changes | Eligibility and blocked-release decision |
Expand Down
1 change: 1 addition & 0 deletions project/v3/case-study/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
| [source-graph-v1.json](source-graph-v1.json) | Stable teaching IDs, typed relations, source semantics, status and proposed impact | Fictional source assertions; no physical confirmation |
| [model-inputs-v1.json](model-inputs-v1.json) | Fixed eight-slot teaching model, event order, A/B arrival sequences, invalid input rules | Invented model and input assumptions |
| [trace-v1.csv](trace-v1.csv) | Sixteen computed state records, eight per scenario | Recomputed deterministic **toy-model calculation**, not a deployed V3 simulation or field measurement |
| [two-cycle-run.json](two-cycle-run.json) | Both scenarios across the cycle boundary with source checksums | Computed by running `node project/v3/case-study/run-two-cycles.mjs` from the repository root |
| [data-quality-v1.json](data-quality-v1.json) | Legitimate derived comparison and the deliberately inapplicable legacy C row | Editorial data-quality decisions |
| [DECISION-CHAIN.md](DECISION-CHAIN.md) | Controlled next increment, agent task, reviewable slice, integration mismatch, evidence, governance, release, reuse and capstone | Proposed engineering decisions, not executed project actions |
| [MODEL-CHECK.md](MODEL-CHECK.md) | Exact model formula, checks and limitations for a future implementer/editor | Independent editorial recomputation record; not software/system qualification |
Expand Down
34 changes: 34 additions & 0 deletions project/v3/case-study/run-two-cycles.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { createHash } from 'node:crypto';
import { readFileSync } from 'node:fs';
import { runTwoCycles } from '../../../models/intersection/queue.mjs';

const root = new URL('../../../', import.meta.url);
const sources = {
inputs: 'project/v3/case-study/model-inputs-v1.json',
calculation: 'models/intersection/queue.mjs',
reference_cycle: 'project/v3/case-study/trace-v1.csv',
runner: 'project/v3/case-study/run-two-cycles.mjs',
};
const read = path => readFileSync(new URL(path, root));
const model = JSON.parse(read(sources.inputs));
const record = {
id: 'INT-RUN-T1-TWO-CYCLES',
model: model.id,
revision: model.revision,
scope: 'Synthetic fixed-phase simulation. Each scenario repeats its own arrivals. Queues carry across the boundary.',
unit: 'vehicles per direction after service in an abstract slot',
event_order: model.event_order,
sources: Object.fromEntries(Object.entries(sources).map(([name, path]) => [
name, { path, sha256: createHash('sha256').update(read(path)).digest('hex') },
])),
scenarios: model.scenarios.map(({ id, arrivals }) => {
const rows = runTwoCycles(model, arrivals);
const boundary = model.horizon_slots;
return {
id, after_first_cycle: rows[boundary - 1],
before_next_arrivals: rows[boundary].opening_queue,
first_slot_of_second_cycle: rows[boundary], after_second_cycle: rows.at(-1),
};
}),
};
process.stdout.write(JSON.stringify(record, null, 2) + '\n');
166 changes: 166 additions & 0 deletions project/v3/case-study/two-cycle-run.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
{
"id": "INT-RUN-T1-TWO-CYCLES",
"model": "INT-MOD-001",
"revision": "T1",
"scope": "Synthetic fixed-phase simulation. Each scenario repeats its own arrivals. Queues carry across the boundary.",
"unit": "vehicles per direction after service in an abstract slot",
"event_order": [
"add arrivals to queues",
"serve at most one vehicle from the green group's non-empty queue",
"record departures and remaining queue"
],
"sources": {
"inputs": {
"path": "project/v3/case-study/model-inputs-v1.json",
"sha256": "18e2fe9ead1c8c0c1a30e8593cf43255a0f29696d367e10751315a075ba9997e"
},
"calculation": {
"path": "models/intersection/queue.mjs",
"sha256": "1a37be436ede7991ed5d9a1f013e1f49749bfe60bca28aac5796aebf1e8453de"
},
"reference_cycle": {
"path": "project/v3/case-study/trace-v1.csv",
"sha256": "f207af5896ddcd8859568ee1e54222ba243c12ec466dc66fb0ad6c76e461a4a7"
},
"runner": {
"path": "project/v3/case-study/run-two-cycles.mjs",
"sha256": "253836901181f7dfad2c076452459a91f6645acd3ef2d0e94bb64dfeb6f7a7e0"
}
},
"scenarios": [
{
"id": "A",
"after_first_cycle": {
"slot": 8,
"phase": "ALL_RED",
"opening_queue": {
"NS": 1,
"EW": 0
},
"arrival": {
"NS": 0,
"EW": 0
},
"departures": {
"NS": 0,
"EW": 0
},
"queue": {
"NS": 1,
"EW": 0
}
},
"before_next_arrivals": {
"NS": 1,
"EW": 0
},
"first_slot_of_second_cycle": {
"slot": 9,
"phase": "NS_GREEN",
"opening_queue": {
"NS": 1,
"EW": 0
},
"arrival": {
"NS": 1,
"EW": 0
},
"departures": {
"NS": 1,
"EW": 0
},
"queue": {
"NS": 1,
"EW": 0
}
},
"after_second_cycle": {
"slot": 16,
"phase": "ALL_RED",
"opening_queue": {
"NS": 1,
"EW": 0
},
"arrival": {
"NS": 0,
"EW": 0
},
"departures": {
"NS": 0,
"EW": 0
},
"queue": {
"NS": 1,
"EW": 0
}
}
},
{
"id": "B",
"after_first_cycle": {
"slot": 8,
"phase": "ALL_RED",
"opening_queue": {
"NS": 2,
"EW": 0
},
"arrival": {
"NS": 0,
"EW": 0
},
"departures": {
"NS": 0,
"EW": 0
},
"queue": {
"NS": 2,
"EW": 0
}
},
"before_next_arrivals": {
"NS": 2,
"EW": 0
},
"first_slot_of_second_cycle": {
"slot": 9,
"phase": "NS_GREEN",
"opening_queue": {
"NS": 2,
"EW": 0
},
"arrival": {
"NS": 0,
"EW": 2
},
"departures": {
"NS": 1,
"EW": 0
},
"queue": {
"NS": 1,
"EW": 2
}
},
"after_second_cycle": {
"slot": 16,
"phase": "ALL_RED",
"opening_queue": {
"NS": 2,
"EW": 0
},
"arrival": {
"NS": 0,
"EW": 0
},
"departures": {
"NS": 0,
"EW": 0
},
"queue": {
"NS": 2,
"EW": 0
}
}
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions project/v3/learning/quizzes/eel-v3-ch06-engineering-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[
{
"id": "test-the-boundary",
"prompt": "A new implementation gets B’s final count right. Which check would expose an accidental reset between the two cycles?",
"options": [
{
"text": "Count the four NS and four EW arrivals across all 16 slots.",
"feedback": "A reset discards waiting vehicles. The incoming traffic can still add up exactly as specified."
},
{
"text": "Look for an NS departure at slot 9, when the only arrivals are EW.",
"feedback": "That departure uses one of the two NS vehicles carried from slot 8. A reset would leave nobody to depart on this green, yet B could still finish with two vehicles.",
"correct": true
},
{
"text": "Compare the last row of each independent eight-slot B run.",
"feedback": "Independent runs each start empty and each end with two NS vehicles. They leave the handoff between the cycles untested."
}
]
},
{
"id": "qualify-the-record",
"prompt": "The spreadsheet’s author confirms that 20 counts vehicles. Which follow-up would establish whether it belongs beside B’s slot-16 result?",
"options": [
{
"text": "Check whether both files were exported on the day the model was run.",
"feedback": "An export date can help locate a source. It cannot identify which queues were counted, under which conditions or when the count was taken."
},
{
"text": "Check whether the model accepts a queue of 20 as a valid whole number.",
"feedback": "Twenty is a possible count, but checking the value’s format leaves its meaning and origin unresolved."
},
{
"text": "Recover which queues were counted, when, and under which input conditions and configuration.",
"feedback": "With those details and the input conditions, a reviewer can judge whether both records measure the same quantity under comparable conditions.",
"correct": true
}
]
},
{
"id": "time-the-interface",
"prompt": "A requirement limits detector-to-controller delivery time while diagnostics share the physical link. Which run would let the reviewer assess that requirement for the proposed configuration?",
"options": [
{
"text": "Use the intended devices and link under the specified load. Measure from send to receipt.",
"feedback": "The measured interval and load match the requirement. Recording the device revisions, link settings and clock basis lets the reviewer relate the result to this configuration.",
"correct": true
},
{
"text": "Run the receiver software under the specified load. Measure how long it spends processing each delivered report.",
"feedback": "That run could identify a processing bottleneck. Its clock starts after delivery, so it misses the interval the requirement limits."
},
{
"text": "Use the intended devices and link with diagnostics paused. Measure from send to receipt.",
"feedback": "This would give an unloaded baseline. The requirement concerns competition for the link, so the reviewer needs a run with the declared diagnostic traffic."
}
]
}
]
Loading
Loading