Jm reharvest - #89
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a first-class reharvest operation for Linked Data (Layer 3), and wires it into mv so that moves automatically refresh RDF triples (especially relative cask:/ references) after paths change.
Changes:
- Adds
CaskFs.reharvest()plus RDF-layer helpers (detectMimeType,detectResourceType,reharvestFile) to support safe delete+reinsert of file-scoped triples. - Updates
moveFile()/moveDirectory()to automatically reharvest affected RDF material post-move, including an opt-in--recheck-mime-typeflag for extension-changing renames. - Exposes reharvest via CLI + REST endpoint, and adds tests + documentation describing the “known boundary” and how reharvest mitigates it.
Reviewed changes
Copilot reviewed 12 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/reharvest.test.js | Adds direct-pg unit/integration coverage for reharvest() and mv auto-reharvest behaviors. |
| tests/cp.test.js | Adds CLI-level assertion that cask reharvest reports reharvested files. |
| src/lib/ld.js | Centralizes MIME/resource-type detection and adds reharvestFile() (delete+insert+persist quads). |
| src/lib/http-client.js | Adds reharvest() method and extends move() to pass recheckMimeType. |
| src/index.js | Implements reharvest(), integrates automatic reharvest into moveFile() / moveDirectory(), and refactors MIME/resource-type detection to RDF helpers. |
| src/controllers/ld.js | Adds HTTP endpoint POST /cask/ld/reharvest. |
| src/controllers/fs.js | Extends /fs/mv to accept recheckMimeType. |
| src/bin/cask.js | Adds cask reharvest command; enhances cask mv behavior/flags description. |
| src/bin/cask-admin.js | Removes the reindex-ld admin command. |
| docs/structural-metadata.md | Documents how mv+reharvest closes part of the Layer 3 boundary, plus relative-reference implications. |
| docs/ld.md | Documents reharvest semantics and updates literal predicate default documentation. |
| docs/ld-rest-api.md | Documents the new REST API endpoint for reharvest. |
| docs/fs.md | Documents mv’s automatic reharvest behavior and the --recheck-mime-type flag semantics. |
| .mocharc.yml | Adds the new reharvest test file to the mocha spec list. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+18
to
+23
| // re-parse and re-store RDF triples for a file, or every rdf-resourceType file under a | ||
| // directory (recursively). Files whose resourceType is not rdf are skipped, not errored. | ||
| router.post('/reharvest', async (req, res) => { | ||
| try { | ||
| const { path: targetPath } = req.body || {}; | ||
| if (!targetPath) return res.status(400).json({ error: 'path is required' }); |
Comment on lines
+1236
to
+1248
| // if the rename changes the extension, resourceType (and, opt-in, mimeType) may be stale | ||
| let metadataPatch = null; | ||
| if (destParts.ext !== path.parse(srcPath).ext) { | ||
| let newMimeType = srcMeta.metadata.mimeType; | ||
| if (opts.recheckMimeType) { | ||
| newMimeType = this.rdf.detectMimeType(destPath); | ||
| } | ||
| let newResourceType = this.rdf.detectResourceType(newMimeType, destPath); | ||
|
|
||
| if (newMimeType !== srcMeta.metadata.mimeType || newResourceType !== srcMeta.metadata.resourceType) { | ||
| metadataPatch = { ...srcMeta.metadata, mimeType: newMimeType, resourceType: newResourceType }; | ||
| } | ||
| } |
Comment on lines
+1441
to
+1443
| while (true) { | ||
| const result = await this.ls({ directory: dir, limit, offset, requestor }); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.