Add storage format spec and NDJSON migration tool#21
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cf860ae4ea
ℹ️ 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".
| pattern := regexp.MustCompile(`^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2})\]\s*(.*)$`) | ||
| scanner := bufio.NewScanner(file) | ||
| lineNum := 0 |
There was a problem hiding this comment.
Avoid bufio.Scanner token limit for long notes
This uses bufio.NewScanner with the default 64K token limit, so any journal.txt line longer than ~64KB will cause scanner.Err() to return bufio.ErrTooLong and the migration will stop with a partial journal.ndjson. That can happen if users paste large logs or long-form notes into a single line. Consider switching to bufio.Reader with ReadString('\n') or calling scanner.Buffer with a larger limit so long notes migrate cleanly.
Useful? React with 👍 / 👎.
Motivation
journal.txtto an optionaljournal.ndjsonfor metadata-heavy workflows.Description
docs/storage-format.mddescribing the currentjournal.txtformat, a proposedjournal.ndjsonschema (fields:id,text,created_at,updated_at,tags,links,repo,source), compatibility guarantees, and a migration plan.scripts/migrate-journal-to-ndjson.go, a small Go utility that readsjournal.txt, parses timestamps ([YYYY-MM-DD HH:MM]), emits RFC3339created_at, preserves original text, assigns a stable hexid, and writes one JSON object per line withsourceprovenance (source file and line number).-in,-out, and-forceflags and skips blank lines; IDs are generated with cryptographic randomness and fall back to a timestamped string on error.Testing
gofmt -w scripts/migrate-journal-to-ndjson.goto ensure idiomatic formatting.docs/storage-format.mdandscripts/migrate-journal-to-ndjson.go) to confirm the intended schema and flags are present.Codex Task