Skip to content

fix(session): verify live messages clear before commit#1673

Closed
euyua9 wants to merge 2 commits into
volcengine:mainfrom
euyua9:devb/openviking-commit-durability-guard
Closed

fix(session): verify live messages clear before commit#1673
euyua9 wants to merge 2 commits into
volcengine:mainfrom
euyua9:devb/openviking-commit-durability-guard

Conversation

@euyua9
Copy link
Copy Markdown
Contributor

@euyua9 euyua9 commented Apr 23, 2026

Summary

  • read back the live messages.jsonl immediately after clearing it during commit
  • roll back the in-memory session state if the persisted live file is still non-empty
  • add a regression test that simulates a stale empty-write no-op

Validation

  • ./.venv/bin/python -m py_compile openviking/session/session.py tests/session/test_session_commit.py
  • ad-hoc async validation with a fake VikingFS to confirm commit_async() now raises and restores state when the live messages.jsonl stays non-empty
  • full pytest in this environment is blocked because local OpenViking test startup still requires ragfs_python, and rebuilding it currently fails with an xcrun CommandLineTools architecture mismatch on this machine

Closes #1487.

@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

1487 - Partially compliant

Compliant requirements:

  • Verify root/messages.jsonl is empty after commit and roll back if not

Non-compliant requirements:

  • Check archive artifacts (.done, .abstract.md, .overview.md) existence
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🏅 Score: 90
🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ No major issues detected

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

@euyua9
Copy link
Copy Markdown
Contributor Author

euyua9 commented Apr 23, 2026

Fixed the failing lint / lint job.

Root cause: the new regression test in tests/session/test_session_commit.py wasn't formatted the way ruff format --check expects.

I pushed a formatter-only follow-up commit:

  • acc9853f (test: format commit durability regression test)

Local validation:

  • uv tool run ruff format --check openviking/session/session.py tests/session/test_session_commit.py
  • uv tool run ruff check openviking/session/session.py tests/session/test_session_commit.py

Waiting for CI to rerun.

@euyua9
Copy link
Copy Markdown
Contributor Author

euyua9 commented May 1, 2026

Updated this PR to cover the remaining archive completion guard from issue #1487.

What changed:

  • rebased/merged the branch onto the latest main to clear the merge conflict
  • kept the existing live messages.jsonl durability check
  • added a Phase 2 guard that verifies the archive artifacts are readable before writing .done
  • added a regression test that simulates a missing .overview.md artifact and asserts .done is not written; the task records a failed archive marker instead

Local validation:

  • uv tool run ruff format --check openviking/session/session.py tests/session/test_session_commit.py
  • uv tool run ruff check openviking/session/session.py tests/session/test_session_commit.py
  • python3 -m py_compile openviking/session/session.py tests/session/test_session_commit.py
  • git diff --check origin/main...HEAD

I also tried the targeted pytest selection locally, but this machine cannot load/build the native RAGFS/OpenViking artifacts (ragfs_python/CommandLineTools linker environment), so I left full runtime validation to CI.

@euyua9 euyua9 force-pushed the devb/openviking-commit-durability-guard branch from d80ab03 to e2d7cf9 Compare May 6, 2026 15:37
@euyua9
Copy link
Copy Markdown
Contributor Author

euyua9 commented May 6, 2026

Updated this branch again after main advanced and rebuilt it as a clean single focused commit on top of the latest main.

Current head: e2d7cf9dff90fdc6bc082729b1dec79dff781eaa

What is preserved/fixed:

  • verifies the persisted live messages.jsonl count immediately after commit clears/retains live messages; rolls back and raises FailedPreconditionError if persisted state does not match memory
  • verifies required archive artifacts are readable before writing .done: messages.jsonl, .abstract.md, .overview.md, .meta.json
  • keeps the regression coverage for both the stale live messages.jsonl rollback path and the missing archive artifact path

Local validation:

  • python3 -m py_compile openviking/session/session.py tests/session/test_session_commit.py
  • git diff --check origin/main...HEAD

Local environment notes:

  • targeted pytest could not run here because the editable build tries to build the native ov/RAGFS artifacts and this machine's CommandLineTools linker environment is broken (libxcrun.dylib architecture mismatch)
  • ruff check is currently blocked by two pre-existing findings in openviking/session/session.py (C420 near line 125 and C414 near line 2239`); I did not change those unrelated areas to keep this PR focused
  • ruff format --check would reformat many unrelated existing WM-v2 sections in the same file, so I avoided applying whole-file formatting churn

@euyua9 euyua9 force-pushed the devb/openviking-commit-durability-guard branch from e2d7cf9 to f113b69 Compare May 7, 2026 04:01
@euyua9
Copy link
Copy Markdown
Contributor Author

euyua9 commented May 7, 2026

Fixed the lint / lint failure from the latest run and pushed f113b69.

Root cause: the PR touched openviking/session/session.py, so the changed-file lint job runs both ruff format and ruff check on the whole changed file. After applying ruff formatting, two existing ruff findings in that same file also needed to be resolved for the changed-file lint job to pass.

Follow-up changes:

  • ran ruff format on the changed files
  • replaced the existing WM schema dict comprehension with dict.fromkeys(...) for C420
  • removed an existing redundant list() inside sorted(...) for C414

Validation:

  • uv tool run ruff format --check openviking/session/session.py tests/session/test_session_commit.py
  • uv tool run ruff check openviking/session/session.py tests/session/test_session_commit.py
  • python3 -m py_compile openviking/session/session.py tests/session/test_session_commit.py
  • git diff --check origin/main...HEAD

@euyua9
Copy link
Copy Markdown
Contributor Author

euyua9 commented May 7, 2026

Fixed the remaining lint / lint format failure and pushed 6871189.

Root cause: the changed-file CI job runs ruff format --check against the complete touched files on the PR merge ref. My previous local formatting changes were still in the working tree instead of being included in the pushed commit.

Follow-up:

  • committed the ruff formatting changes for openviking/session/session.py and tests/session/test_session_commit.py
  • re-checked the account identity before pushing; the new commit is authored/committed as euyu <[email protected]> for this PR account

Validation:

  • uv tool run ruff format --check openviking/session/session.py tests/session/test_session_commit.py
  • uv tool run ruff check openviking/session/session.py tests/session/test_session_commit.py
  • python3 -m py_compile openviking/session/session.py tests/session/test_session_commit.py
  • git diff --check origin/main...HEAD

@euyua9
Copy link
Copy Markdown
Contributor Author

euyua9 commented May 11, 2026

Closing this from my side as superseded by the current main branch. The session commit path now already includes the live-message durability guard helpers such as live_message_count / _read_live_message_count and the schema cleanup, so this older branch is stale and conflicted against the current implementation.

@euyua9 euyua9 closed this May 11, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: not confirm empty message.jsonl state before commit return

1 participant