From 8dbf673a9c09ddcbb1e4e90389cba8c8f44f8b58 Mon Sep 17 00:00:00 2001 From: OpenAI Codex Date: Mon, 26 Oct 2026 12:20:17 +0000 Subject: [PATCH] Make Library current-source searches recoverable and shareable --- .../library-source-search-20261026/README.md | 45 ++++ .../SOURCE.json | 12 + .../baseline-summary.json | 29 +++ .../browser-final.json | 226 ++++++++++++++++++ .../harness-diagnostic.json | 24 ++ .../local-checks.json | 90 +++++++ .../preimages.json | 24 ++ docs/site/README.md | 15 ++ docs/site/library-source-search.mjs | 51 ++++ docs/site/research-desk.css | 6 + docs/site/research-desk.mjs | 2 + docs/site/workspace.html | 4 +- .../plans/2026-10-26-library-source-search.md | 45 ++++ .../specs/2026-10-26-library-source-search.md | 28 +++ tests/test_library_source_search.mjs | 26 ++ tools/library_source_search_browser_check.py | 141 +++++++++++ 16 files changed, 766 insertions(+), 2 deletions(-) create mode 100644 docs/reports/library-source-search-20261026/README.md create mode 100644 docs/reports/library-source-search-20261026/SOURCE.json create mode 100644 docs/reports/library-source-search-20261026/baseline-summary.json create mode 100644 docs/reports/library-source-search-20261026/browser-final.json create mode 100644 docs/reports/library-source-search-20261026/harness-diagnostic.json create mode 100644 docs/reports/library-source-search-20261026/local-checks.json create mode 100644 docs/reports/library-source-search-20261026/preimages.json create mode 100644 docs/site/library-source-search.mjs create mode 100644 docs/superpowers/plans/2026-10-26-library-source-search.md create mode 100644 docs/superpowers/specs/2026-10-26-library-source-search.md create mode 100644 tests/test_library_source_search.mjs create mode 100644 tools/library_source_search_browser_check.py diff --git a/docs/reports/library-source-search-20261026/README.md b/docs/reports/library-source-search-20261026/README.md new file mode 100644 index 000000000..c93043420 --- /dev/null +++ b/docs/reports/library-source-search-20261026/README.md @@ -0,0 +1,45 @@ +# Library source search recovery, 26 October 2026 + +Current-source search previously left an empty list after a zero-match query, +with no nearby reset or search-link action. The Library now offers Clear search, +Link to this search and its existing Save current search together. A zero-match +message suggests recovery. The link carries the literal query, preserves other +page parameters and explicitly reopens against the available admitted observation; +it does not freeze results. Clear uses the existing filter, resets pagination and +returns keyboard focus to the input. + +This is a Library-only progressive enhancement attached after currentSnapshot +verification. The current collector, admission/filtering/history implementations, +source cuts, dated catalog, graph, mathematics, certifications and worker service +are unchanged. There is no new network request, dependency or storage schema. +Unverified/unavailable current snapshots expose no enabled enhancement controls. + +Authored base: `f8ea0b530fed1942aa23d79a8fce179a679862f8`. The source fingerprints +in SOURCE.json bind the working-tree bytes tested before the source commit; they +are not a retrospective claim of execution at an eventual commit. Existing exact +preimages were matched to the independently downloaded prior complete source ZIP. + +Observed checks: + +- Original browser: five expected missing-control failures, zero page errors. +- Final Chromium154.0.8037.57:16/16 cases pass, zero page errors;1440 light/dark, + 390 light/dark and320 light. Tests include keyboard reset, special-character + query links/new tabs/reload, pagination reset, native Back/Forward, newer external + focus and source unavailability. External HTTPS requests are refused. +- Focused Node:3/3 pass, including literal URL state and no initialization before + admission/on unrelated pages. Prescribed local groups and existing reading-list, + Undo and Cite regressions have their exact results in local-checks.json. + +Two first-candidate history assertions failed because the driver captured the +automation client's cached URL before its frame-notification arrived. Renderer +location.href showed the correct synchronous replaceState. The driver now captures +the renderer URL and waits for native traversal; product source was unchanged. +The first invocation also had a serve-helper signature error before opening a +browser. Those failures remain in delivery evidence, not relabelled as passes. + +Actual performer: OpenAI/Codex author; separate engineering review and integration +have their own native PR records. Same-family engineering review is permitted; +organizational-independence credit0 and scientific effect NONE. These emulated +headless Linux browser checks do not qualify physical touch, Safari, spoken AT, +full accessibility compliance or mathematical source applicability. Public worker +operation still depends on an adopted service contract and reviewed record joins. diff --git a/docs/reports/library-source-search-20261026/SOURCE.json b/docs/reports/library-source-search-20261026/SOURCE.json new file mode 100644 index 000000000..e92cead44 --- /dev/null +++ b/docs/reports/library-source-search-20261026/SOURCE.json @@ -0,0 +1,12 @@ +{ + "authored_base": "f8ea0b530fed1942aa23d79a8fce179a679862f8", + "execution": "Working-tree bytes before source commit; source claims use SHA-256, not a later Git head.", + "source_sha256": { + "docs/site/library-source-search.mjs": "14f991580777003531619052771843d916a0bd8bd7d548a3863614df46290228", + "docs/site/research-desk.mjs": "7f25981461881554a67c421d4cddb6ad348667f2ca5efe777a7e27987f76b36a", + "docs/site/research-desk.css": "0caa3b78bf851c701ba2fad9666da34948a9afade6c21aba6e4a06ed6cc79062", + "docs/site/workspace.html": "1aeb1162bee7c2594edc4308d4d97f90624c108844cee1883856cea6b4a4ccf5" + }, + "asset_release": "aae0c5c7a7c42f2bd1a0eaa9b8a1f976f28da0fe4f3154f6c1857b38632d4187", + "scientific_effect": "NONE" +} diff --git a/docs/reports/library-source-search-20261026/baseline-summary.json b/docs/reports/library-source-search-20261026/baseline-summary.json new file mode 100644 index 000000000..615d29d7d --- /dev/null +++ b/docs/reports/library-source-search-20261026/baseline-summary.json @@ -0,0 +1,29 @@ +{ + "browser": "154.0.8037.57", + "passed": 0, + "failed": 5, + "page_errors": [], + "reason": "All five cases fail at the absent #library-source-empty recovery control on original base source; no implementation existed. Original full reports retained in delivery evidence.", + "cases": [ + { + "case": "empty-recovery-keyboard-1440-light", + "passed": false + }, + { + "case": "empty-recovery-keyboard-1440-dark", + "passed": false + }, + { + "case": "empty-recovery-keyboard-390-light", + "passed": false + }, + { + "case": "empty-recovery-keyboard-390-dark", + "passed": false + }, + { + "case": "empty-recovery-keyboard-320-light", + "passed": false + } + ] +} diff --git a/docs/reports/library-source-search-20261026/browser-final.json b/docs/reports/library-source-search-20261026/browser-final.json new file mode 100644 index 000000000..587b05d42 --- /dev/null +++ b/docs/reports/library-source-search-20261026/browser-final.json @@ -0,0 +1,226 @@ +{ + "observed_at": "2026-10-26T12:16:23.827633+00:00", + "cases": [ + { + "case": "empty-recovery-keyboard-1440-light", + "passed": true + }, + { + "case": "literal-query-native-link-reload-1440-light", + "passed": true + }, + { + "case": "pagination-history-focus-1440-light", + "passed": true + }, + { + "case": "empty-recovery-keyboard-1440-dark", + "passed": true + }, + { + "case": "literal-query-native-link-reload-1440-dark", + "passed": true + }, + { + "case": "pagination-history-focus-1440-dark", + "passed": true + }, + { + "case": "empty-recovery-keyboard-390-light", + "passed": true + }, + { + "case": "literal-query-native-link-reload-390-light", + "passed": true + }, + { + "case": "pagination-history-focus-390-light", + "passed": true + }, + { + "case": "empty-recovery-keyboard-390-dark", + "passed": true + }, + { + "case": "literal-query-native-link-reload-390-dark", + "passed": true + }, + { + "case": "pagination-history-focus-390-dark", + "passed": true + }, + { + "case": "empty-recovery-keyboard-320-light", + "passed": true + }, + { + "case": "literal-query-native-link-reload-320-light", + "passed": true + }, + { + "case": "pagination-history-focus-320-light", + "passed": true + }, + { + "case": "unavailable-snapshot-no-enabled-tools", + "passed": true + } + ], + "page_errors": [], + "scope": "Engineering only; no source acquisition, mathematical review or spoken AT claim.", + "browser": "154.0.8037.57", + "history_observations": [ + { + "stage": "before-fragment", + "width": 1440, + "scheme": "light", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current" + }, + { + "stage": "before-back", + "width": 1440, + "scheme": "light", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list" + }, + { + "stage": "after-back", + "width": 1440, + "scheme": "light", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current", + "expected": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current" + }, + { + "stage": "after-forward", + "width": 1440, + "scheme": "light", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list", + "expected": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list" + }, + { + "stage": "before-fragment", + "width": 1440, + "scheme": "dark", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current" + }, + { + "stage": "before-back", + "width": 1440, + "scheme": "dark", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list" + }, + { + "stage": "after-back", + "width": 1440, + "scheme": "dark", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current", + "expected": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current" + }, + { + "stage": "after-forward", + "width": 1440, + "scheme": "dark", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list", + "expected": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list" + }, + { + "stage": "before-fragment", + "width": 390, + "scheme": "light", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current" + }, + { + "stage": "before-back", + "width": 390, + "scheme": "light", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list" + }, + { + "stage": "after-back", + "width": 390, + "scheme": "light", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current", + "expected": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current" + }, + { + "stage": "after-forward", + "width": 390, + "scheme": "light", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list", + "expected": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list" + }, + { + "stage": "before-fragment", + "width": 390, + "scheme": "dark", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current" + }, + { + "stage": "before-back", + "width": 390, + "scheme": "dark", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list" + }, + { + "stage": "after-back", + "width": 390, + "scheme": "dark", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current", + "expected": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current" + }, + { + "stage": "after-forward", + "width": 390, + "scheme": "dark", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list", + "expected": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list" + }, + { + "stage": "before-fragment", + "width": 320, + "scheme": "light", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current" + }, + { + "stage": "before-back", + "width": 320, + "scheme": "light", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list" + }, + { + "stage": "after-back", + "width": 320, + "scheme": "light", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current", + "expected": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=coefficients#library-current" + }, + { + "stage": "after-forward", + "width": 320, + "scheme": "light", + "client_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list", + "renderer_url": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list", + "expected": "http://127.0.0.1:36157/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list" + } + ], + "passed": 16, + "failed": 0 +} diff --git a/docs/reports/library-source-search-20261026/harness-diagnostic.json b/docs/reports/library-source-search-20261026/harness-diagnostic.json new file mode 100644 index 000000000..38e48e989 --- /dev/null +++ b/docs/reports/library-source-search-20261026/harness-diagnostic.json @@ -0,0 +1,24 @@ +{ + "cause": "Playwright frame URL cache lagged synchronous renderer replaceState; expected URL was captured too early in driver, not lost browser state.", + "observations": [ + { + "stage": "before-back", + "width": 390, + "scheme": "light", + "client_url": "http://127.0.0.1:36945/site/workspace.html?keep=literal%23note&source-q=coefficients#reading-list", + "renderer_url": "http://127.0.0.1:36945/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list" + }, + { + "stage": "before-back", + "width": 320, + "scheme": "light", + "client_url": "http://127.0.0.1:36945/site/workspace.html?keep=literal%23note&source-q=coefficients#reading-list", + "renderer_url": "http://127.0.0.1:36945/site/workspace.html?keep=literal%23note&source-q=zz-no-source-20261026#reading-list" + } + ], + "repair": "Capture expected location.href in renderer and wait for URL equality after native traversal. Product source unchanged.", + "original_candidates": [ + "candidate/report.json", + "history-diagnostic/report.json" + ] +} diff --git a/docs/reports/library-source-search-20261026/local-checks.json b/docs/reports/library-source-search-20261026/local-checks.json new file mode 100644 index 000000000..2845023e9 --- /dev/null +++ b/docs/reports/library-source-search-20261026/local-checks.json @@ -0,0 +1,90 @@ +{ + "command_groups": [ + { + "name": "01-release", + "command": "python3 -B tools/site_asset_release.py", + "returncode": 0 + }, + { + "name": "02-release-check", + "command": "python3 -B tools/site_asset_release.py --check", + "returncode": 0 + }, + { + "name": "03-public-shop-data", + "command": "python3 -B -m unittest discover -s tests -p test_public_shop_data.py", + "returncode": 0 + }, + { + "name": "04-site-asset-release-tests", + "command": "python3 -B -m unittest tests.test_site_asset_release", + "returncode": 0 + }, + { + "name": "05-node-frontend", + "command": "node --test tests/test_public_shop_frontend.mjs tests/test_explore_models.mjs tests/test_curvature_export.mjs tests/test_teaching_export.mjs tests/test_pin_export.mjs tests/test_palette_export.mjs tests/test_figure_png.mjs tests/test_reading_list_citation.mjs tests/test_reader_navigation.mjs tests/test_source_reference.mjs tests/test_measurement_model.mjs tests/test_dependency_viewer.mjs tests/test_museum_frontend.mjs tests/test_workspace_navigation.mjs", + "returncode": 0 + }, + { + "name": "06-reader-links", + "command": "python3 -B -S -m unittest discover -s tests -p test_reader_links.py -v", + "returncode": 0 + }, + { + "name": "07-museum-data", + "command": "python3 -B -m unittest discover -s tests -p test_museum_data.py", + "returncode": 0 + }, + { + "name": "08-museum-check", + "command": "python3 -B tools/museum_check.py", + "returncode": 0 + }, + { + "name": "09-museum-geometry", + "command": "node --test tests/test_museum_geometry.mjs", + "returncode": 0 + }, + { + "name": "10-identity-control", + "command": "python3 -B -E -S tests/test_public_shop_check_identity_control.py -v", + "returncode": 0 + }, + { + "name": "11-identity-control-optimized", + "command": "python3 -B -E -O -S tests/test_public_shop_check_identity_control.py -v", + "returncode": 0 + }, + { + "name": "12-public-shop-check", + "command": "python3 -B tools/public_shop_check.py", + "returncode": 0 + }, + { + "name": "13-library-source-search-node", + "command": "node --test tests/test_library_source_search.mjs", + "returncode": 0 + } + ], + "browser_regressions": [ + { + "name": "research_desk", + "passed": true, + "cases": 13, + "page_errors": [] + }, + { + "name": "research_desk_undo", + "passed": true, + "cases": 80, + "page_errors": [] + }, + { + "name": "reading_list_citation", + "passed": true, + "cases": 3, + "page_errors": [] + } + ], + "limits": "Separate technical execution, engineering only. Original logs retained in Drive delivery evidence. No mathematical status promoted." +} diff --git a/docs/reports/library-source-search-20261026/preimages.json b/docs/reports/library-source-search-20261026/preimages.json new file mode 100644 index 000000000..810b73ea6 --- /dev/null +++ b/docs/reports/library-source-search-20261026/preimages.json @@ -0,0 +1,24 @@ +{ + "base": "f8ea0b530fed1942aa23d79a8fce179a679862f8", + "custody_zip_sha256": "77cfae4ca0f71d9699a6606fa96d0d799d809774d403b3c673b2052685131fa3", + "preimages": [ + { + "path": "docs/site/research-desk.mjs", + "sha256": "df1400a5b07ec9577e543b62273533f3b9e12515395faff3d997dd49c23c0f5a", + "bytes": 15966, + "matches_independently_Drive_downloaded_a27_source": true + }, + { + "path": "docs/site/research-desk.css", + "sha256": "bc09620ffbaeebee99b5300bd606d122f1c9e9e106dc3260408d16b714668e65", + "bytes": 2759, + "matches_independently_Drive_downloaded_a27_source": true + }, + { + "path": "docs/site/README.md", + "sha256": "461e623b31116befab6621eb6d677c3c2d335374a51170806f0aab24e38d2adb", + "bytes": 42440, + "matches_independently_Drive_downloaded_a27_source": true + } + ] +} diff --git a/docs/site/README.md b/docs/site/README.md index ff80bbe58..43a860ae6 100644 --- a/docs/site/README.md +++ b/docs/site/README.md @@ -94,6 +94,21 @@ its visible caption travels with the image even when an app strips metadata. ## From a saved source to a reference +The Library's verified current-source search offers **Clear search**, a native +**Link to this search**, and **Save current search** together. A zero-match query +shows recovery guidance. Clearing resets the existing result window and returns +keyboard focus to the input. The link preserves literal query text and unrelated +page parameters; it runs against the admitted observation available when opened, +so its results are not frozen. The dated catalog remains a separate collection. +These tools appear only after the current snapshot verifies and add no source +acquisition, mathematical review or storage schema. + +Focused checks: `node --test tests/test_library_source_search.mjs` and +`python3 -B tools/library_source_search_browser_check.py --output +browser-evidence/library-source-search` (optional installed Playwright/Chromium; +use `--browser PATH` if needed). The browser driver blocks external HTTPS requests +and tests the included current snapshot; no online source custody is inferred. + Each saved source in the Library reading list has **Make a source reference**. It opens the existing Cite builder with its repository, full commit, literal path and actual SHA-256 when present. A Git blob is not substituted for a file hash. diff --git a/docs/site/library-source-search.mjs b/docs/site/library-source-search.mjs new file mode 100644 index 000000000..2ec9786da --- /dev/null +++ b/docs/site/library-source-search.mjs @@ -0,0 +1,51 @@ +// Library presentation only. Filtering and admission remain in current.mjs. +export function librarySearchHref(href,query) { + const url=new URL(href); + if(query)url.searchParams.set('source-q',query);else url.searchParams.delete('source-q'); + url.hash='library-current'; + return url.href; +} + +export function startLibrarySourceSearch(doc,win) { + if(!doc.getElementById('research-desk')||doc.getElementById('library-source-tools'))return null; + const input=doc.querySelector('#current-research .current-search'); + if(!input||input.disabled)return null; + const list=doc.querySelector('#current-research .current-results'),label=input.closest('label'); + if(!list||!label)return null; + const make=(tag,id,text)=>{ + const node=doc.createElement(tag);node.id=id;if(text)node.textContent=text;return node; + }; + const tools=make('div','library-source-tools');tools.className='library-source-tools'; + const clear=make('button','library-source-clear','Clear search');clear.type='button'; + const link=make('a','library-source-link','Link to this search');link.className='button secondary'; + tools.append(clear,link); + // Reuse the existing save action and its identity; it is still disabled + // until the verified snapshot's caller finishes initialization. + const save=doc.getElementById('desk-save-current');if(save)tools.append(save); + const note=make('p','library-source-query-note','This query reopens against the admitted source observation available then; results are not frozen.'); + const empty=make('p','library-source-empty');empty.setAttribute('role','status');empty.hidden=true; + label.after(tools,note,empty); + const described=new Set((input.getAttribute('aria-describedby')||'').split(/\s+/).filter(Boolean)); + described.add(note.id);input.setAttribute('aria-describedby',[...described].join(' ')); + function update() { + clear.disabled=input.value.length===0; + link.href=librarySearchHref(win.location.href,input.value); + const missing=list.children.length===0; + empty.hidden=!missing; + const text=missing?'No source paths match this search. Try a shorter path or use Clear search. The dated catalog is a separate collection.':''; + if(empty.textContent!==text)empty.textContent=text; + } + clear.addEventListener('click',()=>{ + input.value=''; + input.dispatchEvent(new win.Event('input',{bubbles:true})); + input.focus({preventScroll:true}); + }); + input.addEventListener('input',update); + win.addEventListener('popstate',update); + // Fragment navigation can preserve other query state; keep the native link + // aligned without changing the URL, history, results or keyboard focus. + win.addEventListener('hashchange',update); + const observer=new win.MutationObserver(update);observer.observe(list,{childList:true}); + update(); + return {update}; +} diff --git a/docs/site/research-desk.css b/docs/site/research-desk.css index 78fedbb9e..87ae3c5ab 100644 --- a/docs/site/research-desk.css +++ b/docs/site/research-desk.css @@ -32,5 +32,11 @@ .desk-remove {align-self:start} .desk-save-source {display:block;margin-top:10px;padding:6px 12px} #desk-save-current {margin:8px 0 12px} +.library-source-tools {display:flex;flex-wrap:wrap;align-items:center;gap:10px;margin:12px 0} +.library-source-tools > :is(button,a) {min-height:44px;display:inline-flex;align-items:center;font-size:14px;margin:0} +#library-source-query-note,#library-source-empty {font-size:14px;max-width:78ch} +#library-source-empty {border-inline-start:3px solid var(--ul-border);padding:10px 14px} +#library-source-empty[hidden] {display:none} @media(max-width:420px){#reading-list{padding:0 12px}#desk-count{display:block;margin:0}#desk-entries > li{grid-template-columns:minmax(0,1fr);gap:10px}.desk-remove{justify-self:start}.desk-tools{align-items:stretch}.desk-tools > *{max-width:100%}} @media print{.desk-tools,.desk-save-source,#desk-save-current,#desk-save-catalog,.desk-remove,#desk-status{display:none!important}#reading-list{background:white;border-color:#aaa}#desk-entries>li{display:block}} +@media print{.library-source-tools{display:none}} diff --git a/docs/site/research-desk.mjs b/docs/site/research-desk.mjs index e29e43041..a2abc3517 100644 --- a/docs/site/research-desk.mjs +++ b/docs/site/research-desk.mjs @@ -2,6 +2,7 @@ import {currentSnapshot} from './current.mjs?site-release=fc7e8a98c1e23f476962c4c83e95ed3ce817490007987112d9b2cf6d3d90b142'; import {SCHEMA,MAX_FILE_BYTES,validateEntry,entryKey,parseReadingList,mergeEntries,sourceHref,searchHref,readingListJSON} from './research-desk-store.mjs?site-release=547418ff3547b671266d1e46bf8d33f1f3eedf83571f6a0bb69ca9d7786ffaf3'; import {readingListCitationHref} from './reading-list-citation.mjs?site-release=02153e8e3acb70abca98685f5b274c0472eea6450ed2e9c3fc3125a7b0196968'; +import {startLibrarySourceSearch} from './library-source-search.mjs?site-release=0f7fa4196362a427e070fc49f58f8a2935840e9d797358cb9d325e5db44ee612'; export function sourceLinkKey(href) { try{ @@ -214,6 +215,7 @@ export function startResearchDesk(doc=document,win=window,snapshot=currentSnapsh attachCatalog(); snapshot.then(data=>{ if(!data)return; + startLibrarySourceSearch(doc,win); currentData=data; for(const source of data.sources){ try{const entry=validateEntry({kind:'source',collection:'current',repository:source.repository,commit:source.commit,path:source.path,blob:source.blob,bytes:source.bytes,observedAt:data.observed_at,savedAt:now()});currentSources.set(sourceLinkKey(sourceHref(entry)),entry);}catch{} diff --git a/docs/site/workspace.html b/docs/site/workspace.html index 4605691cb..1abf16c78 100644 --- a/docs/site/workspace.html +++ b/docs/site/workspace.html @@ -13,8 +13,8 @@ - - + + diff --git a/docs/superpowers/plans/2026-10-26-library-source-search.md b/docs/superpowers/plans/2026-10-26-library-source-search.md new file mode 100644 index 000000000..eac70f2e7 --- /dev/null +++ b/docs/superpowers/plans/2026-10-26-library-source-search.md @@ -0,0 +1,45 @@ +# Library source search implementation plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox syntax for tracking. + +**Goal:** Recover from an empty current-source search and reopen/share its query. +**Architecture:** Library-only progressive enhancement delegates to the existing +verified search. Existing reader storage and canonical data stay untouched. +**Tech Stack:** Native browser DOM/CSS/modules, Python Playwright, Node test runner. +**Spec:** `docs/superpowers/specs/2026-10-26-library-source-search.md`. + +## Global constraints + +No dependency, network, storage schema, scientific record, current.mjs, importer, +Atlas or workflow change. Preserve current vs dated source-cut semantics and all +existing safety refusals. Use the existing brand and release-key tooling. + +## Review focus + +- A literal query with Unicode, &, # or percent text must round-trip as text. +- Clearing after pagination removes only source-q and resets the existing window. +- A refused snapshot must expose no enabled enhancement controls. +- Back and storage/background updates must not move unrelated keyboard focus. +- Link wording must not promise frozen results or authenticated source custody. + +### Task 1: Progressive search tools and regression + +**Files:** new `docs/site/library-source-search.mjs`, small import/attach in +`research-desk.mjs`, scoped `research-desk.css`, README paragraph; +`tools/library_source_search_browser_check.py` and +`tests/test_library_source_search.mjs`. + +**Interfaces:** `startLibrarySourceSearch(doc,win)` attaches once to the verified +enabled Library input/list, returns null without those prerequisites. Delegate +all actual filtering/history writes to current.mjs by dispatching input. + +- [x] Write a real browser regression for absent controls/recovery. Run against + the original immutable base; retain expected failing report. +- [x] Implement the helper and integration; native query link updates from input, + popstate and observed list replacement. Use textContent for copy, no query HTML. +- [x] Run the focused browser matrix and Node URL/initialization checks. +- [x] Run the prescribed site suite and prior desk/Undo/Cite browser regressions; + run asset re-key and check, stage all derived assets. +- [ ] Record exact input/output evidence and limitations; commit cleanly, obtain + separate whole-branch engineering review and current protected integration. +- [ ] Verify actual publication and an additive offline/source delivery in Drive. diff --git a/docs/superpowers/specs/2026-10-26-library-source-search.md b/docs/superpowers/specs/2026-10-26-library-source-search.md new file mode 100644 index 000000000..3ecd93422 --- /dev/null +++ b/docs/superpowers/specs/2026-10-26-library-source-search.md @@ -0,0 +1,28 @@ +# Library current-source search recovery + +The owner delegates implementation choices and asks us to continue the finished +reader experience without repeated design questions. This is a small Library-only +increment on Main `f8ea0b530fed1942aa23d79a8fce179a679862f8`. + +Current search replaces its list with nothing when no source path matches. Unlike +the dated catalog, it offers neither a recovery hint nor nearby Clear/Link actions. +Add a short no-match message, Clear search, and a native Link to this search. +Keep Save current search in the same compact tool row. Controls appear only after +the existing current snapshot verifies. Clearing dispatches the existing input +event, resets existing pagination, removes only source-q and focuses the input. +The native link preserves unrelated URL parameters, encodes literal query text, +and targets workspace.html#library-current. Explain beside it: the query reopens +against the admitted observation available then; results are not frozen. + +Use one small Library helper imported by research-desk.mjs. Leave current.mjs and +the source importer, their admission rules and other pages unchanged. A patch to +current.mjs would overlap the separate source transition work; a second search +engine would duplicate existing filtering. The helper delegates filtering to the +existing input event and observes the list only to maintain the recovery message. +No new storage, network request, dependency, theorem status or source association. + +Check literal Unicode/special-character queries, native Back/reload/link opening, +unrelated URL state, show-more then reset, unavailable admission, repeated same-page +fragment navigation, 320px/390px/mobile and desktop light/dark keyboard interaction. +Verify existing saved notes, Undo, source-to-Cite and source refusal remain intact. +Browser and engineering checks do not establish spoken AT or scientific acceptance. diff --git a/tests/test_library_source_search.mjs b/tests/test_library_source_search.mjs new file mode 100644 index 000000000..ca568ff79 --- /dev/null +++ b/tests/test_library_source_search.mjs @@ -0,0 +1,26 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import {librarySearchHref,startLibrarySourceSearch} from '../docs/site/library-source-search.mjs'; + +test('search links preserve literal text and unrelated page state',()=>{ + const base='https://example.test/main/site/workspace.html?keep=literal%23note&source-q=old#reading-list'; + for(const query of ['Δ + a&b#c?d%20','',' coefficients ']){ + const url=new URL(librarySearchHref(base,query)); + assert.equal(url.origin,'https://example.test'); + assert.equal(url.pathname,'/main/site/workspace.html'); + assert.equal(url.searchParams.get('keep'),'literal#note'); + assert.equal(url.searchParams.get('source-q'),query); + assert.equal(url.hash,'#library-current'); + } +}); +test('empty queries remove only the current-source parameter',()=>{ + const url=new URL(librarySearchHref('http://localhost/site/workspace.html?source-q=old&catalog-q=other&keep=1','')); + assert.equal(url.searchParams.has('source-q'),false); + assert.equal(url.searchParams.get('catalog-q'),'other'); + assert.equal(url.searchParams.get('keep'),'1'); +}); +test('no initialization on another page or before snapshot admission',()=>{ + assert.equal(startLibrarySourceSearch({getElementById:()=>null},{}),null); + const doc={getElementById:id=>id==='research-desk'?{}:null,querySelector:()=>({disabled:true})}; + assert.equal(startLibrarySourceSearch(doc,{}),null); +}); diff --git a/tools/library_source_search_browser_check.py b/tools/library_source_search_browser_check.py new file mode 100644 index 000000000..b28742869 --- /dev/null +++ b/tools/library_source_search_browser_check.py @@ -0,0 +1,141 @@ +#!/usr/bin/env python3 +"""Exercise Library search recovery against real admitted local source bytes.""" +from __future__ import annotations +import argparse +from datetime import datetime, timezone +import json +from pathlib import Path +import shutil +import traceback +from urllib.parse import urlsplit, parse_qs +from research_desk_browser_check import ROOT, serve + + +def run(origin, browser, output, report, baseline=False): + from playwright.sync_api import expect + def case(name, operation): + row = {'case': name}; report['cases'].append(row) + try: + operation(); row['passed'] = True + except Exception: + row['passed'] = False; row['error'] = traceback.format_exc() + + for width, scheme in [(1440, 'light'), (1440, 'dark'), (390, 'light'), (390, 'dark'), (320, 'light')]: + context = browser.new_context(viewport={'width': width, 'height': 960}, + color_scheme=scheme, reduced_motion='reduce') + context.route('https://**', lambda route: route.abort()) + page = context.new_page(); page.set_default_timeout(5000) + page.on('pageerror', lambda error: report['page_errors'].append(str(error))) + def open_page(query=''): + page.goto(origin+'workspace.html?keep=literal%23note&source-q='+query+'#library-current') + expect(page.locator('.current-search')).to_be_enabled() + def empty(): + open_page('zz-no-source-20261026') + expect(page.locator('.current-results > li')).to_have_count(0) + expect(page.locator('#library-source-empty')).to_be_visible() + expect(page.locator('#library-source-empty')).to_contain_text('Try a shorter path') + expect(page.locator('#library-source-clear')).to_be_enabled() + expect(page.locator('#library-source-link')).to_be_visible() + assert 'results are not frozen' in page.locator('#library-source-query-note').inner_text() + assert page.locator('#library-source-empty').get_attribute('role') == 'status' + page.locator('#library-source-clear').focus(); page.keyboard.press('Enter') + expect(page.locator('.current-search')).to_have_value('') + expect(page.locator('.current-search')).to_be_focused() + expect(page.locator('.current-results > li')).to_have_count(50) + expect(page.locator('#library-source-empty')).to_be_hidden() + expect(page.locator('#library-source-clear')).to_be_disabled() + parsed = parse_qs(urlsplit(page.url).query) + assert 'source-q' not in parsed and parsed['keep'] == ['literal#note'] + assert page.evaluate('document.documentElement.scrollWidth <= innerWidth') + page.locator('#library-source-tools').screenshot(path=str(output/f'tools-{width}-{scheme}.png')) + case(f'empty-recovery-keyboard-{width}-{scheme}', empty) + if not baseline: + def literal(): + open_page() + for query in ['Δ + a&b#c?d%20', 'proof', '', ' coefficients ']: + page.locator('.current-search').fill(query) + href = page.locator('#library-source-link').get_attribute('href') + parsed = urlsplit(href) + assert parse_qs(parsed.query)['source-q'] == [query] + assert parse_qs(parsed.query)['keep'] == ['literal#note'] + assert parsed.fragment == 'library-current' + assert not page.locator('#library-source-tools img').count() + fresh = context.new_page(); fresh.goto(href) + expect(fresh.locator('.current-search')).to_be_enabled() + expect(fresh.locator('.current-search')).to_have_value(query) + fresh.close() + page.reload(); expect(page.locator('.current-search')).to_have_value(' coefficients ') + expect(page.locator('#library-source-link')).to_have_attribute('href', page.url) + case(f'literal-query-native-link-reload-{width}-{scheme}', literal) + def page_window(): + open_page('proof') + expect(page.locator('.current-results > li')).to_have_count(50) + page.locator('.current-more').click() + expect(page.locator('.current-results > li')).to_have_count(100) + page.locator('#library-source-clear').click() + expect(page.locator('.current-results > li')).to_have_count(50) + # Native fragment history carries the existing query snapshots. + page.locator('.current-search').fill('coefficients') + # replaceState is synchronous in the renderer; the automation + # client's cached frame URL may arrive on the next protocol turn. + first = page.evaluate('location.href') + report.setdefault('history_observations',[]).append({'stage':'before-fragment','width':width,'scheme':scheme,'client_url':first,'renderer_url':page.evaluate('location.href')}) + page.evaluate("location.hash='reading-list'") + page.locator('.current-search').fill('zz-no-source-20261026') + second = page.evaluate('location.href') + report['history_observations'].append({'stage':'before-back','width':width,'scheme':scheme,'client_url':second,'renderer_url':page.evaluate('location.href')}) + page.go_back(); expect(page.locator('.current-search')).to_have_value('coefficients') + report['history_observations'].append({'stage':'after-back','width':width,'scheme':scheme,'client_url':page.url,'renderer_url':page.evaluate('location.href'),'expected':first}) + expect(page).to_have_url(first) + expect(page.locator('#library-source-link')).to_have_attribute('href', first) + page.go_forward(); expect(page.locator('.current-search')).to_have_value('zz-no-source-20261026') + report['history_observations'].append({'stage':'after-forward','width':width,'scheme':scheme,'client_url':page.url,'renderer_url':page.evaluate('location.href'),'expected':second}) + expect(page).to_have_url(second) + expect(page.locator('#library-source-empty')).to_be_visible() + # A background result replacement must not steal newer focus. + page.locator('#reading-list > summary').focus() + page.evaluate("document.querySelector('.current-results').append(document.createElement('li'))") + expect(page.locator('#reading-list > summary')).to_be_focused() + case(f'pagination-history-focus-{width}-{scheme}', page_window) + context.close() + if not baseline: + def unavailable(): + context = browser.new_context(viewport={'width':390,'height':844}) + context.route('https://**', lambda route: route.abort()) + context.route('**/current.json', lambda route: route.fulfill(status=503, body='Unavailable')) + page = context.new_page(); page.on('pageerror', lambda error: report['page_errors'].append(str(error))) + page.goto(origin+'workspace.html#library-current') + expect(page.locator('.current-state')).to_contain_text('Unavailable') + expect(page.locator('.current-search')).to_be_disabled() + assert page.locator('#library-source-tools').count() == 0 + expect(page.locator('#desk-save-current')).to_be_disabled() + context.close() + case('unavailable-snapshot-no-enabled-tools', unavailable) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--browser', default=shutil.which('chromium') or shutil.which('google-chrome')) + parser.add_argument('--output', type=Path, required=True) + parser.add_argument('--origin') + parser.add_argument('--baseline', action='store_true') + args = parser.parse_args(); args.output.mkdir(parents=True, exist_ok=True) + report = {'observed_at':datetime.now(timezone.utc).isoformat(), 'cases':[], 'page_errors':[], + 'scope':'Engineering only; no source acquisition, mathematical review or spoken AT claim.'} + from playwright.sync_api import sync_playwright + def execute(origin): + with sync_playwright() as pw: + browser = pw.chromium.launch(executable_path=args.browser, chromium_sandbox=True) + report['browser'] = browser.version + run(origin, browser, args.output, report, args.baseline); browser.close() + if args.origin: execute(args.origin) + else: + with serve() as origin: execute(origin) + report['passed'] = sum(row['passed'] for row in report['cases']) + report['failed'] = len(report['cases'])-report['passed'] + (args.output/'report.json').write_text(json.dumps(report, indent=2)+'\n') + print(json.dumps({key:report[key] for key in ['browser','passed','failed','page_errors']})) + return 1 if report['failed'] or report['page_errors'] else 0 + + +if __name__ == '__main__': raise SystemExit(main())