Skip to content

Add collaborative LaTeX macro safety guard - #393

Closed
karollooool wants to merge 1 commit into
SCIBASE-AI:mainfrom
karollooool:codex/collab-latex-macro-safety
Closed

Add collaborative LaTeX macro safety guard#393
karollooool wants to merge 1 commit into
SCIBASE-AI:mainfrom
karollooool:codex/collab-latex-macro-safety

Conversation

@karollooool

@karolloooolkarollooool commented May 23, 2026

Copy link
Copy Markdown

No description provided.

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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
FileDescription
README.mdLinks the new safety-guard module from the repo root README.
collaborative-latex-macro-safety-guard/index.jsCore policy, packet evaluation checks, and Markdown/SVG report rendering.
collaborative-latex-macro-safety-guard/sample-data.jsSynthetic “ready / blocked / needs_review” packets used by demo/tests.
collaborative-latex-macro-safety-guard/test.jsNode assert-based tests covering evaluator decisions and renderers.
collaborative-latex-macro-safety-guard/demo.jsGenerates deterministic JSON/MD/SVG report artifacts into reports/.
collaborative-latex-macro-safety-guard/scripts/render-demo-video.jsOptional ffmpeg-driven MP4 rendering for demo output.
collaborative-latex-macro-safety-guard/package.jsonAdds scripts (check, test, demo, demo:video) for the module.
collaborative-latex-macro-safety-guard/README.mdDocuments scope, requirement mapping, and how to run validation/demo.
collaborative-latex-macro-safety-guard/reports/demo.jsonCommitted deterministic demo report output (JSON).
collaborative-latex-macro-safety-guard/reports/demo.mdCommitted deterministic demo report output (Markdown).
collaborative-latex-macro-safety-guard/reports/demo.svgCommitted deterministic demo report output (SVG).
Comments suppressed due to low confidence (1)

collaborative-latex-macro-safety-guard/index.js:390

  • findMacroCycle() returns visited when the traversal exceeds maxDepth (i.e., no cycle found within the limit). Because callers treat any non-empty return as a cycle, this will raise RECURSIVE_MACRO_EXPANSION false 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(":", "\\:")
@karolloooolkarollooool closed this by deleting the head repository Jul 26, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@karollooool