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
24 changes: 24 additions & 0 deletions .azure/deployment-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,27 @@ Still requiring environment-specific acceptance (not replaced by those receipts)

No unattended cleanup worker, cloud IAM grants, Kubernetes dependency, background
sync, Azure app hosting or new cloud resources are introduced by this plan.


## Automatic local search startup boundary

Both Codespaces profiles use `npm run codespace:start`: normal two-site startup
and seeding first, then automatic bundled search preparation for local Site A/B.
This does not authenticate, provision or seed Azure, require a paid AI key, or
change any exercise. Attendees can begin at CORE READY while first-use downloads
finish (~274 MB model plus ~455 MB amd64 runtime). Refresh at SEARCH READY.
Verified cached resumes reuse the pinned model/bundle without a model-registry
request or downloader start; a missing runtime Docker image may still be pulled.

Normal `npm ci`, laptop startup and `npm run workspace:start` stay core-only.
`WORKSHOP_AUTO_SEARCH=0` in the lifecycle environment opts out (selected profile
`containerEnv` for persistence, not private `.env`). Older Codespaces require one
reviewed manual `git pull --ff-only` and `npm run codespace:start`; lifecycle never
runs Git or overwrites attendee edits. No destructive rebuild is needed to run the
new command with existing tools. Search-only failure warns without blocking core;
unsafe downloader cleanup and cancellation stay nonzero. See the
[search lifecycle and recovery guide](../docs/semantic-search.md).

The prior 17-second cached manual preparation is not a cold/new automatic-start
measurement. Fresh lifecycle/Codespaces proof must be recorded separately from
offline orchestration/cleanup tests and historical model/vector acceptance.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"onCreateCommand": "npm ci --ignore-scripts --no-audit --no-fund",
"postCreateCommand": "npm run setup",
"postStartCommand": "npm run workspace:start",
"postStartCommand": "npm run codespace:start",
"customizations": {
"vscode": {
"extensions": [
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/organizer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"onCreateCommand": "npm ci --ignore-scripts --no-audit --no-fund",
"postCreateCommand": "npm run setup && npm run organizer:check",
"postStartCommand": "npm run workspace:start",
"postStartCommand": "npm run codespace:start",
"customizations": {
"vscode": {
"extensions": [
Expand Down
54 changes: 46 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,19 @@ cross-listings, unresolved disagreements, and the excluded invalid break time.

1. [Open the workshop in Codespaces](https://codespaces.new/documentdb/ato-2026-workshop).
Choose **ATO 2026 - Attendee** if prompted.
2. Wait for setup to finish. It installs dependencies, generates independent
2. Wait for core setup to finish. It installs dependencies, generates independent
private development credentials, starts both databases and the app, waits for
each database, and seeds the same catalog in both. It does not copy favorites.
Then it automatically prepares **Search by meaning** for both local sites.
First use downloads a ~274 MB query model plus the pinned runtime (~455 MB on
amd64) and can take minutes; cached resumes verify/reuse the model and bundle.
No Azure connection or paid AI key is needed.
3. When the terminal says **Site A and Site B are ready and both catalogs are
seeded**, select **Ports** beside Terminal in the editor's bottom panel. Find
row **3000** and use **Open in Browser** (globe). Keep visibility **Private**.
You can begin the core exercises while search preparation finishes. The app
briefly restarts to enable search; when **SEARCH READY** appears, refresh the
planner, then use **Search by meaning** / **Check search readiness**.
4. Run `npm run extension:connections`, then follow the
[private connection steps](docs/extension.md#connect-the-two-existing-sites-privately)
to save **Workshop — Site A** and **Workshop — Site B** in the DocumentDB
Expand Down Expand Up @@ -81,7 +88,21 @@ Two databases need more memory/storage than the earlier single-site version;
preflight cold creation on the chosen Codespaces machine before class. Helpers
should triage at minute 12, not spend the workshop installing Docker on laptops.

Retry a failed setup after reading and resolving the error:
Retry a failed Codespaces setup after reading and resolving the error:

```sh
npm run codespace:start
```

It runs core setup first, then prepares the built-in search showcase. Search-only
failure prints **unavailable** and a retry command without stopping the core app
or databases. Cancellation and an unverifiable downloader cleanup are nonzero
errors; follow the [scoped recovery guide](docs/semantic-search.md#interruptions-and-emergency-downloader-recovery).
To skip automatic search for one run: `WORKSHOP_AUTO_SEARCH=0 npm run codespace:start`.
For a persistent opt-out, set `WORKSHOP_AUTO_SEARCH` to `"0"` in the selected
profile's `containerEnv` and rebuild, or use an equivalent Codespaces environment
setting. This is a **host lifecycle environment variable**, not a private `.env`
setting. The standalone laptop/core-only fallback remains:

```sh
npm run workspace:start
Expand All @@ -95,6 +116,16 @@ if they remain in an older `.env`. No Azure login, provisioning, or seed occurs.

### Existing notebook or older practice version?

Startup **never runs Git operations**: a new Codespace clones the selected branch;
a resumed one keeps its checkout and your exercise edits. It does not automatically
receive this new lifecycle from upstream. For an existing older Codespace, review
and preserve your changes, manually run **`git pull --ff-only` once** on the intended
branch (ask a helper if it refuses; do not reset/stash/overwrite exercises), then
run **`npm run codespace:start`**. Already-running environments with the existing
CLI tools need no destructive/full rebuild to prepare search now. Fresh or rebuilt
configurations use the new `postStartCommand` on future starts; until that config
is applied, run the new command explicitly on resumes.

Keep the same checkout directory and Compose project name to retain the existing
`documentdb-data` volume: it is still **Site A**. Site B gets a new, separate
`documentdb-site-b-data` volume. Changing directories/project names selects other
Expand Down Expand Up @@ -131,25 +162,32 @@ API**—over the same public title/track metadata. The catalog has no abstracts,
rankings are suggestions, not confidence claims. Keyword search stays separate;
missing models or indexes never trigger a hidden keyword/static fallback.

This is **not another lab exercise** and is disabled during ordinary startup.
Outside the 105-minute lab, after both sites are seeded, explicitly enable it:
This is **not another lab exercise**: both Codespaces profiles now prepare it
**automatically after core startup**, without solving or adding TODOs. No manual
search setup is required on a fresh/current-config Codespace. Laptop setup,
`npm ci` and `npm run workspace:start` remain core-only. For a search-only retry,
or to opt in on a laptop after both sites are seeded:

```sh
npm run search:prepare -- --local-sites
```

This downloads a pinned ~274 MB embedding model once for arbitrary live queries,
On a cache miss this downloads a pinned ~274 MB embedding model once for arbitrary live queries,
starts an internal-only CPU service, and **imports the same checked-in ~716 KiB
session-vector bundle** into both existing local sites before building each real
DocumentDB vector index. Attendee preparation makes **zero document-embedding
calls**; these are precomputed embeddings, not canned search results.
In the tested two-core Codespace, full optional preparation with the model/image
A **prior manual-preparation revision** in a two-core Codespace with the model/image
already cached took **17 seconds**, including about **1.8 seconds per site** for
import/index/verification. First-time model downloads add time; see the
import/index/verification. That is not a measurement of this automatic lifecycle
or first-time setup. Cached preparation now checks the full pinned manifest hash,
bounded size and model availability locally, without contacting the model registry
or starting the downloader. A missing Docker runtime image may still be pulled.
First-time model downloads add time; see the
[measured acceptance and limits](docs/semantic-search.md#codespace-and-browser-acceptance-october-18-2026).
It does not change catalog documents or favorites, provision Azure, or replace
your TODO code. See [optional search setup, limits, model/runtime tradeoffs and
verification](docs/semantic-search.md) before enabling it on a classroom machine.
verification](docs/semantic-search.md) for resource limits, opt-out and recovery.

## Complete reference and recovery

Expand Down
5 changes: 3 additions & 2 deletions compose.search.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Optional showcase only. Normal workspace:start never loads this overlay/model.
# Built-in showcase: Codespaces prepares it automatically after core startup.
# Normal workspace:start never loads this overlay/model.
# This bounded, multi-platform official runtime is deliberately CPU-only at runtime.
# See docs/semantic-search.md for the image-size tradeoff and model license.
x-search-runtime: &search-runtime
Expand Down Expand Up @@ -51,7 +52,7 @@ services:
profiles: [search-download]
networks:
- default
# Runs only while the explicit preparation command downloads the model.
# Runs only on a cache miss during automatic or manual preparation.
# No query traffic is sent here. Stopped in the preparation command's finally.

networks:
Expand Down
142 changes: 142 additions & 0 deletions docs/acceptance.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,147 @@
# Acceptance record and remaining gates

## Downloader preflight follow-up — October 18, 2026

Review reproduced a two-invocation safety gap in `b33a61e`: a successful model pull
followed by failed downloader shutdown released the process lock; a subsequent
valid-cache run could report ready while the old writable, outbound-capable
downloader remained running. The follow-up fails closed **before any inference
startup/cache access, registry fetch or indexing**, using the frozen project and
Docker context. Stable owned-container inspection requires explicit stopped,
not-paused, not-restarting states. Uncertain inventory produces the same nonzero
`SEARCH_DOWNLOAD_CLEANUP_FAILED` recovery error. No new automatic stop is added.

- Offline regression uses a **real filesystem lock and two preparation calls**:
pull succeeds/stop fails; the second cache-valid call refuses before mutations
or fetches. Explicit simulated scoped recovery allows the cached third call.
Additional cases reject running/restarting/paused/missing/unknown/malformed
states and failed/invalid/changing inventories. Existing whole-process-group
signal and cleanup tests remain passing.
- Full host suite: **194 passed, 1 Linux-only skip, 0 failures** (195 total).
- Actual owned local project `ato-auto-search-verify-20261018`: started only its
cached downloader, then preparation refused with zero registry fetches and no
app/database/model startup, execution or stop. Independent before/after state
and timestamps of those four services were unchanged. Scoped manual downloader
stop was verified **exited, Running/Restarting/Paused all false**; a subsequent
cached preparation reached both sites ready with zero fetches and unchanged
downloader timestamps. All owned services were stopped after proof; no volumes
deleted and no unrelated project changed.
- Search panel and disabled-state message now say Codespaces prepares search
automatically, core work can continue while loading, and the manual command is
for retry/laptop setup. This is copy-only: no polling or query/UI behavior change.

**The follow-up was also tested in the owned Codespace at
`92bc4a900deedb3c1e90f682520ecb83a895c59b`.** An actual running downloader was
rejected before any inference startup, cache access or registry fetch; app,
database and model state/timestamps stayed unchanged. Explicit scoped recovery
verified the downloader stopped; subsequent cached preparation succeeded with
**0 host fetches**, unchanged downloader timestamps and both stores reused.
The search phase took **10.03 seconds**. A separate complete automatic startup
with host `fetch` forbidden also succeeded with **0 fetches**. Environment and
both exercise-file hashes were unchanged. Codespace tests: **195/195 passed**,
**75 documentation links** passed. The updated automatic-start wording and an
actual five-result browser search were verified after recovery. These were
targeted cached checks, not a repeat of the full cold lifecycle below.

## Automatic Codespaces search startup — October 18, 2026

This revision adds automatic search preparation after normal core startup to both
Codespaces profiles. It builds on bundled-search main
`1b98ea4d246482b307cd1f59903f8b94ab18ca4c`; it does not change the search UI, vector
store, checked-in bundle, model/runtime pins, exercise files or Azure boundaries.
The older Codespace timings below and the prior **17.07-second cached manual**
search measurement are not measurements of this new lifecycle.

### Executed on an isolated local stack

- macOS arm64 host, Docker **2 CPUs / approximately 4 GiB RAM**, new project
`ato-auto-search-verify-20261018`, loopback app **8786** and database extension
ports **10272/10273**. New independent private credentials, database volumes,
model volume and runner volume; no other project's settings/data were adopted.
Existing pinned Docker images were cached. No Codespace or Azure resource was
changed, and no heavyweight replacement runtime was downloaded.
- Actual `npm run codespace:start` with **empty model/runner volumes** completed
in **55.72 seconds**. Core readiness appeared first; optional preparation took
**45.19 seconds**, including bounded cold read-only runner fallback, first
model download and verified downloader shutdown. Site A/B imported all **216**
bundled vectors in **2.290 / 2.269 seconds**, with zero document embeddings and
real hash/index/full-corpus cosine-query verification. This is not a cold Docker
image download or fresh Codespace measurement.
- A repeat of the automatic lifecycle with **host model-registry fetch forbidden**
completed in **13.49 seconds** (search phase **6.70 seconds**). It reported
`cached: true`, **0 external fetch calls**, and reused both real search collections
with full integrity/index/query probes (**157 / 165 ms**). The stopped downloader's
`StartedAt` and `FinishedAt` were exactly unchanged. The cache's actual manifest
passed the full SHA-256 pin and size check, followed by real `ollama show`.
- Actual inference inspection: read-only root filesystem and both model/runner
mounts; **no published ports**; only the Docker network marked `internal: true`.
- Real model/DocumentDB search integration **1/1 passed**; ordinary independent
two-site database/HTTP/aggregation integration **2/2 passed**. These suites use
and remove only their uniquely named test databases, not attendee notebooks.
- With an **injected cache miss plus simulated model-registry failure**, the real
automatic lifecycle returned **0 with `core: ready, search: unavailable`**, not
a search-ready claim. No model-cache files were altered. In command-scoped
complete-reference mode, actual core health/state endpoints remained **200**
with **216 sessions**; exercise source and private configuration were unchanged.
This is failure injection, not an observed internet outage.
- Live `WORKSHOP_AUTO_SEARCH=0 npm run codespace:start` and a subsequent cached
manual `search:prepare -- --local-sites` retry were also checked. No credential
rotation or exercise edits; all owned services are stopped after verification,
with their isolated volumes retained for reviewed retesting.

### Offline verification and limits

After `npm ci --ignore-scripts --no-audit --no-fund`, host `npm test` passed
**181 tests, 0 failures, 1 Linux-only skip** (182 total). Tests cover both profile
hooks, core-before-search ordering, opt-out, safe optional failures, hard cleanup
errors, cache digest/size/missing-blob/runner cases, zero external fetch/downloader
startup on a hit, bounded readiness, shared lock exclusion/release and no Git/Azure
lifecycle commands. Real OS subprocess tests deliver SIGINT/SIGTERM to whole
process groups during core startup and model preparation, including a second
signal during cleanup; cancellation stays nonzero and indexing never starts.
Existing search/bundle/UI regression tests remain unchanged. These signal tests
use fake Docker/registry services, not a live-container interruption claim for
this revision. Documentation links are checked offline.

### Actual fresh Attendee Codespace and real resume

A fresh two-core / 8 GiB Attendee Codespace executed the configured
`postStartCommand: npm run codespace:start` at `b33a61e35af294855a5c09717d77bd699d6d6c4b`.
No manual startup, search preparation or Git pull was used to reach readiness.

- Core HTTP 200 was observed about **4m30s after creation**; automatic
**SEARCH READY at 6m39s**, including runtime-image pulls and the first query-model
download. Both sites imported 216 checked-in vectors with **zero document
embedding calls**. GitHub host-level image caching cannot be characterized;
these are observations, not startup-time guarantees.
- The real browser showed the untouched Exercise 1 checkpoint while core was
ready, then semantic readiness and an actual AI-local search with the expected
**0.747 / 0.724** top scores. No manual search setup command was required.
- After an actual stop, verified Shutdown, and restart of that same Codespace,
automatic cached search preparation took **12.951 seconds**. Total restart
request through VM/core/search readiness was **83.792 seconds**, not 13 seconds.
The downloader ID and start/finish timestamps were unchanged.
- Supplemental instrumented automatic startup with host global `fetch` throwing
succeeded with **0 calls**, `cached:true`, and both search collections reused.
This instrumentation supplements rather than replaces the real resume.
- A controlled cache-miss/registry-failure injection left core HTTP 200 and search
unavailable, exited 0, and did not start a downloader or modify the cache.
Opt-out and subsequent cached recovery also passed. This was injected failure,
not a claimed real internet outage.
- Initial Codespace tests: **182/182**, 75 doc links, real database integration
**2/2**, and search integration **1/1**. Environment, exercise files, canonical
data, vectors, model pin and one test favorite remained unchanged across resume.
- Only app port **3000 / Private** was forwarded. The model stayed internal and
unpublished. Only the owned test Codespace was used; its data was retained and
its **Shutdown** state verified after testing. No Azure or billing changes.

The targeted `92bc4a9` follow-up guard and updated-copy tests are recorded above.
Final evidence publication changes documentation only. Organizer was not separately
created; both profile hooks have configuration/test coverage. Representative
account quotas/networks and human classroom timing remain unverified. See the
[automatic startup/recovery guide](semantic-search.md) for one-time old-checkout
updates, opt-out, cache receipts and scoped cleanup.

## Extension-integrated revision — live GUI acceptance

**Core fresh attendee GUI acceptance passed October 18, 2026.** A new two-core
Expand Down
Loading
Loading