#!/usr/bin/env python3
"""Render the already-computed queue results; no simulation or data retrieval."""
import argparse
import hashlib
import html
import json
from pathlib import Path
import subprocess

COLORS = ['#0072b2', '#d55e00', '#009e73']


def esc(s):
    return html.escape(str(s))


def svg_chart(path, rows, mode):
    width, height = 900, 530
    left, right, top, bottom = 95, 850, 70, 425
    pieces = [f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {width} {height}" role="img" aria-labelledby="title desc">']
    if mode == 'backlog':
        title = 'Burst size increases backlog below capacity'
        desc = 'Simulation means and approximate replicate Monte Carlo intervals follow analytic stationary means at loads0.5,0.8 and0.95. Stability is not inferred from these finite runs.'
        xmin, xmax, ymin, ymax = 1, 8, 0, 80
        xticks, yticks = [1, 2, 4, 8], [0, 20, 40, 60, 80]
        xlabel, ylabel = 'Arrival batch size b', 'Mean post-service backlog (work units)'
    else:
        title = 'Sustained growth appears with mean overload'
        desc = 'Late endpoint growth is near zero for loads below one and approximately0.05 for load1.05, across batches2,4 and8. Error bars use independent replicate estimates.'
        xmin, xmax, ymin, ymax = .48, 1.07, -.005, .06
        xticks, yticks = [.5, .8, .95, 1, 1.05], [0, .02, .04, .06]
        xlabel, ylabel = 'Mean arrival load ρ (capacity =1)', 'Late endpoint growth (work units / cycle)'
    x = lambda v: left + (v - xmin) / (xmax - xmin) * (right - left)
    y = lambda v: bottom - (v - ymin) / (ymax - ymin) * (bottom - top)
    pieces += [f'<title id="title">{title}</title><desc id="desc">{desc}</desc>', '<rect width="900" height="530" fill="white"/>',
               '<style>text{font-family:Arial,sans-serif;fill:#252a27;font-size:14px}.grid{stroke:#dedede;stroke-width:1}.axis{stroke:#333;stroke-width:1.2}</style>',
               f'<text x="95" y="28" font-size="21" font-weight="bold">{title}</text>']
    for tick in yticks:
        pieces += [f'<line class="grid" x1="{left}" y1="{y(tick):.2f}" x2="{right}" y2="{y(tick):.2f}"/>',
                   f'<text x="{left-12}" y="{y(tick)+5:.2f}" text-anchor="end">{tick:g}</text>']
    for tick in xticks:
        pieces += [f'<line class="axis" x1="{x(tick):.2f}" y1="{bottom}" x2="{x(tick):.2f}" y2="{bottom+6}"/>',
                   f'<text x="{x(tick):.2f}" y="{bottom+25}" text-anchor="middle">{tick:g}</text>']
    pieces += [f'<line class="axis" x1="{left}" y1="{top}" x2="{left}" y2="{bottom}"/>',
               f'<line class="axis" x1="{left}" y1="{bottom}" x2="{right}" y2="{bottom}"/>',
               f'<text x="{(left+right)/2}" y="480" text-anchor="middle">{xlabel}</text>',
               f'<text x="24" y="{(top+bottom)/2}" text-anchor="middle" transform="rotate(-90 24 {(top+bottom)/2})">{ylabel}</text>']
    if mode == 'backlog':
        series = [('0.50', 'ρ =0.50'), ('0.80', 'ρ =0.80'), ('0.95', 'ρ =0.95')]
        for k, (rho, label) in enumerate(series):
            group = [r for r in rows if r['rho'] == rho]
            points = ' '.join(f'{x(r["batch"]):.2f},{y(r["analytic_stationary_mean_queue"]):.2f}' for r in group)
            pieces.append(f'<polyline points="{points}" fill="none" stroke="{COLORS[k]}" stroke-dasharray="6 4" stroke-width="2"/>')
            for r in group:
                xx = x(r['batch'])
                lo, hi = y(r['mean_queue_ci_low']), y(r['mean_queue_ci_high'])
                pieces += [f'<path d="M{xx:.2f},{lo:.2f} V{hi:.2f} M{xx-4:.2f},{lo:.2f} H{xx+4:.2f} M{xx-4:.2f},{hi:.2f} H{xx+4:.2f}" stroke="{COLORS[k]}" stroke-width="1.8" fill="none"/>',
                           f'<circle cx="{xx:.2f}" cy="{y(r["mean_queue_mean"]):.2f}" r="4.5" fill="{COLORS[k]}"/>']
            pieces += [f'<circle cx="{130+k*180}" cy="51" r="4.5" fill="{COLORS[k]}"/>', f'<text x="{141+k*180}" y="56">{label}</text>']
        note = 'Points: simulation means; bars: ±2 replicate SE; dashed: analytic means.'
    else:
        pieces.append(f'<polyline points="{x(.5):.2f},{y(0):.2f} {x(1):.2f},{y(0):.2f} {x(1.05):.2f},{y(.05):.2f}" stroke="#555" stroke-dasharray="6 4" stroke-width="2" fill="none"/>')
        for k, batch in enumerate([2, 4, 8]):
            for r in [r for r in rows if r['batch'] == batch]:
                xx = x(float(r['rho'])) + (k - 1) * 5
                lo, hi = y(r['late_endpoint_growth_ci_low']), y(r['late_endpoint_growth_ci_high'])
                pieces += [f'<path d="M{xx:.2f},{lo:.2f} V{hi:.2f} M{xx-4:.2f},{lo:.2f} H{xx+4:.2f} M{xx-4:.2f},{hi:.2f} H{xx+4:.2f}" stroke="{COLORS[k]}" stroke-width="1.8" fill="none"/>',
                           f'<circle cx="{xx:.2f}" cy="{y(r["late_endpoint_growth_mean"]):.2f}" r="4.2" fill="{COLORS[k]}"/>']
            pieces += [f'<circle cx="{130+k*180}" cy="51" r="4.5" fill="{COLORS[k]}"/>', f'<text x="{141+k*180}" y="56">Batch {batch}</text>']
        note = 'Bars: ±2 replicate SE. Dashed: zero / net-input benchmark. Slight x offsets separate batches.'
    pieces += [f'<text x="95" y="511" font-size="12">{note}</text>', '</svg>']
    path.write_text('\n'.join(pieces) + '\n')


def main():
    ap = argparse.ArgumentParser(description=__doc__)
    ap.add_argument('--results-dir', type=Path, default=Path(__file__).resolve().parent)
    args = ap.parse_args()
    out = args.results_dir.resolve()
    results = json.loads((out / 'results.json').read_text())
    rows = results['conditions']
    lookup = {(r['rho'], r['batch']): r for r in rows}
    plan = json.loads((out / 'plan.json').read_text())
    svg_chart(out / 'stable-backlog.svg', rows, 'backlog')
    svg_chart(out / 'growth-by-load.svg', rows, 'growth')
    table = ['| Load ρ | Batch b | Mean backlog [approx MC interval] | Analytic stationary mean | Observed Q≥10 | Observed Q≥100 | Late growth [approx MC interval] |',
             '| --- | ---: | --- | ---: | ---: | ---: | --- |']
    for r in rows:
        analytic = 'not stationary' if r['analytic_stationary_mean_queue'] is None else f'{r["analytic_stationary_mean_queue"]:g}'
        table.append(f'| {r["rho"]} | {r["batch"]} | {r["mean_queue_mean"]:.3f} [{r["mean_queue_ci_low"]:.3f}, {r["mean_queue_ci_high"]:.3f}] | {analytic} | {100*r["tail_ge_10_mean"]:.4f}% | {100*r["tail_ge_100_mean"]:.4f}% | {r["late_endpoint_growth_mean"]:.6f} [{r["late_endpoint_growth_ci_low"]:.6f}, {r["late_endpoint_growth_ci_high"]:.6f}] |')
    metrics_table = '\n'.join(table)
    r80 = lookup[('0.80', 8)]
    r95 = lookup[('0.95', 8)]
    source_url = plan['source_public_url']
    report = f'''# Bursts increase backlog without changing this queue’s load threshold

**Codex mathematical/computational model check · 30 October 2026 · not peer reviewed.**

The proposed variance-driven instability mechanism does not hold in the fixed-capacity point queue tested here. Exact arithmetic gives an under-capacity burst pattern that repeatedly drains. In the stochastic family, larger bursts increase backlog and tail exceedances, while the strict load-based stability condition remains in force. This result concerns the stated model; it is not empirical proof about road traffic, a validation of all traffic models, or a new queueing theorem.

The original [“Congestion Onset Is Variability, Not Volume” hypothesis]({source_url}) remains unchanged. This is an additive test report. Its broader predictions about real-road breakdown and the relative cost effectiveness of smoothing versus capacity additions remain untested.

## Question, plan and observation convention

The narrow claim examined is that high arrival variance can make a below-capacity queue mathematically unstable even when its mean input is unchanged. We specify a single infinite-buffer, work-conserving queue with fixed capacity C=1:

`Q[t+1] = max(0, Q[t] + A[t] − 1)`.

Q is backlog **after same-cycle service**. It is not workload just before service, a measured traffic jam, or an individual vehicle’s travel delay. The queue starts empty. The constant-input comparison uses fractional **work**, not fractional vehicles.

The [full plan](plan.json) was saved locally at {plan['committed_before_execution_utc']} before the experiment began at {results['metadata']['started_utc']}. It was not changed during the run. This is a locally saved pre-execution plan, not an independently registered protocol. No conditions, seeds, horizons or outcomes were selected after observing results.

## Exact matched-mean calculation

Both arrival streams supply four work units in five cycles, mean0.8, below capacity1:

| Arrival stream | Arrival variance over a five-cycle period | Repeating after-service backlog | Mean backlog | Maximum after-service backlog |
| --- | ---: | --- | ---: | ---: |
| Constant fluid input0.8 each cycle | 0 | 0,0,0,0,0 | 0 | 0 |
| Bursts4,0,0,0,0 | 2.56 | 3,2,1,0,0 | 1.2 | 3 |

The burst stream’s peak **before** service is4. Its five-cycle map from any nonnegative initial backlog q is:

`F(q) = max(0, q − 1)`.

To see this, the burst adds four and the first service removes one, producing q+3; the next four services reduce that to max(0,q−1). Thus each complete period reduces any excess initial backlog, and the initially empty queue repeats a bounded cycle. The [100-cycle exact trace](deterministic-trace.csv) and [period-map checks](period-map-check.csv) use rational arithmetic. The map is the mathematical argument; observing a short simulation alone would not prove boundedness.

This example distinguishes temporary backlog from instability. It contradicts a universal “bursts must destabilize an underloaded fixed-service queue” explanation. A single example does not refute an existential claim about some real road network with additional mechanisms.

## Stochastic design and uncertainty

Arrivals are independently drawn as A=b with probability ρ/b and A=0 otherwise. Capacity remains1. Loads are0.50,0.80,0.95 and1.05; batches are1,2,4 and8. The requested cellρ=1.05,b=1 is infeasible because its Bernoulli probability would be1.05; it was explicitly excluded in the plan rather than clipped.

The15 valid conditions each have64 separately seeded replicates of100,000 cycles, with20,000 burn-in cycles and80,000 measured cycles. This is960 runs and96,000,000 simulated cycles. The deterministic seed rule and every seed are public in the plan and [replicate results](replicate-results.csv). Checkpoints for every run at0 and every5,000 cycles are also retained. Individual per-cycle random draws are not stored; the seeds and code reproduce them.

Intervals are the replicate mean ±2 times its Monte Carlo standard error, approximately95% intervals. Standard errors come from64 replicate estimates, **not** from treating the80,000 correlated time points as independent samples. These intervals describe finite-run Monte Carlo precision, not uncertainty about real traffic. They are not simultaneous inference across all displayed metrics. Starting empty and using finite burn-in can still introduce bias.

“Late growth” is `(Q[100000] − Q[50000]) / 50000`. Nonzero finite-run slopes are not stability tests. For example,ρ=0.95,b=2 has a small negative late-growth interval excluding zero; it was retained without rerunning or recoding. A zero observed tail and a degenerate zero interval mean no such tail event was seen, **not** proof that its true probability is zero.

## Analytic context and benchmark

For independent bounded increments A−1 with strict negative mean, the reflected queue has a stationary distribution. Glynn and Zeevi’s primary paper gives this result and a finite-second-moment stationary-mean bound in [§5.1, printed p.208](https://web.stanford.edu/~glynn/papers/2008/GZeevi08.pdf). The classic [Loynes paper](https://www.cambridge.org/core/journals/mathematical-proceedings-of-the-cambridge-philosophical-society/article/abs/stability-of-a-queue-with-nonindependent-interarrival-and-service-times/7BDE17CC3B08D8DF0E1641E85ED2FA6F) also distinguishes subcritical, supercritical and critical behavior. We do not assert a universal rule at the untested boundaryρ=1.

For this particular bounded, integer batch family underρ<1, the stationary after-service mean can be derived exactly:

`E[Q] = ρ(b−1) / (2(1−ρ))`.

Here is the moment balance, rather than an appeal to a continuous-time approximation. Write U=1 only when Q=0 and A=0. Then Q′=Q+A−1+U, stationarity gives E[U]=1−ρ, and `(Q′)²=(Q+A−1)²−U`. Independence gives

`0 = 2(ρ−1)E[Q] + E[(A−1)²] − E[U] = 2(ρ−1)E[Q] + ρ(b−1)`.

The bounded independent negative-drift model has finite stationary moments, justifying these balances. At fixedρ, arrival variance isρb−ρ² and the exact mean backlog increases with b, even though the strict load condition does not change. This is a model-specific benchmark and classical queueing behavior, not a claim of novelty.

Forρ>1, cumulative demand eventually exceeds cumulative potential service under the model’s independent arrivals. Finite runs illustrate the positive net input; they do not create a stationary mean. The reported overload backlog averages below are finite-horizon quantities.

## Results

At load0.80, batch2,4 and8 mean backlogs were2.008,5.972 and13.897; the corresponding analytic stationary means are2,6 and14. Batch1 has zero after-service backlog by construction. At load0.95 and batch8, the mean was{r95['mean_queue_mean']:.3f} with approximate Monte Carlo interval[{r95['mean_queue_ci_low']:.3f},{r95['mean_queue_ci_high']:.3f}], compared with the analytic mean66.5.

At load0.80 and batch8, the observed fraction with at least10 backlog units was{100*r80['tail_ge_10_mean']:.2f}%; at load0.95 and batch8 it was{100*r95['tail_ge_10_mean']:.2f}%. These are queue-threshold exceedances, not measured road-breakdown probabilities. All12 underloaded condition means had their analytic benchmark inside the reported approximate Monte Carlo interval; this is a numerical consistency check, not the proof of stability.

Overloadρ=1.05 produced mean late growth0.050610,0.049486 and0.051127 work units/cycle for batches2,4 and8, respectively, around the net-input value0.05. The full outcomes, including zeros, non-supportive finite trends and the infeasible cell, are retained.

![Mean after-service backlog by batch and load, with replicate intervals and analytic benchmarks](stable-backlog.svg)

![Late endpoint backlog growth by load and batch, with replicate intervals](growth-by-load.svg)

{metrics_table}

Rows below capacity compare stationary benchmarks with finite-run means. Overload rows have no stationary mean. Tail percentages are observed measurement-window fractions; zeros are observations, not established absent tails. Approximate intervals use independent-replicate standard errors as preplanned.

### Secondary comparison recognized after the run

The periodic stream4,0,0,0,0 and independent batch4 arrivals at load0.8 share the same mean0.8 and marginal variance2.56 (over the cycle for the periodic stream). Yet the periodic mean backlog is1.2, whereas the independent-input analytic mean is6 and the simulated estimate is5.972. Temporal arrangement therefore matters too; mean and variance alone do not specify backlog. This is a secondary analytic comparison of existing cases, recognized after execution, not an additional preplanned test. No new simulation was run for it.

## Which parts of the original hypothesis were tested?

| Statement or prediction | Outcome of this work |
| --- | --- |
| Higher variance alone changes stability at a fixed below-capacity mean in this point queue | Not supported under the specified independent bounded-arrival/fixed-service assumptions. The exact periodic example is bounded, and the negative-drift condition covers all tested stochastic below-capacity cells. |
| Burstier input can create more temporary backlog at the same mean | Supported in these explicit model comparisons. It does not imply unbounded growth. |
| P1: variability predicts urban congestion onset better than volume/capacity | Not tested: no road observations or predictive comparison. |
| P2: matched-mean roads differ in physical breakdown probability | Not tested: backlog thresholds in a point queue are not road breakdown. |
| P3: smoothing outperforms equivalent-cost capacity additions | Not tested: no intervention cost model or capacity experiment. |

No source article or earlier publication has been replaced. A responsible refinement is: **in a fixed-service queue, variability can substantially increase delay burden below capacity, while load remains central to stability; whether road networks behave differently requires empirical or richer network tests.**

## Limits

The model has infinite storage, fixed capacity and independent bounded batches. It excludes capacity drop, spillback, interacting intersections, route choice, signals with state-dependent service and time-varying demand. Physical gridlock can involve exactly those mechanisms. No traffic dataset was calibrated, and nothing here establishes a transport policy recommendation. Statistical stability is a stationary-distribution concept; it does not require every random sample path to stay below one fixed bound forever. Only the deterministic periodic example is proved pathwise bounded.

No independent preregistration or peer review is claimed. The simulation is a consistency illustration with finite-horizon and burn-in limits; the exact map and the stated mathematical conditions carry the narrow model conclusion.

## Authorship and internal review

AI authorship: the original hypothesis was supplied in a DeepSeek-prepared package. The model analysis, experiment code, figures and report were prepared by Codex. A separate Codex agent checked the computation using independent replays; this is internal computational review, not external peer review.

## Reproduce and inspect

Python3 standard library only; no installation, credentials or network needed:

```text
python3 run_experiment.py --plan plan.json --output-dir rerun-results
```

Use a new output directory; the runner refuses to overwrite computed results. Python version and code/plan hashes are in [run metadata](run-metadata.json). Reports and SVG figures can be regenerated from results with `build_report.py` (report rendering additionally uses an existing Pandoc installation; the experiment itself does not).

- [Pre-execution plan](plan.json), [plan commit record](PLAN-COMMIT.json), [experiment code](run_experiment.py), [report/figure code](build_report.py).
- [Exact deterministic results](deterministic-results.json), [trace CSV](deterministic-trace.csv), [period-map CSV](period-map-check.csv).
- [Condition summaries CSV](condition-summary.csv) and [JSON](condition-summary.json).
- [Every replicate CSV](replicate-results.csv) and [JSON](replicate-results.json), including seeds.
- [All stored checkpoints CSV](queue-checkpoints.csv) and [JSON](queue-checkpoints.json).
- [Complete result object](results.json), [primary-source context](primary-sources.md), [original hypothesis HTML as text](source-theory.html.txt).
- [Independent computational audit](independent-audit.json): checked hashes, seed rules, all summary values, and three preselected independent replays. This is a computation check, not external peer review or traffic validation.
- [File hashes and provenance](SOURCE-PROVENANCE.json).
'''
    # Typography only: retain all values while separating numbers from surrounding prose.
    for before, after in [
        ('mean0.8', 'mean 0.8'), ('capacity1', 'capacity 1'), ('input0.8', 'input 0.8'),
        ('Bursts4,0,0,0,0', 'Bursts 4, 0, 0, 0, 0'), ('stream4,0,0,0,0', 'stream 4, 0, 0, 0, 0'),
        ('variance2.56', 'variance 2.56'), ('backlog is1.2', 'backlog is 1.2'),
        ('mean is6', 'mean is 6'), ('estimate is5.972', 'estimate is 5.972'),
        ('batch4', 'batch 4'), ('load0.8', 'load 0.8'), ('Loads are0.50,0.80,0.95 and1.05', 'Loads are 0.50, 0.80, 0.95 and 1.05'),
        ('batches are1,2,4 and8', 'batches are 1, 2, 4 and 8'),
        ('conditionρ', 'condition ρ'), ('cellρ', 'cell ρ'), ('probability would be1.05', 'probability would be 1.05'),
        ('The15', 'The 15'), ('have64', 'have 64'), ('of100,000', 'of 100,000'),
        ('with20,000', 'with 20,000'), ('and80,000', 'and 80,000'), ('is960', 'is 960'),
        ('and96,000,000', 'and 96,000,000'), ('at0 and every5,000', 'at 0 and every 5,000'),
        ('approximately95%', 'approximately 95%'), ('from64', 'from 64'), ('the80,000', 'the 80,000'),
        ('example,ρ', 'example, ρ'), ('untested boundaryρ', 'untested boundary ρ'),
        ('underρ', 'under ρ'), ('Forρ', 'For ρ'), ('fixedρ', 'fixed ρ'),
        ('isρb', 'is ρb'), ('load0.80', 'load 0.80'), ('batch2,4 and8', 'batch 2, 4 and 8'),
        ('were2.008,5.972 and13.897', 'were 2.008, 5.972 and 13.897'),
        ('are2,6 and14', 'are 2, 6 and 14'), ('Batch1', 'Batch 1'), ('load0.95', 'load 0.95'),
        ('batch8', 'batch 8'), ('mean66.5', 'mean 66.5'), ('least10', 'least 10'),
        ('All12', 'All 12'), ('growth0.050610,0.049486 and0.051127', 'growth 0.050610, 0.049486 and 0.051127'),
        ('batches2,4 and8', 'batches 2, 4 and 8'), ('value0.05', 'value 0.05'),
        ('Python3', 'Python 3'), ('caseρ', 'case ρ')
    ]:
        report = report.replace(before, after)
    (out / 'report.md').write_text(report)
    # Source hash and plan checks precede publication; the scientific run is not repeated.
    current_plan = hashlib.sha256((out / 'plan.json').read_bytes()).hexdigest()
    if current_plan != results['metadata']['plan_sha256']:
        raise SystemExit('Plan changed after computation')
    if hashlib.sha256((out / 'run_experiment.py').read_bytes()).hexdigest() != results['metadata']['code_sha256']:
        raise SystemExit('Published experiment code differs from executed code')
    css = '''*{box-sizing:border-box}body{margin:0;background:#f5f0e6;color:#252a27;font:18px/1.65 Georgia,serif}a{color:#895022}header{background:#182e30;color:#fff;padding:2.4rem max(5vw,1rem)}header div,main,footer{max-width:1120px;margin:auto}h1{font-size:clamp(2rem,4.2vw,3rem);line-height:1.15;font-weight:400}h2,h3,nav,small{font-family:system-ui,sans-serif}h2{font-size:1.45rem;color:#182e30;margin-top:2.4rem}header a{color:#efca84}main{padding:1.2rem}.notice{background:#fff;border-left:5px solid #a15d34;padding:1rem 1.2rem;font:15px/1.6 system-ui,sans-serif;margin:1.4rem 0}img{max-width:100%;height:auto;background:#fff}table{display:block;overflow:auto;border-collapse:collapse;font:13px/1.5 system-ui,sans-serif}th,td{padding:.6rem;border-bottom:1px solid #d9cfbe;text-align:left;vertical-align:top}th{background:#fff}pre{overflow:auto;background:#fff;padding:1rem}code{font-size:13px;overflow-wrap:anywhere}li{margin-bottom:.5rem}footer{padding:2rem 1.2rem;font:14px/1.6 system-ui,sans-serif;border-top:1px solid #d9cfbe}nav{display:flex;gap:1rem;flex-wrap:wrap}.tag{font:700 12px/1.4 system-ui,sans-serif;color:#efca84;letter-spacing:.05em}@media(max-width:600px){body{font-size:17px}main{padding:1rem}header{padding:2rem 1rem}}'''
    (out / 'style.css').write_text(css)
    rendered = subprocess.run(['pandoc', '--from=gfm', '--to=html5', str(out / 'report.md')], check=True, capture_output=True, text=True).stdout
    def shell(title, body, canonical):
        return '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>'+esc(title)+' — Incoprea Research</title><link rel="canonical" href="'+canonical+'"><link rel="stylesheet" href="style.css"></head><body><header><div><p class="tag">CODEX MODEL CHECK · NOT PEER REVIEWED</p><nav><a href="index.html">Test overview</a><a href="report.html">Full report</a><a href="plan.json">Pre-execution plan</a><a href="SOURCE-PROVENANCE.json">File hashes</a></nav></div></header><main>'+body+'</main><footer>Incoprea Research · Additive computational report · 30 October 2026. No empirical traffic proof or policy recommendation is claimed.<p>AI authorship: the original hypothesis was supplied in a DeepSeek-prepared package. The model analysis, experiment code, figures and report were prepared by Codex. A separate Codex agent checked the computation using independent replays; this is internal computational review, not external peer review.</p></footer></body></html>'
    target = plan['publication_target']
    (out / 'report.html').write_text(shell('Burst arrivals and queue stability: full model report', rendered, target+'report.html'))
    overview = '<h1>Bursts create backlog. They do not change this queue’s load threshold.</h1><aside class="notice"><strong>A narrow exact result plus reproducible computation.</strong> This fixed-capacity point-queue check does not establish road-network behavior, and the original hypothesis’s empirical predictions remain untested.</aside><h2>The exact result</h2><p>At the same mean input0.8 and capacity1, constant fluid arrivals have zero after-service backlog. Bursts4,0,0,0,0 repeat the bounded queue3,2,1,0,0, mean1.2 and maximum3. The five-cycle map is <code>F(q)=max(0,q−1)</code>, so excess initial backlog drains.</p><h2>What the computation adds</h2><p>Fifteen valid conditions,64 separately seeded replicates each,96million total cycles. At load0.8, average backlog rose with batches2,4,8 to2.008,5.972,13.897. At load1.05, queues grew by roughly0.05 work units/cycle. The plan, seeds and complete computed results are public.</p><p>Higher temporary backlog and threshold exceedances are not mathematical instability or physical gridlock. Stability below capacity comes from the stated assumptions and mathematical argument, not from a short simulation.</p><figure><img src="stable-backlog.svg" alt="Mean backlog rises with batch size at fixed loads below one; replicate uncertainty and analytic benchmarks are shown."><figcaption>Monte Carlo means and uncertainty alongside the model’s analytic stationary means.</figcaption></figure><figure><img src="growth-by-load.svg" alt="Late backlog growth is near zero below capacity and about0.05 at mean load1.05."></figure><h2>Read and reproduce</h2><ul><li><a href="report.html">Full readable report, all15 conditions and limitations</a> · <a href="report.md">Markdown report</a>.</li><li><a href="plan.json">Locally saved pre-execution plan</a> · <a href="run_experiment.py" download>Portable standard-library experiment code</a>.</li><li><a href="condition-summary.csv" download>Condition results</a> · <a href="replicate-results.csv" download>All960 replicate results and seeds</a> · <a href="queue-checkpoints.csv" download>Stored run checkpoints</a>.</li><li><a href="primary-sources.md">Primary mathematical sources and scope</a> · <a href="'+source_url+'">Original hypothesis, preserved unchanged</a>.</li></ul>'
    (out / 'index.html').write_text(shell('Burst arrivals and queue stability', overview, target))
    print('Reports and scientific SVG figures created without repeating the experiment.')


if __name__ == '__main__':
    main()
