A handoff file can be perfectly valid JSON and still tell a misleading story. Two rows may describe different drafts using the same identifier. A file marked approved may have no record of the intended use. A field that looks like a harmless filename may actually contain an absolute path copied from one person's laptop. None of these problems requires a large data platform to become inconvenient. A small, explicit validator can catch inconsistencies before a worksheet is reused as configuration or attached to a delivery message.
Disclosure: I work with the BeatMuse team. This article and its code were prepared autonomously with AI assistance. The code below was executed locally against synthetic metadata fixtures. It does not read audio, test a music product, integrate with a generator, or establish that a real release has permission.
Start by defining the record, not the parser
The example format is a manually maintained handoff manifest. It is our own illustrative convention, not an export format supplied by a service. A project contains a list of versions. Each version records an identifier, a relative filename, a review status, an intended use, a permission state, and a note. Keeping those concepts separate is the design decision that matters most. A pleasant sounding draft is not automatically approved, and an approved creative direction is not the same thing as documented permission for distribution.
Use a schema version from the beginning. The integer here selects a particular interpretation of the fields. It is not a score or an estimate of completeness. The validator rejects unknown fields because a typo such as statuss should not silently become ignored metadata. That is a deliberately strict policy for a small internal format. A team that needs extensibility can define an explicit extension object or a new version instead of making the reader guess which extra properties have meaning.
The smallest valid example is deliberately unexciting:
{
"schema_version": 1,
"project": "lantern-demo",
"versions": [
{
"id": "sketch-01",
"file": "drafts/lantern-v01.wav",
"status": "exploration",
"permission": "unknown",
"intended_use": "internal comparison",
"permission_note": ""
}
]
}
Notice that exploration with unknown permission is valid. A validator should not force people to claim certainty they do not have. This record says what is currently known and names an internal comparison as the intended use. It does not say that the referenced file exists, that the music has been listened to, or that any external reviewer has approved it. Those are separate checks. The synthetic filename is only a string used to explain the format.
Make failure information specific enough to fix
The implementation returns a list of errors rather than a single true or false value. Every row error includes its array position and the relevant field when possible. This gives a reviewer a useful place to start without printing the whole record, which might contain private project notes. The function also continues past a malformed row so that one mistake does not hide every later problem. For this small format, ordinary Python structures are sufficient; there is no network request, database dependency, or package installation step.
"""Lint a manually maintained example format; no audio or service integration."""
import re
ROOT_FIELDS = {"schema_version", "project", "versions"}
ROW_FIELDS = {"id", "file", "status", "permission", "intended_use", "permission_note"}
STATUSES = {"exploration", "review", "approved"}
PERMISSIONS = {"unknown", "needs_review", "recorded"}
ID = re.compile(r"[a-z0-9][a-z0-9_-]{0,39}\Z")
def nonempty(value):
return isinstance(value, str) and bool(value.strip())
def portable_path(value):
if not nonempty(value) or value != value.strip():
return False
if any(ord(c) < 32 for c in value) or any(c in value for c in "\\:"):
return False
return all(part not in {"", ".", ".."} for part in value.split("/"))
def validate(document):
errors = []
if not isinstance(document, dict):
return ["root: expected an object"]
unknown = set(document) - ROOT_FIELDS
if unknown:
errors.append("root: unknown fields " + ", ".join(sorted(map(str, unknown))))
if type(document.get("schema_version")) is not int or document["schema_version"] != 1:
errors.append("schema_version: expected integer 1")
if not nonempty(document.get("project")):
errors.append("project: expected nonempty text")
rows = document.get("versions")
if not isinstance(rows, list) or not rows:
return errors + ["versions: expected a nonempty array"]
ids, paths = set(), set()
for index, row in enumerate(rows):
prefix = f"versions[{index}]"
if not isinstance(row, dict):
errors.append(prefix + ": expected an object")
continue
unknown = set(row) - ROW_FIELDS
if unknown:
errors.append(prefix + ": unknown fields " + ", ".join(sorted(map(str, unknown))))
ident = row.get("id")
if not isinstance(ident, str) or not ID.fullmatch(ident):
errors.append(prefix + ".id: expected a short lowercase identifier")
elif ident in ids:
errors.append(prefix + ".id: duplicate identifier")
else:
ids.add(ident)
path = row.get("file")
if not portable_path(path):
errors.append(prefix + ".file: expected a portable relative path")
elif path.casefold() in paths:
errors.append(prefix + ".file: duplicate case-folded path")
else:
paths.add(path.casefold())
status, permission = row.get("status"), row.get("permission")
if not isinstance(status, str) or status not in STATUSES:
errors.append(prefix + ".status: unknown state")
if not isinstance(permission, str) or permission not in PERMISSIONS:
errors.append(prefix + ".permission: unknown state")
if not nonempty(row.get("intended_use")):
errors.append(prefix + ".intended_use: expected nonempty text")
note = row.get("permission_note")
if not isinstance(note, str):
errors.append(prefix + ".permission_note: expected text")
if permission == "recorded" and not nonempty(note):
errors.append(prefix + ".permission_note: recorded requires a note")
if status == "approved" and permission != "recorded":
errors.append(prefix + ": approved requires a recorded permission note")
return errors
The exact integer check is intentional. In Python, a Boolean is a subclass of integer, so an equality check alone can make True look like version one. Checking the type first avoids that accidental interpretation. The status and permission checks also test for strings before consulting their allowed sets. This means a malformed list or object produces a normal validation error instead of an unhashable-value exception. Boundary inputs deserve the same predictable behavior as ordinary successful examples.
Treat identifiers and filenames as different namespaces
The identifier is a short lowercase label used in discussion and comparison notes. The filename is a reference to a local artifact. They are not interchangeable, and the code tracks duplicates separately. The filename comparison uses case folding as a conservative portability policy. Consequently, two spellings that differ only in case are rejected even on a filesystem that could store them separately. This is a workflow tradeoff, not a statement that every operating system treats those names identically. Make that choice visible to collaborators before enforcing it.
The path rule permits clean relative components and rejects absolute paths, parent components, empty components, drive-like colons, backslashes, control characters, and surrounding whitespace. It never normalizes a suspicious value into something that looks acceptable. However, this is still string validation, not a filesystem sandbox. It does not resolve symbolic links, open a file, inspect its contents, or authorize access. If another program later reads the referenced artifact, that program needs its own containment and access checks. Do not turn a bookkeeping example into a security guarantee it cannot provide.
Require a note without pretending to verify its truth
An approved row must use the recorded permission state, and that state requires a nonempty note. This creates a visible checkpoint in the workflow. It does not make the note reliable. A person can still type an inaccurate statement, point to an irrelevant document, or misunderstand the intended use. The application of the record therefore still requires human judgment and appropriate evidence. A useful next step might be a private reference identifier reviewed by the responsible person, rather than copying contracts or personal details into the manifest itself.
The recorded state should also be reconsidered when the intended use changes. Internal comparison and a public advertising campaign are different situations. This validator cannot infer that change by listening to audio or reading a filename. It can only require that the relevant fields exist and remain mutually consistent under the chosen rules. That limited purpose is a strength: a small tool is easier to explain when its successful result means only that the metadata meets a defined convention.
Test the boundaries before adding a user interface
The accompanying tests use deep copies so that one mutation cannot leak into another case. They exercise a valid exploration record, a Boolean version value, duplicate identifiers, case-folded filename collisions, an unknown property, malformed shapes, invalid path forms, malformed enum values, and the approval-note relationship. The path test includes several independent examples under subtests. These are deliberately synthetic records. No real audio, customer material, external account, or product-generated export is involved in the test run.
import copy
import unittest
from beatmuse_manifest_lint import validate
BASE = {
"schema_version": 1,
"project": "lantern-demo",
"versions": [{
"id": "sketch-01", "file": "drafts/lantern-v01.wav",
"status": "exploration", "permission": "unknown",
"intended_use": "internal comparison", "permission_note": ""
}]
}
class ManifestTests(unittest.TestCase):
def test_valid_exploration(self):
self.assertEqual(validate(copy.deepcopy(BASE)), [])
def test_boolean_is_not_version_integer(self):
data = copy.deepcopy(BASE)
data["schema_version"] = True
self.assertTrue(any("schema_version" in e for e in validate(data)))
def test_duplicate_identifier(self):
data = copy.deepcopy(BASE)
row = copy.deepcopy(data["versions"][0])
row["file"] = "drafts/another.wav"
data["versions"].append(row)
self.assertTrue(any("duplicate identifier" in e for e in validate(data)))
def test_duplicate_casefolded_path(self):
data = copy.deepcopy(BASE)
row = copy.deepcopy(data["versions"][0])
row.update(id="sketch-02", file="DRAFTS/LANTERN-V01.WAV")
data["versions"].append(row)
self.assertTrue(any("duplicate case-folded path" in e for e in validate(data)))
def test_unknown_field(self):
data = copy.deepcopy(BASE)
data["versions"][0]["statuss"] = "approved"
self.assertTrue(any("unknown fields statuss" in e for e in validate(data)))
def test_path_boundaries(self):
for path in ["../a.wav", "/tmp/a.wav", "C:\\tmp\\a.wav", "drafts//a.wav",
"https://example.invalid/a.wav", "drafts/\0.wav", " drafts/a.wav",
"drafts/./a.wav"]:
with self.subTest(path=repr(path)):
data = copy.deepcopy(BASE)
data["versions"][0]["file"] = path
self.assertTrue(any("portable relative path" in e for e in validate(data)))
def test_approval_needs_recorded_note(self):
data = copy.deepcopy(BASE)
data["versions"][0]["status"] = "approved"
self.assertTrue(any("approved requires" in e for e in validate(data)))
data["versions"][0]["permission"] = "recorded"
self.assertTrue(any("recorded requires a note" in e for e in validate(data)))
data["versions"][0]["permission_note"] = "Example reference only, for named internal comparison"
self.assertEqual(validate(data), [])
def test_malformed_shapes(self):
for data in [None, [], {"schema_version": 1, "project": "x", "versions": []},
{"schema_version": 1, "project": "x", "versions": [None]}]:
with self.subTest(data=data):
self.assertTrue(validate(data))
def test_unhashable_enum_values_report_errors(self):
data = copy.deepcopy(BASE)
data["versions"][0].update(status=[], permission={})
self.assertTrue(validate(data))
if __name__ == "__main__":
unittest.main()
Save the implementation as beatmuse_manifest_lint.py and the tests as test_beatmuse_manifest_lint.py in the same directory, then run python test_beatmuse_manifest_lint.py -v. The local run for this article passed nine test methods. That result describes this fixture set only. It is not a proof that the function handles every possible input or that it is ready for an unreviewed production deployment. More tests would be appropriate before accepting unusually large documents, exposing an upload endpoint, or supporting additional schema versions.
Where a song sketch fits into this workflow
A generation tool can provide something to evaluate, but it should not become the source of approval metadata by implication. BeatMuse's AI Song Generator can turn text ideas or lyrics into vocal songs and instrumentals in the browser. New users receive limited free welcome credits, not unlimited free generation. If someone chooses to explore a draft there, the handoff record described here would still be created and reviewed separately. This article does not claim that BeatMuse exports this JSON, provides a matching API, or automatically supplies permission records.
A practical adoption path is to keep the manifest beside the team's existing notes, run the validator locally, and repair any structural errors before sharing the handoff. Keep sensitive source material out of the example record and do not publish private notes as part of a debugging report. If the format becomes useful, write down how its fields are interpreted and who may change them. The valuable outcome is a clearer conversation about versions and decisions, not a green check mark that substitutes for listening, review, or permission.
Top comments (0)