GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(id): wire `id world fork` CLI + provenance inspect (F12.2 remainder) (#556) by dezren39 · Pull Request #3291 · developing-today/code

feat(id): wire id world fork CLI + provenance inspect (F12.2 remainder) (#556) #3291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
dezren39 merged 2 commits into main from queue/4824-556-world-fork-cli
Nov 1, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

feat(id): wire id world fork CLI + provenance inspect (F12.2 remainder) (#556) #3291

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
d738516
feat(id): wire id world fork CLI + provenance inspect (F12.2 remainder)
dezren39 Nov 1, 2026
c8c1737
fix(id): provenance reads the latest Forked entry; drop unterminated …
dezren39 Nov 1, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
fix(id): provenance reads the latest Forked entry; drop unterminated …
…tail entries

Codex review on the fork CLI (PR for #556): (1) world_provenance used
find_map over the journal, returning the OLDEST Forked entry — in an
A->B->C chain C reported A (and Bs template flag) as its origin; now
scans in reverse so the worlds own fork record wins. (2)
read_world_journal accepted an unterminated final entry when it
happened to parse; FileJournal::open and the store fork reader drop
every unterminated fragment as never-acknowledged, so the inspect
reader now pops the final chunk before parsing when the file does not
end in a newline.

Regression tests: chained fork provenance reports the immediate
origin + own template flag; a complete-JSON but unterminated Forked
line is not reported by provenance.
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@dezren39
dezren39 committed Nov 1, 2026
commit c8c1737b712ad4713a1b8aa4ffd0228b3ede237d

There are no files selected for viewing

26 changes: 13 additions & 13 deletions 26 pkgs/id/src/commands/world.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -765,22 +765,22 @@ pub async fn cmd_world(command: WorldCommand) -> Result<()> {
fn read_world_journal(dir: &std::path::Path) -> Result<Vec<crate::world::JournalEntry>> {
let path = dir.join("journal.jsonl");
let bytes = std::fs::read(&path).with_context(|| format!("read {}", path.display()))?;
let mut lines: Vec<&[u8]> = bytes.split(|byte| *byte == b'\n').collect();
if bytes.last() != Some(&b'\n') {
// The final chunk is an unterminated fragment (or the empty tail
// of an empty file): it was never durably acknowledged, so it is
// dropped even when it happens to parse — the same rule
// `FileJournal::open` and the store-level fork reader apply.
lines.pop();
}
let mut entries = Vec::new();
let lines: Vec<&[u8]> = bytes.split(|byte| *byte == b'\n').collect();
for (index, line) in lines.iter().enumerate() {
for line in lines {
if line.is_empty() {
continue;
}
match serde_json::from_slice::<crate::world::JournalEntry>(line) {
Ok(entry) => entries.push(entry),
Err(error) => {
let is_torn_tail = index == lines.len() - 1 && bytes.last() != Some(&b'\n');
if is_torn_tail {
break;
}
bail!("{} is corrupt: {error}", path.display());
}
}
let entry: crate::world::JournalEntry = serde_json::from_slice(line)
.with_context(|| format!("{} is corrupt", path.display()))?;
entries.push(entry);
}
Ok(entries)
}
Expand All @@ -801,7 +801,7 @@ fn world_provenance(dir: &std::path::Path) -> Result<WorldProvenance> {
);
};
let world_id = world_id.clone();
let forked = entries.iter().find_map(|entry| match entry {
let forked = entries.iter().rev().find_map(|entry| match entry {
crate::world::JournalEntry::Forked {
from_world_id,
from_module_hash,
Expand Down
55 changes: 55 additions & 0 deletions 55 pkgs/id/tests/world_fork_cli.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,61 @@ fn cli_fork_template_flag_is_recorded_and_identifiable() {
assert_eq!(value["template"], false);
}

#[test]
fn cli_provenance_reports_the_most_recent_fork_in_a_chain() {
let tmp = tempfile::tempdir().unwrap();
let (src, _hash) = make_source(tmp.path());
let middle = tmp.path().join("middle-world");
let leaf = tmp.path().join("leaf-world");

run_ok(&[
"world",
"fork",
src.to_str().unwrap(),
middle.to_str().unwrap(),
]);
// Forking the fork appends a second Forked entry; the leaf's
// provenance is its own record (origin = middle, template = true),
// not the inherited one.
run_ok(&[
"world",
"fork",
middle.to_str().unwrap(),
leaf.to_str().unwrap(),
"--template",
]);

let stdout = run_ok(&["world", "provenance", leaf.to_str().unwrap(), "--json"]);
let value: serde_json::Value = serde_json::from_str(&stdout).unwrap();
assert_eq!(value["world_id"], "leaf-world");
assert_eq!(value["forked_from"], "middle-world");
assert_eq!(value["template"], true);
}

#[test]
fn cli_provenance_discards_an_unterminated_final_entry() {
use std::io::Write as _;
let tmp = tempfile::tempdir().unwrap();
let (src, _hash) = make_source(tmp.path());

// A crash left a complete-JSON Forked entry with no terminating
// newline: never acknowledged, so provenance must not report it.
let mut file = std::fs::OpenOptions::new()
.append(true)
.open(src.join("journal.jsonl"))
.unwrap();
file.write_all(
br#"{"entry":"forked","from_world_id":"ghost","from_module_hash":"x","template":true,"at_sequence":99}"#,
)
.unwrap();
drop(file);

let stdout = run_ok(&["world", "provenance", src.to_str().unwrap(), "--json"]);
let value: serde_json::Value = serde_json::from_str(&stdout).unwrap();
assert!(value["forked_from"].is_null(), "{value}");
assert_eq!(value["template"], false);
}

#[test]
fn cli_fork_refuses_a_non_empty_destination_and_a_bad_name() {
let tmp = tempfile::tempdir().unwrap();
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.