Skip to content

OpenConceptLab/ocl_online#46 | staff turn OCL Semantic Search on or off for a source version - #99

Open
paynejd wants to merge 2 commits into
mainfrom
ocl_online#46-semantic-search
Open

paynejd wants to merge 2 commits into
mainfrom
ocl_online#46-semantic-search

Conversation

@paynejd

@paynejd paynejd commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

closes OpenConceptLab/ocl_online#46

Staff can turn OCL Semantic Search on or off for a source version from TBv3, instead of the CLI's ocl repo version-update --match-algorithms es,llm. TBv3 uses the API as it is: the change needs no oclapi2 work, and the API already allows these changes for staff only.

Version menu (staff only)

  • Turn On / Turn Off OCL Semantic Search, on every source version but HEAD, disabled while the version is processing. A confirm dialog names the version and its concept count and says what happens. Confirming sends PUT <version>/ with the version's match algorithms, adding or removing llm and keeping the rest; the API then queues the vector sync. The version's Mapper chip updates without a reload, and an API error shows its message.
  • Sync Vectors, on a semantic version. It reuses the reindex dialog to send POST <version>/concepts/indexes/ with sync_vectors, which reruns the vector sync without changing the setting, and shows the task id.

New source version form (staff only): an OCL Semantic Search checkbox that starts as HEAD's setting, which is the API's default. Unchanged for everyone else: the form sends no match_algorithms.

Re-index and Sync Vectors can run again once their task finishes (from the review, F1.1). Until now, a queued re-index kept its menu item disabled until the page was reloaded. useQueuedTasks remembers each queued task, and opening a version's or an expansion's menu asks GET /tasks/<id>/ and forgets the tasks that have finished. Both versions tabs use it.

Not in scope: HEAD's own setting (it stays in the API and the CLI), and access for users who aren't staff (OpenConceptLab/ocl_online#587).

Documentation needed, once this is deployed

  • OCL Docs (OpenConceptLab/ocl-docs), docs/source/oclmap/matching-algorithms.md, the OCL Semantic paragraph that says "Only staff accounts can change that setting": say where staff change it. That's the version's menu on the repository's Versions tab in the TermBrowser, or the OCL Semantic Search checkbox when creating a source version.
  • TBv3 knowledge base (OpenConceptLab/ocl-kb), tbv3/tbv3-knowledge-base.md, authoring section, next to "Release (or un-release) a version": add the staff version actions Turn On/Off OCL Semantic Search and Sync Vectors, the create-form checkbox, and that Re-index and Sync Vectors become available again once their task finishes.
  • Staff vectorization runbook (OpenConceptLab/ocl-online-docs), infrastructure/vectorization.md, "Opting in or out": add the TBv3 route beside the CLI and API ones for creation, later changes and the staff re-run.

Checked

  • npm test (136 pass; new: semanticSearch.test.js, taskState.test.js) and CI's ESLint command.
  • Headless Chrome against the staging API, on a 9-concept test source (users/jontest4/sources/default-view-test, v1), 21 checks:
    • Its owner, who isn't staff, sees none of the new items and no checkbox.
    • A staff user turned it on (["es","llm"], 200), saw the Mapper chip appear, ran Sync Vectors (202, task id shown, the item then disabled), turned it off (["es"], 200) and saw the chip go. HEAD's menu has no toggle.
    • The create form's request was intercepted: with the box ticked it sends ["es","llm"] and no semantic field. No version was created, and v1 is back to ["es"].
    • After the F1.1 fix: Sync Vectors was disabled right after queueing and enabled again once its task reported SUCCESS. The 21 checks still pass.
  • Reviews (comments below): Codex pass 1 found F1.1 (P1) and F1.2 (P2), both fixed; pass 2 clean. Simplification review: 3 optional cuts, none applied.
  • English strings only; other locales fall back to English.

🤖 Generated with Claude Code

paynejd and others added 2 commits November 10, 2026 13:31
…ff for a source version

- Version menu (staff, not HEAD): Turn On / Turn Off OCL Semantic Search, with a
  confirm dialog that names the version and its concept count. It updates the
  version's match algorithms (adds or removes llm, keeps the rest); the API
  queues the vector sync.
- Version menu (staff, semantic versions): Sync Vectors, the reindex dialog
  posting sync_vectors, which reruns the sync without changing the setting.
- New source version form (staff): an OCL Semantic Search checkbox that starts
  as HEAD's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… once its task finishes; a semantic-only setting stays so

Codex pass 1 on #99:
- F1.1: a queued reindex or vector sync kept its menu item disabled until the
  page reloaded. useQueuedTasks remembers each queued task, and opening a
  version's (or an expansion's) menu asks the API about it and forgets it once
  it has finished. Both versions tabs use it.
- F1.2: withSemanticSearch(['llm'], true) added es. Only an empty list, or
  turning off the only algorithm, falls back to es now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@paynejd

paynejd commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 1 (codex-cli 0.167.0, commit 0ab6342)

Verdict: findings (2 findings)

  • F1.1 P1 src/components/repos/SourceVersionsTab.jsx:293: Sync Vectors stays disabled after its task finishes or fails.
  • F1.2 P2 src/components/repos/semanticSearch.js:11: Creating a version from semantic-only HEAD silently enables token matching.

Response (fixed in f935cf7):

  • F1.1 (P1) fixed, with the same issue in the existing Re-index items on both versions tabs: useQueuedTasks remembers each queued task, and opening the menu checks it with GET /tasks/<id>/ and forgets it once it has finished. Checked on staging: Sync Vectors was disabled right after queueing and enabled again once the task reported SUCCESS.
  • F1.2 (P2) fixed: withSemanticSearch(['llm'], true) now returns ['llm']. Only an empty list, or turning off the only algorithm, falls back to es. New test cases cover both.
findings.json
{
  "reviewer": "codex-cli 0.167.0",
  "perspective": "defects",
  "mode": "full",
  "commit": "0ab63425e5cd40eb004201ea5cc5d329a69f3f10",
  "verdict": "findings",
  "prior": [],
  "findings": [
    {
      "id": "F1.1",
      "severity": "P1",
      "tag": null,
      "file": "src/components/repos/SourceVersionsTab.jsx",
      "line": 293,
      "claim": "Sync Vectors stays disabled after its task finishes or fails.",
      "scenario": "Staff queue a sync and close the result dialog. Its task ID is stored in reindexWip, but nothing clears that entry. Even after processing ends, the menu remains disabled and reports the task as running, preventing a retry after failure until the component is remounted.",
      "action": "Clear the cached entry when the task completes or fails, or stop treating a cached task ID as permanent evidence of running work.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.2",
      "severity": "P2",
      "tag": null,
      "file": "src/components/repos/semanticSearch.js",
      "line": 11,
      "claim": "Creating a version from semantic-only HEAD silently enables token matching.",
      "scenario": "HEAD has the valid setting [\"llm\"]. Staff create a version with the default semantic checkbox unchanged. withSemanticSearch([\"llm\"], true) returns [\"es\", \"llm\"], whereas creation previously inherited [\"llm\"]. The fallback adds an algorithm even though the final list would not be empty.",
      "action": "Preserve [\"llm\"] when semantic search remains enabled; apply the es fallback only for missing settings or an otherwise empty final list. Add this case to the helper tests.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

@paynejd

paynejd commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 2 (codex-cli 0.167.0, commit f935cf7)

Verdict: clean. F1.1 resolved, F1.2 resolved; no new findings.

findings.json
{
  "reviewer": "codex-cli 0.167.0",
  "perspective": "defects",
  "mode": "verify",
  "commit": "f935cf7d6d808b2fe3970244397799a294ac0fcc",
  "verdict": "clean",
  "prior": [
    {
      "id": "F1.1",
      "status": "resolved"
    },
    {
      "id": "F1.2",
      "status": "resolved"
    }
  ],
  "findings": []
}

@paynejd

paynejd commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

Simplification review (claude subagent, commit f935cf7)

Verdict: 3 optional cuts; none applied, so no commits follow the last Codex pass and no extra check is needed.

  • S1 shrink src/components/repos/SemanticSearchDialog.jsx:10: lodash isNumber is imported for one check on the concept count. A plain typeof does the same and drops a dependency import from a new file. Reply: declined: RepoContentSummary.jsx checks the same summary counts with lodash isNumber, so this matches the code around it.
  • S2 shrink src/components/repos/SourceVersionsTab.jsx:488: The reindex menu entries carry both key and contentType, which are identical for concepts and mappings. syncVectors already implies the vectors entry, so key and label can be derived. The entries also pass label through reindexTarget just to rebuild a string the dialog could pick itself from syncVectors/contentType. Reply: declined: explicit keys are clearer, and passing the label replaced a ternary that would otherwise need a third branch for Sync Vectors.
  • S3 yagni src/components/repos/SemanticSearchDialog.jsx:16: The new dialog copies ReindexVersionDialog's whole submit/result/close structure (submitting and result state, response status parsing, success and error Alert, Close button). A shared confirm-and-submit dialog could serve both. Judged only a possible later cleanup, since the two differ in verb and payload. Reply: no change in this PR, as suggested; recorded as a possible later cleanup.

No adversarial pass: the PR changes no permission. The API's existing staff checks still decide, and the UI only hides what they would refuse.

findings.json
{
  "reviewer": "claude subagent",
  "perspective": "simplify",
  "mode": "full",
  "commit": "f935cf7d6d808b2fe3970244397799a294ac0fcc",
  "verdict": "findings",
  "prior": [],
  "findings": [
    {
      "id": "S1",
      "severity": null,
      "tag": "shrink",
      "file": "src/components/repos/SemanticSearchDialog.jsx",
      "line": 10,
      "claim": "lodash isNumber is imported for one check on the concept count. A plain typeof does the same and drops a dependency import from a new file.",
      "scenario": null,
      "action": "Replace `isNumber(conceptCount)` with `typeof conceptCount === 'number'` and remove the lodash import.",
      "lines_delta": -1,
      "confidence": "medium"
    },
    {
      "id": "S2",
      "severity": null,
      "tag": "shrink",
      "file": "src/components/repos/SourceVersionsTab.jsx",
      "line": 488,
      "claim": "The reindex menu entries carry both `key` and `contentType`, which are identical for concepts and mappings. `syncVectors` already implies the vectors entry, so key and label can be derived. The entries also pass `label` through reindexTarget just to rebuild a string the dialog could pick itself from `syncVectors`/`contentType`.",
      "scenario": null,
      "action": "Drop `key` from the first two entries and use `key = syncVectors ? 'vectors' : contentType`. Stop passing `label` through reindexTarget and have the dialog derive it, as it did before.",
      "lines_delta": -3,
      "confidence": "low"
    },
    {
      "id": "S3",
      "severity": null,
      "tag": "yagni",
      "file": "src/components/repos/SemanticSearchDialog.jsx",
      "line": 16,
      "claim": "The new dialog copies ReindexVersionDialog's whole submit/result/close structure (submitting and result state, response status parsing, success and error Alert, Close button). A shared confirm-and-submit dialog could serve both. Judged only a possible later cleanup, since the two differ in verb and payload.",
      "scenario": null,
      "action": "Optional: extract a shared confirm/result dialog shell. No change needed for this PR.",
      "lines_delta": -30,
      "confidence": "low"
    }
  ]
}

@paynejd
paynejd marked this pull request as ready for review November 10, 2026 18:41
@paynejd
paynejd requested a review from snyaggarwal November 10, 2026 19:04

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants