Conversation
generate_naics_clusters.py:100 wrote "naisc_cluster.json" -- a misspelling
of naics, with no path -- into the current directory, so clusters/naics.json
was never updated. gen_defence_university.py:290 had the same shape.
gen_gsma_motif.py:281 had its galaxies/ write commented out while still
printing "All done", so the cluster was regenerated and the galaxy was not.
All three now write to ../clusters/... / ../galaxies/... as the other
generators in tools/ do, with encoding='utf-8', indent=2, sort_keys=True and
a trailing newline so the output already matches jq_all_the_things.sh.
The commented-out concern in gen_gsma_motif ("sort_keys breaks the
kill_chain_order") was unfounded: sort_keys orders dict keys, not list
elements. Dumping the committed galaxy with those exact options round-trips
byte-identically.
Pointing gen_defence_university at the real cluster makes its per-entry
uuid4() destructive, so it now reuses the uuid already committed for each
university (159/159 preserved) and mints only for genuinely new entries --
without that, the path fix would be a regression.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HZGwPoa8MMfkhCw47rDLA4
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 free
to 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.
BLUF — Three generators never write the clusters and galaxy they claim to maintain, and say nothing
generate_naics_clusters.pywrites a misspellednaisc_cluster.jsoninto the current directory,gen_defence_university.pywriteschina-defence-universities.jsoninto the current directory, andgen_gsma_motif.pyhas its galaxy write commented out while still printing success. Maintainers get a stray file intools/and staleclusters/naics.json,clusters/china-defence-universities.jsonand the gsma-motif galaxy, with no error.../clusters/and../galaxies/with utf-8,indent=2,sort_keysand a trailing newline, so output already matchesjq_all_the_things.sh, and make the silent ones print the path written.Problem
Three generators do not write to the files they claim to maintain.
tools/generate_naics_clusters.py:100— writes a misspelled filename into the current directory:clusters/naics.jsonis never touched. Running the generator produces a stray file intools/and leaves the real cluster untouched — while reporting nothing.tools/gen_defence_university.py:290— same shape:clusters/china-defence-universities.jsonis never updated.tools/gen_gsma_motif.py:281-284— the galaxy write is commented out, but the script still prints a success message:So the cluster is regenerated and the galaxy silently is not.
Fix
All three now write to
../clusters/.../../galaxies/...— the same relative form the other generators intools/use — withencoding='utf-8',indent=2,sort_keys=Trueand a trailing newline, so their output already matches whatjq_all_the_things.shwould produce. The two that were silent now print the path they wrote.The commented-out concern in
gen_gsma_motif.pywas unfounded:sort_keysorders dict keys, not list elements, so thekill_chain_orderphase sequence is unaffected. Verified — dumping the committed galaxy with those exact options round-trips byte-identically:One coupled change
Pointing
gen_defence_university.pyat the real cluster makes its per-entryuuid.uuid4()destructive — a first real run would replace all 159 universities with new uuids and orphan everyrelatededge. So this PR also has it reuse the uuid already committed for each university, minting a fresh one only for a genuinely new entry:Without that, the path fix would be a regression rather than a fix.
Verification
No stray current-directory
open()calls remain (the old paths survive only inside explanatory comments). All three compile.🤖 Generated with Claude Code