Vibe Coding Advanced / Owned practice and prerequisite bridges

Derive an oracle and a meaningful negative control

Lesson 5 of 32. Open to read. No account needed.

A cancellation helper can pass a test while doing the wrong thing. If the only test asks whether another member is denied, a helper that denies everyone looks correct. If the only test asks whether the owner is allowed, a helper that allows everyone looks correct. Before accepting a generated edit, you need a way to decide what each result should be and cases that can expose plausible mistakes.

You will derive four expected decisions from a supplied contract, predict which faulty helpers they reject, and add an identity counterexample that the first four cases miss. The result is A05, your own case table and explanation in records/behaviour-oracle.json. Allow 15–20 minutes for the explanation and 20–30 minutes for practice. This lesson uses authored deterministic fixtures; there is no model request or application feature edit.

Start from the requirement

A test oracle is the basis for deciding whether an observed result is right. For this exercise it is the cancellation contract and the expected decisions you derive from it. The assertion library compares two values; it does not know the business requirement. A literal false can still be wrong if its author misread that requirement.

Read contracts/cancellation.md before inspecting the fixture implementations. The input is an actor string and a supplied well-formed booking. The booking has id, memberId, equipmentId, slotId and a status of active or cancelled. Here, memberId is the row's owner. It is not an authenticated login token.

ClauseCondition required for trueRequirement-derived example
C1Actor is nonempty: string length greater than zero"" supplies no identity
C2Actor strictly equals booking.memberIdmember-b differs from owner member-a
C3Row status strictly equals activeOwner cannot cancel an already cancelled row

All three must hold. Otherwise the boolean result must be false. The helper must not change its input or storage. This lesson's rows belong to the supplied synthetic members; arbitrary malformed booking objects are outside its scope. You do not need the TypeScript or SQL bridges to reason about these plain values.

The contract deliberately requires exact identity comparison, with no trimming or case conversion. Nonempty means at least one character, not “contains a non-space character”. A whitespace-only actor differs from the supplied member-a owner because the strings differ. Do not add a general blankness rule or normalisation policy that the contract did not request.

L02/A02 followed requests, responses and direct rows. Keep that boundary in mind: a pure helper returning false does not by itself show a 403 response or unchanged durable rows. Those need application observations later. The native app's src/policy.ts still returns false; leave it for the later bounded edit.

Prepare the owned fixture exercise

Use your L01 owned native workbench and keep the A02 trace. The reference path uses macOS/POSIX, Node 24.19.0, pnpm 11.25.0 and the locked application dependencies. This lesson adds only Node built-in modules and needs no new package, database, listener, browser, model or cloud account. There is no network request or service charge in its commands. Earlier installation was a separate step; fresh tool acquisition and other host profiles are not established here.

The lesson-05-v1 download introduces these files; later snapshots may extend them. If an older native copy lacks them, keep its source/data/records and use L01's verified extraction/materialization procedure with a new absent owned destination. Do not merge over an old copy or change its manifest to conceal edits. Verify the current download's published checksum, then its native files before purposeful edits. Materialization uses the verified CPython 3.12 path already taught in L01; the fixture commands below need only Node.

Native inputRole
contracts/cancellation.mdAuthoritative exercise clauses and scope
cases/cancellation.jsonFour literal expected results and reasons
cases/control-defects.jsonDescriptions of the authored faulty controls
fixtures/cancellation-controls.mjsPure deterministic implementations; not app code
tools/oracle-bridge.mjsRead fixed case files, print decisions and report acceptance/rejection
checks/cancellation.test.mjsSelf-check of this fixture harness, separate from application acceptance
cases/oracle-counterexample.jsonEditable starter, initially repeating the owner-success case
records/behaviour-oracle.jsonBlank learner evidence input, not a supplied pass

All terminal commands below run from the native project root, where package.json, cases/ and tools/ exist. node --version should report the verified version. Do not run the .tmpl transport files directly.

Work one allow/deny comparison

A positive case here expects permission (true); a negative case expects denial (false). A negative control is a deliberately faulty implementation used to check whether your tests can detect its fault. A denial case is not, by itself, a negative control.

For an active booking belonging to member-a, actor member-a satisfies all three clauses, so the expected value is true. Actor member-b violates C2, so the expected value is false. Write both expectations before running a helper. Consider these two complete functions, excerpted from the maintained fixture control map in fixtures/cancellation-controls.mjs:

  'allow-all': () => true,
  'deny-all': () => false,

These map entries name two functions. Neither reads its supplied actor or row; one always returns true, the other always returns false. The first matches owner success by accident, the second matches other-member denial by accident. Their lack of input dependence is exactly the defect we want the pair of cases to expose. They are labelled teaching fixtures, not captured model responses.

Run the named fixture against the base cases:

node tools/oracle-bridge.mjs check allow-all
node tools/oracle-bridge.mjs check deny-all

Run these separately in your terminal so you can inspect each exit status. Both deliberately return exit 1, meaning rejected by at least one supplied case. This is the expected detection result. The JSON gives each input actor, literal expected, computed actual, matches and clause-based reason. Illustrative decisive rows, shortened to those fields:

Control/caseExpectedActualMatches
allow-all / other-memberfalsetruefalse
deny-all / active-ownertruefalsefalse

The controlled defect should fail. Do not turn the result green by changing the required value or deleting the rejecting case. Exit 2 instead indicates an exercise/argument/JSON error; it is not evidence that a meaningful defect was detected. These tools only read files and print; they do not write an app row.

Guided practice: predict the matrix

Before running the matrix, read the four cases and descriptions. In A05, write the expected result and C1/C2/C3 reason for each case. Predict which case rejects each control:

  • allow-all: always permits.
  • deny-all: always denies.
  • ignore-status: requires supplied exact owner but ignores C3.
  • trim-identity: trims the actor before comparing with the owner.
  • reference: authored fixture satisfying the stated clauses.

Use active-owner, other-member, cancelled-owner and missing-identity (actor ""), all with owner member-a. Then observe:

node tools/oracle-bridge.mjs matrix
node --test checks/cancellation.test.mjs

matrix exits zero when it successfully prints observations. That does not mean all controls are correct; read the per-case matches fields. The test runner executes seven self-checks: reference/literal agreement, four declared control failure sets, the circular-check demonstration and input preservation. A green runner means the harness behaves as specified, including the fact that one defect currently survives. It is not app cancellation acceptance. The existing pnpm run check still covers twelve baseline application cases; it is a separate command and does not assert owner cancellation succeeds.

Here is the actual assertion loop in the maintained fixture self-check checks/cancellation.test.mjs (excerpt; imports and case loading are in that complete supplied file):

  for (const item of cases) {
    const actual = controls.reference(item.actor, item.booking);
    assert.equal(actual, item.expected, item.id);
  }

cases comes from the fixed JSON file, not generated code. Each item supplies actor, booking and a literal boolean expectation. The function computes only actual. Imported assert is node:assert/strict; equal compares actual and expected strictly and uses the case ID as its failure message. Changing a literal expectation changes what the check demands even when the helper is unchanged, which is why requirement review matters. Imported test from node:test registers the containing callback for node --test; a failed assertion fails that test. Other harness callbacks compare declared failure ID arrays with deepEqual, which compares their structure and values.

The loader accepts only base or variation, reads the corresponding file relative to its own module, parses JSON, and checks case count, unique IDs, string actor/reason, boolean expectation and supplied row-field domains. It does not evaluate case text as code or judge whether your written reason is correct. Unknown controls/arguments or malformed cases produce exit 2. Fixed paths and shape checks are local exercise guards, not OS isolation.

Check your understanding before the independent variation

Would this expectation independently check decide?

        const actual = decide(item.actor, item.booking);
        const expected = decide(item.actor, item.booking);
        return { id: item.id, matches: actual === expected };

This is an excerpt of the deliberately bad mirror branch in the maintained CLI. Both operands call the same deterministic, stateless fixture on the same inputs; neither operand comes from the contract's expected value. Predict the result for allow-all and deny-all, then run:

node tools/oracle-bridge.mjs mirror

Keep your explanation and actual output. Also explain why four literal values can still miss a defect, even though they avoid this circular comparison.

Independent attempt: find the surviving identity defect

Before reading hints or answers, inspect the contract and your matrix. Change only cases/oracle-counterexample.json and your A05 record. The starter is a valid owner-success case, not a useful new discriminator. Keep its original contents in your record. Create a whitespace/empty-identity variation that distinguishes exact comparison from trim-identity. Write the expected boolean and a clause-based reason before running either fixture. Do not change the booking owner, fixture implementations, base cases or application source.

Run the same commands before and after your edit:

node tools/oracle-bridge.mjs check reference variation
node tools/oracle-bridge.mjs check trim-identity variation

The starter makes both exit zero. A useful completed variation should preserve agreement with the contract/reference fixture while making the trimming defect exit 1. Compare exact actor strings, expected/actual and reason. The reference fixture is a diagnostic comparison, not the authority that writes your expectation; keep the independent contract argument. A deliberately wrong expected value can reject a correct helper, so rejection alone is insufficient.

Success is a reasoned case table that rejects both overly permissive and overly restrictive controls, plus a new case rejecting the identity defect with a contract-derived expectation. Keep incorrect predictions, before/after case contents, raw results/exit codes and why the variation discriminates in A05. Do not prefill a pass or replace failures with the worked answer below.

Hints, then reasoned answers

First hint: identify what the first four actors have in common about leading and trailing spaces. Second hint: keep member-a as the row owner; compare it with a padded actor. Does the requirement authorise silently changing that actor string? An empty actor again may only repeat an existing denial.

The guided matrix should be:

Case / literal oracleallow-alldeny-allignore-statustrim-identityreference
active-owner / truematchesrejectsmatchesmatchesmatches
other-member / falserejectsmatchesmatchesmatchesmatches
cancelled-owner / falserejectsmatchesrejectsmatchesmatches
missing-identity / falserejectsmatchesmatchesmatchesmatches

Each cell says whether the case detects the control, not whether the control is globally correct. The owner success and other-member denial reject the two extremes. The cancelled-owner row adds discrimination against omitted status checks. All four still accept trimming because none contains padding. The missing-identity case fails C1 and C2; with nonempty supplied owner IDs it does not isolate C1's implementation. Four cases are not exhaustive proof.

For one independent solution, set actor to " member-a ", keep the active row owned by member-a, set expected to false, and write: C2 fails because the literal strings differ; the contract forbids trimming. The reference returns false; trim-identity returns true after removing spaces. The same reference and trim commands now exit 0 and 1 respectively. Only your case file and record change. A whitespace-only or empty actor against member-a is a valid denial but fails to distinguish these two controls; both deny it. A different padded-owner identity case is valid if its exact-comparison argument and observed discrimination hold.

The mirror branch reports all matches, including for both extreme defects. For these deterministic functions it merely compares a value with itself. The output's zero exit says the demonstration ran, not that permission is correct. Copying the helper's entire decision expression into the expected side creates a related risk: two copies can share the same misunderstood rule. Start from named contract examples, inspect counterexamples, and protect the expectation/check files when later allowing a model to edit helpers. Independent means separately justified; it does not mean a test's author is infallible.

Diagnose and retain the evidence

ObservationSafe next check
check allow-all or check deny-all exits 1Expected control rejection; identify the decisive row rather than weakening it
A control unexpectedly survivesVerify case inputs, literal expectation and contract clauses; seek an uncovered difference
Reference rejected by your variationReview your expectation/reason and exact actor characters before blaming the helper
Exit 2 or file not foundCheck native working directory, exact CLI form, JSON syntax and required snapshot inputs
Seven fixture self-checks passHarness is consistent; still inspect surviving defects and your independent variation
Old copy lacks the exercisePreserve it; materialize the verified current payload to a new absent owned name

Reruns are deterministic and read-only. After interruption, retain any partial terminal capture and rerun only the named fixture command; no service or data reset is needed. Review your own case/record diff. Keep the contract, original and changed case, A02/A05 and actual observations. Leave app source, earlier records and databases intact. These commands leave no model, listener or billable resource to stop. The next lesson uses this oracle reasoning to define the booking change's acceptance boundary; application/API regression coverage comes in L14, followed by the actual AI edit.

Sources and limits

Rechecked 2026-10-26: Node 24.19.0 test runner (S18) supports test registration/execution; strict assertions (S44) supports comparison/failure behaviour. Playwright best practices (S21) supports checking observable behaviour and isolating tests; no Playwright run is required here. These sources do not establish this application's requirements or prove an oracle independent. The original contract, case reasoning and actual labelled fixture observations supply that bounded teaching evidence.

27 more lessons in the full course

Course access opens every lesson and adds revision notes, the Quick Reference, saved progress, bookmarks and your own notes.

INR 199 plus 18% GST. 90 days of online access. No auto-renewal.

Get the full course

This website is operated by VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED, operating as Vectametric.

Corporate Identity Number (CIN): U85499KA2026OPC229822. GSTIN: 29AAMCV8281D1ZS. Registered office: RS NO/38/2A/1 BASTAND, ROAD MAHANTESH NAGAR, Ramdurg, Ramdurg, Belgaum- 591123, Karnataka.

Queries and grievances: Prajval Honnungar, Grievance Officer and Data Protection Contact.

Telephone: +91 94800 09310. Support: support@vectametric.com. Grievances: support@vectametric.com.

Copyright 2026 VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED. All rights reserved.

Vectametric home · Roadmaps · Vecta IT Exams · Vecta Government Exams · Vecta Banking & Finance Exams · Vecta Entrance Exams · About us · Contact · Privacy Policy · Terms and Conditions · No-Refund Policy