“The page says saved” is a weak basis for accepting an AI-assisted change. The browser can display a message without making a request. A request can reach the wrong local application. A successful response can describe a different record from the one you intended. Before changing the booking app, learn to connect one browser event to its request, handler and stored result.
You will follow a successful creation, explain a rejected duplicate, then trace a denied cancellation without editing the server. Your independent task changes only a browser caption and asks which observations actually changed. Save the result as A02, your request trace, for later lessons.
Three observations of one operation
Display state is what the current page shows. Response state is the
status and JSON body returned for a particular HTTP request. Stored state
is the data read from the database file. A database row is one stored record
with named fields, such as a booking's id, memberId and status.

Read the blue arrows downward: a submit event makes a request, the handler
checks it, and the store issues a database operation. Read the green arrows
upward: a row or database error becomes an HTTP result, which the browser can
render. 201 means this create request was accepted; 409 is the duplicate
conflict in our example. The cancellation branch can return 403 before a
write. The diagram combines those paths; it does not say every request inserts
a row. A direct inspection and later reopening of the same file add evidence
that a browser message alone cannot supply.
An actor is the identity used for a decision. Here x-practice-member is
a synthetic actor input. The browser's member selector sets that header; the
local request helper sends member-a. Neither is production authentication.
Anyone with this local practice app can select another supplied member.
Start with an identifiable practice copy
Complete Lesson 1 first. Retain A01, its source identity, readiness card and owned database. Use the same reference profile: macOS arm64 with Node 24.19.0, pnpm 11.25.0 and the locked TypeScript 6.0.3 application. The materializer requires CPython 3.12/POSIX; the author checked CPython 3.12.14 and Chrome 156.0.8078.47. Other hosts and a fresh external tool installation remain unverified. Browser developer tools and basic JSON/JavaScript are declared starting knowledge.
The booking-workbench.zip in Practice files extends the first
baseline with tools/inspect.mjs, tools/request.mjs,
records/request-trace.json and contracts/request-map.md. The L02 snapshot
lesson-02-v1 introduced 26 native files, plus two transport/control files.
Later snapshots retain these helpers and can add inputs; record the current
manifest version and count instead of substituting the historical L02 identity. If your L01 copy lacks those helpers, verify the current panel's
archive checksum and repeat L01 materialization/install/type/build/check in a
new, absent owned destination. Keep your earlier copy and A01; do not merge
over its edits or rewrite its old manifest identity. Record the new checkpoint
alongside the old one. Matching an old archive's checksum does not establish
that it contains new inputs.
All shell commands below run in that materialized native project root, where
package.json, tools/, records/ and dist/ exist. The application build and
12 baseline smoke cases must already pass. No model service, AI subscription,
external API or cloud database is needed. The commands create one synthetic
SQLite file, contact your owned loopback listener and print observations.
Dependency installation, if needed for a new copy, has the network effects
described in L01; tracing itself uses no external service.
Open records/request-trace.json in your editor. It is a blank template,
not a passing result. Fill it with your own paths, runtime, source checkpoint,
requests, before/after rows, failures and explanations. Keep copied JSON
observations in valid JSON fields or adjacent named evidence files. Do not
replace variable IDs with an author's successful result.
Read the small path before running it
These are excerpts of supplied native files, not replacements to paste over them. You can locate them by the function or event names. No TypeScript edit is required; the next lesson teaches its runtime boundary in depth.
In public/app.js, the create form's submit handler contains:
event.preventDefault();
try { await request('/api/bookings', 'POST', { equipmentId: equipment.value, slotId: slot.value }); await load(); message.textContent = 'Booking created and saved'; }
catch (error) { message.textContent = error.message; }
preventDefault() keeps the form from navigating away. The selected equipment
and slot values become JSON fields. The supplied request helper adds the
selected member header, sends fetch, parses the response and throws when
response.ok is false. Thus await load() and the success caption occur only
after the create response was accepted. load() makes a separate GET /api/state and renders that member's bookings. If creation returns 409, the
catch branch displays the error instead. Changing only message.textContent
would change the page without changing that sequence of network/storage work.
In src/server.ts, the POST /api/bookings branch reads the JSON object,
allows only equipmentId and slotId, and checks both against supplied IDs.
The actor comes from the header, checked against supplied members; a body field
cannot choose a booking owner. Its create/error block is:
try { reply(res, 201, store.create(actor, equipmentId, slotId)); }
catch (error) {
if (error instanceof Error && error.message.includes('UNIQUE constraint failed: bookings.equipmentId, bookings.slotId')) throw new RequestError(409, 'Equipment already booked for that slot');
throw error;
}
store.create runs before reply sends the row. A successful insert produces
201; the known active equipment/slot uniqueness failure is translated to
409. Other failures are rethrown to the outer error handler, which returns
the relevant request error or 500. This branch does not turn every error
into a success. In src/db.ts, create constructs a generated booking ID,
the header actor, chosen equipment/slot and active status, then executes:
this.db.prepare('INSERT INTO bookings VALUES (?, ?, ?, ?, ?)').run(row.id, row.memberId, row.equipmentId, row.slotId, row.status);
The five ? positions receive those five values in order. This is a bound
statement, not a string assembled from request values. The schema has one
active booking per equipment/slot pair; changing the slot can change whether
the insert conflicts. Deeper keys and transaction work come in the database
bridge. Here you need to trace inputs and compare rows, not invent SQL.
tools/inspect.mjs opens only an existing regular owned database. Within its
guarded try block, it uses these actual statements:
db = new DatabaseSync(database, { readOnly: true, allowExtension: false, timeout: 1000 });
const version = db.prepare('PRAGMA user_version').get().user_version;
if (version !== 1) throw new Error('Expected schema v1; do not migrate or reset to inspect');
const bookings = db.prepare('SELECT id, memberId, equipmentId, slotId, status FROM bookings ORDER BY id').all();
readOnly: true opens a connection that cannot write; extensions are disabled.
timeout: 1000 bounds a lock wait in milliseconds. PRAGMA user_version
reads the app's schema marker; anything other than 1 is refused. SELECT
reads the named fields; ORDER BY id makes comparisons stable rather than
promising insertion order. .all() returns all matching booking rows. The
tool prints the exact database path and closes in finally, including failure.
It does not seed, reset, repair or migrate a file. These options are described
in the pinned Node SQLite reference.
The inspector includes both members' stored rows. /api/state filters rows
to the selected member and adds display fields. Different counts across those
two observations can therefore be expected. Compare record IDs and fields,
not an assumption that every view returns every row.
Work one creation and its duplicate
First stop any app you started in L01 with Ctrl-C in its own verified start terminal. Keep that database. In the current native project root, create a separate database for this trace:
node tools/seed.mjs trace-02.sqlite
node tools/inspect.mjs trace-02.sqlite
trace-02.sqlite is a new simple basename under this project's data/ directory.
Seeding refuses an existing file; it never means “reset this name”. If it
already exists, inspect/retain it and use a new name consistently in every
subsequent command and your record. A fresh seed contains these two rows:
| ID | Member | Equipment | Slot | Status |
|---|---|---|---|---|
booking-a | member-a | drill-01 | slot-am | active |
booking-b | member-b | camera-01 | slot-pm | active |
Save the actual inspector output as your before observation. Do not infer it from this table if your command failed. Then start the app in terminal A:
node tools/start.mjs trace-02.sqlite 0
Port 0 asks the OS for a free port. The JSON start record supplies the actual
url, pid and full database path. Verify that path belongs to this project,
then open that URL. Keep the terminal open. The URL/port varies; do not
visit a remembered port belonging to another exercise. The helper binds only
127.0.0.1, using Node's HTTP server lifecycle.
In the browser, wait for Baseline ready. Open developer tools' Network
view so you can inspect the next request and response. Select Practice member
A, Cordless drill (drill-01) and Afternoon slot (slot-pm); then
click Create booking once. The drill/afternoon pair is free in a fresh seed.
Identify the POST /api/bookings request, separate from the subsequent GET /api/state. Record the synthetic member header, request body, status and
response. The expected illustrative shape, with a variable generated ID,
is:
{"id":"YOUR-GENERATED-ID","memberId":"member-a","equipmentId":"drill-01","slotId":"slot-pm","status":"active"}
This is a response shape, not a runnable fixture or your evidence. Use your
actual ID. The status should be 201, the body should contain the chosen
fields, and the page should say Booking created and saved. In terminal B,
also in the same native project root, run:
node tools/inspect.mjs trace-02.sqlite
Find the returned ID among three total stored rows. Its actor, equipment, slot and status must match the response; the two seed rows must remain. Member A's page shows two bookings, because member B's row is filtered out. Save the after output and explain this difference in A02.
Submit the same selections again while watching the Network view. Expect
409 and Equipment already booked for that slot. Inspect the database
again: the previous three rows should be unchanged, with no second booking
for that active pair. A visible error and unchanged rows together explain this
rejection. A successful first creation followed by a rejected duplicate is
expected, not an intermittent success rate.
If browser request inspection is unfamiliar, node tools/request.mjs can
print a fixed request/response independently. It does not report what your
browser previously sent. Its create case sends a real new create request for
drill/afternoon and will return 409 now because you already occupied that
pair. Label separate observations separately.
Guided trace: deny a cancellation before a write
Keep the listener running. In terminal B, assign your owned origin to a shell variable. The following is a command template: replace the port placeholder with the number from terminal A before executing it. There is no API path, trailing query or credential in the origin.
VIBE_URL='http://127.0.0.1:REPLACE_WITH_YOUR_PORT'
node tools/request.mjs "$VIBE_URL" state
The assignment stores a string; the second line sends a real GET /api/state
as synthetic member-a. It should return 200, with A's two bookings. Record
the actual URL. The helper accepts only an explicit http://127.0.0.1:PORT
origin, fixed named cases, no redirect and a five-second response timeout.
That URL guard prevents accidental external destinations; it cannot establish
who owns a loopback service. You must still match the start record and file.
Before trying the guided case, inspect and save all rows again. Then run:
node tools/request.mjs "$VIBE_URL" cancel-other
node tools/inspect.mjs trace-02.sqlite
The fixed case posts {} to /api/bookings/booking-b/cancel as member-a.
booking-b belongs to B. Expect status 403, error Cancellation is not
permitted, and that row still active with exactly its previous fields.
The helper's process exit zero means it completed an HTTP exchange, including
403 or 409. Read the printed status and rows before deciding whether the
application accepted the action.
Locate the cancellation branch in src/server.ts: it reads the target row,
returns 404 if absent, asks canCancel(actor, row), and throws 403 if false.
The store.cancel write lies after that decision. The supplied src/policy.ts
currently returns false for every cancellation. This denied other-member case
is correct, but it does not demonstrate a completed owner-cancellation feature.
Do not enable the UI button, edit the policy or add a successful owner case to
this lesson. That behaviour belongs to the later specified AI change.
Explain the path in A02: event/command → method/path/body and actor → row lookup
→ false decision → 403 → unchanged stored row. The absence of a visible
Cancel click is no obstacle; the supplied helper makes the bounded request.
Independent variation: a convincing caption
Predict the result before opening the answer. In your own local booking tab, use the developer-tools Console to run this understood JavaScript expression:
document.querySelector('#create button').textContent = 'Saved (display only)';
It selects the create button and assigns its displayed text. It does not submit
the form, write a source file or call fetch. Type it yourself if your browser
blocks console pasting; do not disable a browser-wide protection to paste code.
Do not click the renamed button during this variation.
Check for a new booking POST, inspect the same database, then reload the page.
Record the caption, request observation and before/after rows. Explain whether
the changed word “Saved” establishes a stored booking, and what a reload tells
you. Also answer: would an optimistic UI that changed before a server reply
establish persistence?
Hint 1: Separate an assignment to a DOM property from an event that sends a request. Hint 2: Compare the generated ID from the real creation with the same database row; compare the caption before and after reloading.
Reasoned answer after your attempt
The caption changes immediately, but this expression sends no POST and the
three stored rows stay unchanged. Reload recreates the button from supplied
HTML, restoring Create booking. It also fetches member A's state; the two
displayed rows include your genuine earlier creation. The caption experiment
adds no booking. An optimistic display would likewise need a response and
stored-row checks; the display alone is insufficient even when it looks right.
Finish the durability check: in terminal A press Ctrl-C, wait for STOPPED:
owned app closed; source and database retained, then start the same
trace-02.sqlite again with port 0. Update VIBE_URL from its new start record.
Use state and inspect again, and visit/reload the new URL. Your generated ID
should still appear with the same values. This closes and reopens the owned
app/database; it is bounded persistence evidence, not a crash/power-loss test.
If you accidentally reseed a different file, its rows cannot establish what
survived in the first file.
Make a failed observation useful
| Observation | Interpretation and safe next check |
|---|---|
| Seed refuses an existing name | Preserve it. Inspect that name or choose a new one consistently; never overwrite it to obtain the expected table. |
First create returns 409 | Check the actual before rows and selected pair. You may have already used this database; retain the attempt. |
| Inspector refuses a path/schema or reports a lock | Verify project root, simple basename, existing file and schema 1. If needed stop only the owned app and retry the read; do not migrate/reset as a diagnostic. |
Response is 201, ID missing from inspection | Check the full database path and owned start record before claiming success. A different file or listener breaks the chain. |
| State has two bookings; inspector has three | Expected after this create: API filters to A, inspector reads both members. Compare IDs/ownership. |
Helper prints 403 with exit zero | Transport completed; the application denied the cancellation. Compare before/after rows. |
| Request fails or browser still points at an old port | Match the current start URL and stopped/restarted process. Keep the failed result; do not stop unrelated listeners. |
| Independent caption edit creates a row | Check whether you also clicked/pressed submit or another tab sent a request; the provided expression alone has no network operation. |
A02 is complete when it links all four cases to the actual actor, request or absence of request, response, record ID, before/after rows and explanation. Record reopening the same file, exact owned paths and source identity. A screenshot can illustrate display state; it cannot replace those observations. Keep unrun or failed fields candid. Passing this exercise covers these supplied local paths; it does not establish production authentication, complete security or the later cancellation feature.
For a fresh retry, retain this trace and database and use L01's seeding recipe
with a new owned database name. Keep A01, A02, native source and data for
the next bridge. Stop only this lesson's verified listener with Ctrl-C and wait
for its stop message. Remove the shell variable with unset VIBE_URL if set;
this only clears that terminal's string. No external resource needs cleanup.