Skip to content

Jm reharvest - #89

Merged
jrmerz merged 2 commits into
devfrom
jm-reharvest
Aug 21, 2026
Merged

Jm reharvest#89
jrmerz merged 2 commits into
devfrom
jm-reharvest

Conversation

@jrmerz

@jrmerz jrmerz commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-type flag 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 thread src/controllers/ld.js
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 thread src/index.js
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 thread src/index.js
Comment on lines +1441 to +1443
while (true) {
const result = await this.ls({ directory: dir, limit, offset, requestor });

@jrmerz
jrmerz merged commit 9dc18ba into dev Aug 21, 2026
1 check passed
@jrmerz
jrmerz deleted the jm-reharvest branch August 21, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants