Skip to content

fix: add dry-run discoverability safe repair - #3048

Merged
1 commit merged into
nesquena:masterfrom
ai-ag2026:fix/discoverability-safe-repair
May 28, 2026
Merged

1 commit merged into
nesquena:masterfrom
ai-ag2026:fix/discoverability-safe-repair

Conversation

@ai-ag2026

Copy link
Copy Markdown
Contributor

Thinking Path

The discoverability audit is intentionally read-only, but its findings identified two deterministic cleanup classes: stale persisted WebUI-as-CLI flags and WebUI-origin state.db rows with messages but no sidecar/index entry. Operators need a safe routine that plans those repairs by default and only mutates state with an explicit backup directory.

What Changed

  • Adds repair_session_discoverability() with default dry-run behavior.
  • Plans deterministic repairs from the existing audit findings.
  • Requires backup_dir for apply mode.
  • Clears stale is_cli_session=true from WebUI sidecars and _index.json entries.
  • Materializes messageful WebUI state.db rows into sidecars and index metadata using the existing state-db sidecar conversion path.
  • Adds python -m api.session_discoverability --repair-safe as a dry-run CLI; --apply --backup-dir <dir> is required for mutation.
  • Adds regression coverage for dry-run no-mutation, backup-required apply, backup-backed apply, and CLI dry-run behavior.
  • Updates the changelog.

Why It Matters

This turns the audit's actionable but operator-heavy follow-up into a controlled routine. It still defaults to no mutation, so users can inspect the plan before touching session files or state.db-derived recovery state.

Contract Routing

Task type: runtime/session metadata repair tooling.
Touched areas: api.session_discoverability, session sidecars, _index.json, state-db-derived sidecar materialization.
Relevant public docs:

  • AGENTS.md
  • CONTRIBUTING.md
  • docs/CONTRACTS.md
  • docs/rfcs/webui-run-state-consistency-contract.md
    Scope boundaries: no live repair route, no automatic startup repair, no deletion/archive of unsafe rows, no service restart.
    Evidence needed before claiming done: regression tests for dry-run/apply gates plus adjacent recovery/discoverability tests.

Verification

  • python3 -m pytest tests/test_session_discoverability_repair.py -q
  • python3 -m pytest tests/test_session_discoverability_repair.py tests/test_session_discoverability_audit.py tests/test_session_recovery_api.py -q
  • python3 -m pytest tests/test_session_discoverability_repair.py tests/test_session_discoverability_audit.py tests/test_session_recovery_api.py tests/test_session_db_sidecar_reconciliation.py -q
  • python3 -m py_compile api/session_discoverability.py api/session_recovery.py
  • Added-line public marker scan: 0 hits

Risks / Follow-ups

  • The routine can mutate session sidecars/index files only in --apply mode and only with backups.
  • state_db_messageful_missing_sidecar materialization is intentionally limited to WebUI-origin rows with messages; empty/orphan rows remain manual-review territory.
  • Live use should still be operator-triggered after inspecting dry-run output and choosing a backup directory.

Model Used

AI-assisted by OpenAI Codex GPT-5.5 via Hermes/TARS, using local tests and git/GitHub CLI tooling.

@nesquena-hermes nesquena-hermes closed this pull request by merging all changes into nesquena:master in 6267716 May 28, 2026
@nesquena-hermes

Copy link
Copy Markdown
Collaborator

Shipped in v0.51.154 / Release DZ (stage-batch36, commit 6267716). Thanks for the contribution!

ai-ag2026 pushed a commit to ai-ag2026/hermes-webui that referenced this pull request May 28, 2026
# Conflicts:
#	CHANGELOG.md
ai-ag2026 pushed a commit to ai-ag2026/hermes-webui that referenced this pull request May 28, 2026
9-PR medium-risk cleanup:
- nesquena#3037 routes.py: argv-style prefill hook + env-var override for notes drawer
- nesquena#3046 models.py: compression parent not repaired as stale interrupted turn
- nesquena#3048 session_discoverability.py: --repair-safe CLI with default dry-run
- nesquena#3053 ui.js: streaming KaTeX guard for parser-owned equations
- nesquena#3059 models.py: empty partial activity rows excluded from sidebar recency
- nesquena#3060 profiles.py: API key writes to .env (chmod 600), not config.yaml
- nesquena#3064 routes.py: MEDIA: image tokens allow exact session-referenced paths
- nesquena#3069 models.py: cron sessions with project_id surface via Cron Jobs chip
- nesquena#3077 gateway_chat.py: HTTP 401 maps to gateway_auth_error event
SysAdminDoc pushed a commit to SysAdminDoc/hermes-webui that referenced this pull request Jun 26, 2026
# Conflicts:
#	CHANGELOG.md
SysAdminDoc pushed a commit to SysAdminDoc/hermes-webui that referenced this pull request Jun 26, 2026
9-PR medium-risk cleanup:
- nesquena#3037 routes.py: argv-style prefill hook + env-var override for notes drawer
- nesquena#3046 models.py: compression parent not repaired as stale interrupted turn
- nesquena#3048 session_discoverability.py: --repair-safe CLI with default dry-run
- nesquena#3053 ui.js: streaming KaTeX guard for parser-owned equations
- nesquena#3059 models.py: empty partial activity rows excluded from sidebar recency
- nesquena#3060 profiles.py: API key writes to .env (chmod 600), not config.yaml
- nesquena#3064 routes.py: MEDIA: image tokens allow exact session-referenced paths
- nesquena#3069 models.py: cron sessions with project_id surface via Cron Jobs chip
- nesquena#3077 gateway_chat.py: HTTP 401 maps to gateway_auth_error event
bernyforce pushed a commit to bernyforce/hermes-webui that referenced this pull request Jul 29, 2026
# Conflicts:
#	CHANGELOG.md
bernyforce pushed a commit to bernyforce/hermes-webui that referenced this pull request Jul 29, 2026
9-PR medium-risk cleanup:
- nesquena#3037 routes.py: argv-style prefill hook + env-var override for notes drawer
- nesquena#3046 models.py: compression parent not repaired as stale interrupted turn
- nesquena#3048 session_discoverability.py: --repair-safe CLI with default dry-run
- nesquena#3053 ui.js: streaming KaTeX guard for parser-owned equations
- nesquena#3059 models.py: empty partial activity rows excluded from sidebar recency
- nesquena#3060 profiles.py: API key writes to .env (chmod 600), not config.yaml
- nesquena#3064 routes.py: MEDIA: image tokens allow exact session-referenced paths
- nesquena#3069 models.py: cron sessions with project_id surface via Cron Jobs chip
- nesquena#3077 gateway_chat.py: HTTP 401 maps to gateway_auth_error event
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