Skip to content

Commit e4911cc

Browse files
author
Test User
committed
Add collaborative LaTeX macro safety guard
1 parent abb4798 commit e4911cc

12 files changed

Lines changed: 1365 additions & 0 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# deepevents.ai
22
deepevents.ai main codebase
3+
4+
- [Collaborative LaTeX macro safety guard](collaborative-latex-macro-safety-guard/README.md)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Collaborative LaTeX Macro Safety Guard
2+
3+
This module is a self-contained real-time collaborative research editor slice for SCIBASE.AI issue #12. It validates synchronized Markdown and LaTeX editor packets before live preview or named-version export.
4+
5+
The guard uses synthetic data only. It does not connect to live users, private manuscripts, browser sessions, credentials, or external services.
6+
7+
## Scope
8+
9+
- Detect conflicting collaborator macro definitions before broadcast.
10+
- Block unsafe macro commands such as raw HTML helpers, external links, and image includes unless a trusted render packet is explicitly reviewed.
11+
- Detect recursive macro expansion cycles that can hang live preview or export rendering.
12+
- Block raw active HTML and unapproved external render resources inside Markdown/LaTeX blocks.
13+
- Hold locked sections when unapproved or external-resource macro changes affect the render packet.
14+
- Emit deterministic remediation actions for live preview, trusted KaTeX rendering, and named-version export gates.
15+
16+
## Requirement Mapping
17+
18+
| Issue #12 area | Implementation |
19+
| --- | --- |
20+
| Rich scientific formatting | Macro, equation, Markdown, and external render-resource checks |
21+
| Real-time collaboration | Multi-user macro conflict and shared render packet validation |
22+
| Locking/unlock modes | Locked section render holds for risky macro packets |
23+
| Version history and autosave | Named-version export decisions and reviewer remediation packets |
24+
25+
## Files
26+
27+
- `index.js` - dependency-free evaluator plus Markdown/SVG report renderers.
28+
- `sample-data.js` - synthetic ready, blocked, and needs-review editor packets.
29+
- `test.js` - Node assertion coverage for guard decisions and report renderers.
30+
- `demo.js` - writes deterministic JSON, Markdown, and SVG reviewer artifacts.
31+
- `scripts/render-demo-video.js` - optional ffmpeg-based MP4 renderer.
32+
- `reports/` - generated reviewer artifacts.
33+
34+
## Validation
35+
36+
```bash
37+
npm run check
38+
npm test
39+
npm run demo
40+
```
41+
42+
Optional video render when ffmpeg is available:
43+
44+
```bash
45+
npm run demo:video
46+
```
47+
48+
The included demo artifacts are deterministic and based only on the synthetic fixtures in `sample-data.js`.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const fs = require("node:fs");
2+
const path = require("node:path");
3+
const {
4+
createGuardReport,
5+
renderMarkdown,
6+
renderSvg,
7+
} = require("./index");
8+
const { samplePackets } = require("./sample-data");
9+
10+
const reportsDir = path.join(__dirname, "reports");
11+
fs.mkdirSync(reportsDir, { recursive: true });
12+
13+
const report = createGuardReport(samplePackets);
14+
const jsonPath = path.join(reportsDir, "demo.json");
15+
const markdownPath = path.join(reportsDir, "demo.md");
16+
const svgPath = path.join(reportsDir, "demo.svg");
17+
18+
fs.writeFileSync(jsonPath, `${JSON.stringify(report, null, 2)}\n`);
19+
fs.writeFileSync(markdownPath, renderMarkdown(report));
20+
fs.writeFileSync(svgPath, renderSvg(report));
21+
22+
console.log(`Wrote ${path.relative(process.cwd(), jsonPath)}`);
23+
console.log(`Wrote ${path.relative(process.cwd(), markdownPath)}`);
24+
console.log(`Wrote ${path.relative(process.cwd(), svgPath)}`);
25+
console.log(
26+
`Ready=${report.totals.ready} NeedsReview=${report.totals.needsReview} Blocked=${report.totals.blocked}`,
27+
);

0 commit comments

Comments
 (0)