Files
tidewall/tools/provenance.gd
T
claudeandClaude Opus 5.5 6873ba4ab4 R4: Originality and licence audit
- docs/ASSET_PROVENANCE.md traces each of the 162 files under assets/ to
  the script that generates it, or to its hand-written original (the app
  icon's SVG). It's written by tools/provenance.gd, and the new
  test_asset_provenance fails on a file with no rule, a rule naming a
  generator that doesn't exist, or a stale document. The release package
  and the .deb now ship it next to PROVENANCE.md (make dist-check and
  make deb-check pass).
- Searched code, data, assets, docs and packaging for commercial game
  names, characters, item and place names: none. The only matches are the
  genre wording ("battle royale") and, in the DEVLOG, an open-source engine
  another task uses. Item and place names are Tidewall's own (dock carbine,
  fowling piece, tern chapel...).
- Licence notices: the Godot engine's licence and its third-party notices
  (ENGINE-LICENSES.txt, generated from the engine) already ship in the
  tarball and the .deb's copyright; there are no other libraries, addons or
  fonts. CREDITS.md links the new trace.
- Name check for "Tidewall" noted on R7 (#66).

Closes #63

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:27:28 -05:00

101 lines
4.5 KiB
GDScript

## R4: traces every file under assets/ to the script that makes it, or to its original
## hand-written source, and writes the per-file table in docs/ASSET_PROVENANCE.md.
## `test_asset_provenance` fails if a file has no rule, a rule names a generator that
## doesn't exist, or the document is out of date.
## tools/godot.sh --script res://tools/provenance.gd
extends SceneTree
const ASSETS: String = "res://assets"
const DOC: String = "res://docs/ASSET_PROVENANCE.md"
## Path pattern (relative to assets/, `*` wildcards) -> [source, how]. First match wins.
const RULES: Array[Array] = [
["PROVENANCE.md", "written by hand", "The summary of how each kind of asset is made."],
["audio/manifest.json", "tools/audio/generate.gd", "Each sound's category, length, SHA-256, peak and loudness, written as the sounds are baked."],
["audio/music_*.wav", "tools/audio/score.gd", "A layer of the original score: note lists written for Tidewall, synthesized by tools/audio/dsp.gd."],
["audio/*.wav", "tools/audio/recipes.gd", "Synthesized from seeded noise, oscillators, filters and decaying modes (tools/audio/dsp.gd)."],
["models/items/*", "tools/models/items.py", "An item model (OBJ and MTL) and its grip data (JSON), built from primitives in headless Blender."],
["icons/items/*.png", "tools/models/items.py", "The item's model rendered with Cycles on the CPU in headless Blender."],
["models/figure/*", "tools/models/figure.py", "A part of the player figure (OBJ and MTL) or its joint data (JSON), built from primitives in headless Blender."],
["icons/app/tidewall.svg", "written by hand", "The application icon, an SVG written for Tidewall in Palette colours."],
["icons/app/tidewall-*.png", "tools/app_icon.gd", "The hand-written SVG rasterised by the engine's SVG loader."],
]
const HEADER: String = """# Asset provenance, file by file
Every file under `assets/` and where it comes from: the script in this repository that
generates it, or "written by hand" for an original source written for Tidewall. Nothing
is sampled, recorded, downloaded or taken from a third party. How each kind of asset is
made is described in [assets/PROVENANCE.md](../assets/PROVENANCE.md); the licence is
CC BY-SA 4.0 ([LICENSE-ASSETS](../LICENSE-ASSETS)).
Code-built art (terrain, sea, points of interest, props, build pieces, the barge, sea
chests and effects) isn't a file here: it's drawn by the scripts under `src/client/`.
This file is written by `tools/godot.sh --script res://tools/provenance.gd`, and
`test/test_asset_provenance.gd` fails if it falls out of date or a file has no source.
| File | Source | What it is |
|---|---|---|
"""
func _init() -> void:
var problems: Array[String] = problems_with(rows())
if not problems.is_empty():
for problem: String in problems:
push_error(problem)
quit(1)
return
var file: FileAccess = FileAccess.open(DOC, FileAccess.WRITE)
file.store_string(render())
file.close()
print("asset provenance: %d files in %s" % [rows().size(), DOC])
quit(0)
## Every file under assets/, sorted, without the engine's .import and .uid sidecars.
static func files(dir: String = ASSETS, prefix: String = "") -> Array[String]:
var found: Array[String] = []
for name: String in DirAccess.get_files_at(dir):
if name.ends_with(".import") or name.ends_with(".uid"):
continue
found.append(prefix + name)
for sub: String in DirAccess.get_directories_at(dir):
found.append_array(files(dir.path_join(sub), prefix + sub + "/"))
found.sort()
return found
## [path, source, how] for each file, with an empty source where no rule matches.
static func rows() -> Array[Array]:
var out: Array[Array] = []
for path: String in files():
var row: Array = [path, "", ""]
for rule: Array in RULES:
if path.match(rule[0]):
row = [path, rule[1], rule[2]]
break
out.append(row)
return out
static func problems_with(table: Array[Array]) -> Array[String]:
var found: Array[String] = []
for row: Array in table:
var source: String = row[1]
if source.is_empty():
found.append("assets/%s: no recorded source; add a rule to tools/provenance.gd" % row[0])
elif source != "written by hand" and not FileAccess.file_exists("res://" + source):
found.append("assets/%s: its generator %s doesn't exist" % [row[0], source])
return found
static func render() -> String:
var lines: Array[String] = []
for row: Array in rows():
var source: String = row[1]
var shown: String = source if source == "written by hand" else "`%s`" % source
lines.append("| `assets/%s` | %s | %s |" % [row[0], shown, row[2]])
return HEADER + "\n".join(lines) + "\n"