Skip to content

Commit 4acf70c

Browse files
hyperpolymathclaude
andcommitted
feat(chapel): compile mass-panic under Chapel 2.8.0 and wire diff subcommand
Bug fixes from code review: - spawn() called with list(string) instead of array — add .toArray() - proc ref classifyRisk invalid syntax — remove erroneous ref prefix - image.generatedAt/scanSurface and report.createdAt never populated - loadTemporalIndex discarded all prior snapshot history on each save — replaced with loadSnapshotCount + loadRawSnapshots + raw-splice append - dateString() returned epoch seconds — now shells to date -u ISO 8601 - findingsOnly config flag declared but never wired up — fixed - buildEdges loop used (i+1)..#nodes.size causing out-of-bounds on last element Chapel 2.8.0 compatibility: - label is a reserved keyword — renamed all fields/params to tag/snapTag - map initializer requires new map(K, V) syntax - string.find(str, int) removed — replaced with character-scan iteration - string indexing/slicing and casts are now throwing — wrapped in try/catch - list.this() throws — wrapped in try! - comparator requires relativeComparator interface - isFile/isDir throw — safeIsFile/safeIsDir helpers added - Math module needed for exp() in Imaging - Map module missing from Temporal.chpl imports - Protocol.basename conflicts with Path.basename — removed duplicate New: diff subcommand wired through MassPanic.main() → runDiff() → diffSnapshots() using loadSnapshotSummaries() line-by-line parser. Justfile: chapel-build, chapel-build-toolbox, chapel-clean, chapel-scan, chapel-diff. Mason.toml: bumped to chplVersion 2.8.0. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5c5916a commit 4acf70c

6 files changed

Lines changed: 504 additions & 157 deletions

File tree

Justfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,27 @@ build-riscv:
133133
@echo "Building for RISC-V..."
134134
cross build --target riscv64gc-unknown-linux-gnu
135135

136+
# Build Chapel mass-panic distributed scanner (requires Chapel 2.8.0+)
137+
# On Fedora Atomic, run inside toolbox: toolbox run --container chapel-dev just chapel-build
138+
chapel-build:
139+
cd chapel && chpl src/MassPanic.chpl src/Protocol.chpl src/Imaging.chpl src/Temporal.chpl -o mass-panic
140+
141+
# Build inside the chapel-dev toolbox container (Fedora Atomic host)
142+
chapel-build-toolbox:
143+
toolbox run --container chapel-dev bash -c "cd $(pwd)/chapel && chpl src/MassPanic.chpl src/Protocol.chpl src/Imaging.chpl src/Temporal.chpl -o mass-panic"
144+
145+
# Clean Chapel build artefacts
146+
chapel-clean:
147+
rm -f chapel/mass-panic
148+
149+
# Scan local repo tree with mass-panic (Chapel single-locale)
150+
chapel-scan dir=env("HOME") + "/Documents/hyperpolymath-repos":
151+
./chapel/mass-panic --repoDirectory={{dir}}
152+
153+
# Diff the two most recent mass-panic temporal snapshots
154+
chapel-diff:
155+
./chapel/mass-panic --subcommand=diff
156+
136157
# Run panic-attacker pre-commit scan
137158
assail:
138159
@command -v panic-attack >/dev/null 2>&1 && panic-attack assail . || echo "panic-attack not found — install from https://github.com/hyperpolymath/panic-attacker"

chapel/Mason.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[brick]
44
name = "mass-panic"
55
version = "0.1.0"
6-
chplVersion = "2.3.0"
6+
chplVersion = "2.8.0"
77
authors = ["Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>"]
88
license = "PMPL-1.0-or-later"
99

chapel/src/Imaging.chpl

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module Imaging {
3030
use IO;
3131
use List;
3232
use Map;
33+
use Math;
3334
use Sort;
3435
use Protocol;
3536

@@ -203,26 +204,28 @@ module Imaging {
203204

204205
// Risk proximity edges: connect repos with similar risk profiles
205206
for i in 0..#nodes.size {
206-
if nodes[i].skipped || nodes[i].error != "" then continue;
207-
for j in (i+1)..#nodes.size {
208-
if nodes[j].skipped || nodes[j].error != "" then continue;
207+
const ni = try! nodes[i];
208+
if ni.skipped || ni.error != "" then continue;
209+
for j in (i+1)..<nodes.size {
210+
const nj = try! nodes[j];
211+
if nj.skipped || nj.error != "" then continue;
209212

210213
// Connect repos with similar risk intensity (within 0.15)
211-
const riskDelta = abs(nodes[i].riskIntensity - nodes[j].riskIntensity);
212-
if riskDelta < 0.15 && nodes[i].riskIntensity > 0.3 {
214+
const riskDelta = abs(ni.riskIntensity - nj.riskIntensity);
215+
if riskDelta < 0.15 && ni.riskIntensity > 0.3 {
213216
var edge: ImageEdge;
214-
edge.fromNode = nodes[i].id;
215-
edge.toNode = nodes[j].id;
217+
edge.fromNode = ni.id;
218+
edge.toNode = nj.id;
216219
edge.edgeType = "risk_proximity";
217220
edge.weight = 1.0 - riskDelta / 0.15;
218221
edges.pushBack(edge);
219222
}
220223

221224
// Connect repos that share dominant vulnerability categories
222-
if sharesDominantCategory(nodes[i], nodes[j]) {
225+
if sharesDominantCategory(ni, nj) {
223226
var edge: ImageEdge;
224-
edge.fromNode = nodes[i].id;
225-
edge.toNode = nodes[j].id;
227+
edge.fromNode = ni.id;
228+
edge.toNode = nj.id;
226229
edge.edgeType = "shared_pattern";
227230
edge.weight = 0.8;
228231
edges.pushBack(edge);
@@ -260,7 +263,7 @@ module Imaging {
260263
// Risk classification
261264
// ---------------------------------------------------------------------------
262265

263-
proc ref classifyRisk(ref dist: RiskDistribution, risk: real) {
266+
proc classifyRisk(ref dist: RiskDistribution, risk: real) {
264267
if risk < 0.2 then dist.healthy += 1;
265268
else if risk < 0.4 then dist.low += 1;
266269
else if risk < 0.6 then dist.moderate += 1;

0 commit comments

Comments
 (0)