Uh oh!
There was an error while loading. Please reload this page.
Add collaborative LaTeX macro safety guard - #393
Closed
karollooool wants to merge 1 commit into
Closed
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a self-contained “collaborative LaTeX macro safety guard” slice that evaluates collaborative Markdown/LaTeX macro packets for safety risks (unsafe macros, recursion, external resources, locked-section holds) and produces deterministic JSON/Markdown/SVG demo artifacts.
Changes:
- Introduces a dependency-free evaluator (
evaluateMacroPacket) and report renderers (Markdown/SVG) for collaborative macro safety gating. - Adds synthetic sample packets plus a demo script that generates deterministic report artifacts.
- Adds a minimal Node-based test and an optional ffmpeg script to render a demo video card.
Reviewed changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Links the new safety-guard module from the repo root README. |
| collaborative-latex-macro-safety-guard/index.js | Core policy, packet evaluation checks, and Markdown/SVG report rendering. |
| collaborative-latex-macro-safety-guard/sample-data.js | Synthetic “ready / blocked / needs_review” packets used by demo/tests. |
| collaborative-latex-macro-safety-guard/test.js | Node assert-based tests covering evaluator decisions and renderers. |
| collaborative-latex-macro-safety-guard/demo.js | Generates deterministic JSON/MD/SVG report artifacts into reports/. |
| collaborative-latex-macro-safety-guard/scripts/render-demo-video.js | Optional ffmpeg-driven MP4 rendering for demo output. |
| collaborative-latex-macro-safety-guard/package.json | Adds scripts (check, test, demo, demo:video) for the module. |
| collaborative-latex-macro-safety-guard/README.md | Documents scope, requirement mapping, and how to run validation/demo. |
| collaborative-latex-macro-safety-guard/reports/demo.json | Committed deterministic demo report output (JSON). |
| collaborative-latex-macro-safety-guard/reports/demo.md | Committed deterministic demo report output (Markdown). |
| collaborative-latex-macro-safety-guard/reports/demo.svg | Committed deterministic demo report output (SVG). |
Comments suppressed due to low confidence (1)
collaborative-latex-macro-safety-guard/index.js:390
findMacroCycle()returnsvisitedwhen the traversal exceedsmaxDepth(i.e., no cycle found within the limit). Because callers treat any non-empty return as a cycle, this will raiseRECURSIVE_MACRO_EXPANSIONfalse positives for long-but-acyclic macro chains. Consider returning an empty array on depth exhaustion (or emitting a distinct "depth limit exceeded" warning/check code).
if (visited.includes(nextName)) {
return [...visited, nextName];
}
current = macroMap.get(nextName);
}
return visited;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "\\url", | ||
| ], | ||
| rawHtmlPattern: /<\s*(script|iframe|object|embed|link|meta|style)\b/i, | ||
| externalUrlPattern: /https?:\/\/([^)\s"']+)/gi, |
Comment on lines
+374
to
+389
| const visited = []; | ||
| let current = startMacro; | ||
| for (let depth = 0; depth <= maxDepth; depth += 1) { | ||
| visited.push(current.name); | ||
| const nextName = [...macroMap.keys()].find((name) => | ||
| current.body.includes(name), | ||
| ); | ||
| if (!nextName) { | ||
| return []; | ||
| } | ||
| if (visited.includes(nextName)) { | ||
| return [...visited, nextName]; | ||
| } | ||
| current = macroMap.get(nextName); | ||
| } | ||
| return visited; |
Comment on lines
+322
to
+325
| function checkLockedSection(packet, addCheck, addIssue) { | ||
| const lockedBlocks = packet.blocks.filter((block) => block.locked); | ||
| const hasRenderRisk = packet.macros.some( | ||
| (macro) => !macro.approved || macro.body.includes("\\href"), |
| function escapeDrawtext(value) { | ||
| return String(value) | ||
| .replaceAll("\\", "\\\\") | ||
| .replaceAll(":", "\\:") |
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 freeto 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.