HOLLOWREED STUDIO / DEVELOPER SAMPLE
Verify a decision tree against every listed case
Hollowreed Studio · Original AI-generated technical writing sample
A decision tree can look convincing and still give the wrong answer on a case you already listed. It can also answer every case correctly while asking an unnecessary question. Those are different defects, and a single success flag does little to distinguish them.
This walkthrough builds a small, reproducible review process. A Node.js producer creates a strategy and a full report. A separate Python implementation checks that report against the original input. A candidate auditor then checks policies you supply, including a deliberately wrong shortcut and a correct tree that repeats a question.
The example is a complete catalogue of eight synthetic cases. It is small enough to inspect by hand, which lets you check the tools' conclusions as you follow the commands. The result is a precise guarantee about these rows and these allowed questions. It makes no prediction about cases outside the catalogue.
Download the runnable code · Read the print copy
In this walkthrough
Define what an answer means
Each row has three binary features, Q0, Q1 and Q2, and a target of either 0 or 1. Reading a feature means asking one allowed question. The target rule is simple: when Q0 is 0, use Q1; when Q0 is 1, use Q2.
| Row | Q0 | Q1 | Q2 | Target |
|---|
| 0 | 0 | 0 | 0 | 0 |
|---|
| 1 | 0 | 0 | 1 | 0 |
|---|
| 2 | 0 | 1 | 0 | 1 |
|---|
| 3 | 0 | 1 | 1 | 1 |
|---|
| 4 | 1 | 0 | 0 | 0 |
|---|
| 5 | 1 | 0 | 1 | 1 |
|---|
| 6 | 1 | 1 | 0 | 0 |
|---|
| 7 | 1 | 1 | 1 | 1 |
|---|
The row numbers are zero-based references for diagnostics. They are not the values the tree must identify. Several rows share a target, so a valid leaf can cover more than one row.
Questions have declared effort costs: Q0 costs 1, Q1 costs 4 and Q2 costs 2. A path's effort is the sum of the questions it actually asks, including repeats. We will minimize the largest effort over the supplied rows. These numbers are abstract units, rather than measured latency, currency or a probability distribution.
The supplied examples/INPUT.json records the table as a features matrix, its targets array and costs: [1, 4, 2]. Keeping those inputs explicit matters: changing a cost changes the optimization problem even when every target stays the same.
Reproduce the full report
Extract the code ZIP and open a terminal in its FinitePolicySample folder. The examples were tested on Linux with Node.js 24.19.0 and CPython 3.14.4. They use standard libraries and need no package installation, account, API key or network connection.
Run the producer, then check its output with Python:
node code/produce.mjs examples/INPUT.json > reports/OUTPUT.json
python3 -B code/fqp_verify.py examples/INPUT.json reports/OUTPUT.json
The second command exits 0 and prints:
{
"valid": true, "minimumWorstCaseCost": 5, "fixedMinimumCost": 7,
"attainingWorstCaseQuestions": 2,
"checkedLowerNodes": 8, "cheaperFixedSets": 7
}
OUTPUT.json contains more than those summary values. It includes an attaining tree, the rows assigned to its branches, a lower-bound certificate and witnesses for cheaper fixed question sets. Keep the full file when you pass a result to another component. The short verification result is a receipt from this check, rather than a substitute for its input.
The Node runner also performs its own check before writing output. The Python checker provides a separate implementation with no import from the Node producer. It reads the original input file directly and checks the report's catalogue hash, dimensions, strategy and certificate. It therefore does not have to accept the producer's description of what problem it solved.
The original input reaches both the producer and the independent checker; the full report reaches the checker before a candidate is compared. Open vector figureFind a concrete error before comparing costs
A tempting shortcut asks Q1 and returns its value as the target. That is correct for every Q0=0 case. It also happens to work for two Q0=1 cases. A few successful examples could easily make this policy look finished.
The file examples/adaptive-wrong.json expresses that tree using numeric questions, answer branches and target leaves. Audit it against all eight rows:
python3 -B code/audit_strategy.py examples/INPUT.json examples/adaptive-wrong.json reports/OUTPUT.json
This command deliberately exits 1. The result has candidateCorrect: false and names rows 5 and 6 as failures. For row 5, Q1 is 0 but the target is 1. For row 6, Q1 is 1 but the target is 0. The complete saved result is in reports/adaptive-wrong-audit.json.
The shortcut asks Q1 and returns its value, producing wrong targets for rows 5 and 6. Open vector figureThe shortcut spends 4 effort units before it stops. That is less than the certified minimum of 5, but it is not a valid completion bound: the policy sometimes stops with the wrong target. The auditor reports candidateWorstCaseEffort: null and keeps the observed work in a separate workUntilExitMaximumEffort field.
That distinction is useful when reviewing generated plans. A procedure that fails early can appear faster than a working one. First require correctness on the declared catalogue; then compare the cost of completing the same task.
Separate a correct policy from a minimum policy
The natural adaptive tree asks Q0 first. On answer 0 it asks Q1; on answer 1 it asks Q2. Its two possible path costs are 1+4=5 and 1+2=3, so its worst effort is 5.
python3 -B code/audit_strategy.py examples/INPUT.json examples/adaptive-optimum.json reports/OUTPUT.json
This command exits 0. Its result confirms a correct candidate with effort 5, a verified full report, and a difference of 0 from the certified adaptive minimum. candidateWorstCaseQuestions is 2. Question count and effort are separate quantities here.
Q0 selects whether Q1 or Q2 determines the target; the largest path effort is five. Open vector figureNow audit a policy that repeats Q0:
python3 -B code/audit_strategy.py examples/INPUT.json examples/adaptive-repeat.json reports/OUTPUT.json
It also exits 0, because every supplied row still reaches the correct target. Its worst effort is 6, with a difference of 1 from the minimum. A repeated question consumes effort even though its answer is already determined by the path.
The report checker expects its attaining tree to avoid repeated questions. The candidate auditor admits repeats so that it can expose this kind of redundancy. Positive question costs make the distinction sound: asking an already known feature again cannot improve the minimum, but a proposed policy can still do it.
Omit the final report argument and the auditor can still check a candidate's answers and path costs. It will leave the certified minimum unknown. Correctness follows from simulating the supplied catalogue; minimum effort requires the additional verified comparison.
Compare fixed questions within their own mode
A fixed policy chooses the same questions for every row. It cannot ask Q0 and then choose a different next question according to the answer.
For this catalogue, every fixed policy needs all three features. You can establish that with three pairs:
| Required question | Rows that differ only there | Why the question is necessary |
|---|
| Q0 | 1 and 5 | Their targets differ; Q1 and Q2 agree. |
|---|
| Q1 | 0 and 2 | Their targets differ; Q0 and Q2 agree. |
|---|
| Q2 | 4 and 5 | Their targets differ; Q0 and Q1 agree. |
|---|
Omitting any one feature leaves a pair that the remaining answers cannot distinguish. Asking all three costs 1+4+2=7. Check the supplied fixed policy:
python3 -B code/audit_strategy.py examples/INPUT.json examples/fixed-complete.json reports/OUTPUT.json
The result gives a correct candidate with effort 7 and a difference of 0 from the fixed minimum. Comparing it with the adaptive minimum of 5 would answer a different question. The auditor selects the comparison bound from the candidate's mode.
The fixed auditor derives a target lookup from the catalogue groups. That establishes that the chosen answers contain enough information. It does not inspect a separate lookup implementation in your application; test that implementation too if you deploy one.
Check the certificate, then try to break it
An attaining tree gives an upper bound: there is a strategy that finishes within 5 effort units. Establishing a minimum also needs a lower bound: no allowed strategy can finish every row for less.
The adaptive certificate supplies a family of adverse answer choices. For each available question, it points to a nonempty response group that still requires enough remaining effort. The checker reconstructs these groups from the original table and checks the required budgets, question availability and references. It refuses malformed or incomplete evidence instead of trusting a claimed minimum.
For the fixed minimum, it enumerates every cheaper feature subset and checks a witness pair with different targets but identical selected answers. This example has seven such subsets. Those checks explain the checkedLowerNodes: 8 and cheaperFixedSets: 7 values in the verification receipt.
The provided examples/TAMPERED-OUTPUT.json changes the report's adaptive minimum from 5 to 4 while leaving the other evidence in place. Run:
python3 -B code/fqp_verify.py examples/INPUT.json examples/TAMPERED-OUTPUT.json
The checker prints CERTIFICATE_REJECTED to stderr and exits 2. Passing that file to the candidate auditor also refuses the comparison. A familiar filename, catalogue hash or success label does not make an altered result acceptable.
Keep the three outcomes distinct in automation: exit 0 means the requested check succeeded, exit 1 from the candidate auditor means a concrete policy failure, and exit 2 means the input, file or certificate was refused. A refused comparison is not evidence that a candidate is optimal or incorrect.
Keep the guarantee attached to its assumptions
This process checks a finite contract: the supplied rows are complete, targets are supplied correctly, allowed questions read individual listed features, and declared positive effort costs apply each time a question is asked. It does not establish those assumptions by observing a real system.
The supplied numerical code bounds catalogues to 32 rows and eight features. The walkthrough uses eight rows and three features so that its counterexamples and bounds remain readable. Exact checking can explore many subsets; the bounds are part of the tool's contract, rather than a claim about large-scale classification.
A separate implementation reduces shared code paths, but both implementations can still contain mistakes. The package therefore includes the original fixture, full report, candidate policies, expected results and a local test runner. You can reproduce the failure and the successful checks before adapting the example.
For an actual integration, preserve the original request, validate the full report against it, and audit the proposed policy within the same mode and cost model. Retain concrete failing rows when a policy fails. That gives the next reviewer something they can run and inspect, alongside the answer they were asked to trust.