[limen jules LIMEN-067] feat: context sync diff/changelog between runs#136
[limen jules LIMEN-067] feat: context sync diff/changelog between runs#1364444J99 wants to merge 2 commits into
Conversation
limen task LIMEN-067 (jules session 8747587654007889078)
Spec Compliance ReportTraceability Audit
Invariant Validators
Ruff Lint✅ Exit code: 0 Tests & Coverage✅ Tests exit code: 0
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48a6194764
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| from organvm_engine.contextmd import AUTO_START, AUTO_END | ||
| import re | ||
|
|
||
| changelog_file = context_changelog_path() |
There was a problem hiding this comment.
Honor --workspace for changelog lookup
When context --workspace /tmp/ws sync --write records history, sync_all writes the changelog via a PathConfig(workspace_dir=workspace), but this lookup ignores args.workspace and reads the default corpus instead. In multi-workspace or test runs, rollback can report no records or apply a timestamp from the default workspace to unrelated files; cmd_context_diff has the same lookup issue above.
Useful? React with 👍 / 👎.
| for change in changes: | ||
| record = { | ||
| "timestamp": sync_timestamp, | ||
| "path": change["path"], |
There was a problem hiding this comment.
Persist resolved paths in changelog entries
When sync is invoked with a relative workspace, for example organvm context --workspace . sync --write, change["path"] is relative because ws is not resolved before generating changes. Persisting that value makes rollback later interpret it relative to the rollback process's current directory, so running rollback from another directory can edit/delete the wrong context file or skip the original one.
Useful? React with 👍 / 👎.
| import time | ||
| from organvm_engine.paths import PathConfig, context_changelog_path | ||
|
|
||
| sync_timestamp = int(time.time()) |
There was a problem hiding this comment.
Use a unique run id for sync records
When two syncs run within the same second, such as in automation or a script calling sync_all twice, both batches receive the same timestamp. Since context diff groups by timestamp and context rollback selects every record with the requested timestamp, a rollback intended for one run will also roll back the other run's files; use a per-run UUID or a higher-resolution timestamp.
Useful? React with 👍 / 👎.
| elif action == "updated": | ||
| if AUTO_START in content and AUTO_END in content: | ||
| pattern = re.escape(AUTO_START) + r".*" + re.escape(AUTO_END) | ||
| new_content = re.sub(pattern, old_section, content, flags=re.DOTALL) |
There was a problem hiding this comment.
Guard rollback against newer syncs
When a file has been synced again after the selected timestamp, rollback still replaces the current AUTO block with this record's old_section without checking that the current block matches the record's new_section. That makes rolling back an older changelog entry silently discard later context updates; compare the current block/after hash first and skip or warn on mismatch.
Useful? React with 👍 / 👎.
| config = PathConfig(workspace_dir=workspace) if workspace else None | ||
| changelog_file = context_changelog_path(config) |
There was a problem hiding this comment.
Keep changelogs with overridden registries
When context sync is run with a top-level --registry pointing at an alternate corpus or fixture, the generated files are based on that registry but the persistent changelog is still resolved only from workspace/environment defaults here. That sends history for the alternate registry to the default corpus path, so the matching context diff/rollback run cannot find it and the default corpus can accumulate unrelated rollback records.
Useful? React with 👍 / 👎.
- Fix W293 (blank line whitespace), I001 (import sorting), PTH123 (Path.open()), F401 (unused import), F541 (f-string), F841 (unused var) - Fix duplicate --format argument on registry list subparser causing argparse.ArgumentError and CI test failure - All lint, typecheck, and CLI tests now passing
Lands completed jules session 8747587654007889078.
limen task LIMEN-067