Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ python scripts/mcsource.py prepare --jar .local/inputs/client.jar --project /pat

`verify` compares the local SHA-1 and byte size against Mojang's official client metadata over HTTPS, without downloading Minecraft. It reports `verified`, `mismatch`, or `unverified`; network errors never count as success. `prepare --verify-official` requires a verified result before tool downloads or source generation and stores the verification evidence. See [official verification](docs/OFFICIAL_VERIFICATION.md).

`check-project` compares supported static version declarations with the input JAR and prints evidence as JSON. It never runs Gradle or writes to the mod project. See [project checks](docs/PROJECT_CHECKS.md) for the supported syntax and limitations. A matching declaration is not proof of effective build configuration or API compatibility.
`check-project` compares supported static version declarations with the input JAR and prints evidence as JSON. It never runs Gradle or writes to the mod project. See [project checks](docs/PROJECT_CHECKS.md) for the supported syntax and limitations. Mapping hints and their file/line evidence appear under `namespace_review`. Unsupported or multiple mapping hints require review and block project preparation/binding. A matching declaration is not proof of effective build configuration or API compatibility.

`prepare --project` blocks unknown, conflicting, or mismatching declarations before downloading tools or creating an output directory. It records a matching declaration report in the reference identity. This optional version gate does not replace the agent's namespace review. Omitting `--project` keeps standalone source preparation available.

Expand Down
2 changes: 1 addition & 1 deletion docs/AGENT_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
1. Identify the target mod project and the user-supplied Minecraft JAR. Ask only for missing paths. Read the project's own instructions first.
2. Inspect only build configuration needed to identify the exact Minecraft version, loader, Java requirements, and mapping namespace. Do not infer values you cannot resolve.
3. Run `check-project --jar <jar> --project <mod directory>` from the kit root. On `version_mismatch`, stop and request the correct input. On `needs_review`, inspect the evidence and resolve the actual target manually; never treat unknown as compatible. On `declared_version_match`, still check the effective configuration and namespace: this is a bounded declaration check, not Gradle evaluation. Review project instructions and any known property overrides. Use `inspect` for standalone JAR metadata and bytecode. For a claimed official client JAR, use `verify --jar <jar>` for standalone provenance diagnostics, or enforce verification during preparation as described below. A successful project check alone does not verify provenance.
4. Check the namespace explicitly. Old obfuscated JARs need matching mappings; this first version cannot remap them. Do not treat raw obfuscated output as matching a named project. Do not silently substitute another Minecraft version.
4. Inspect `namespace_review` and its file/line evidence. Yarn, Intermediary, Parchment, multiple mapping hints, unsupported source labels, or a known unnamed input require review and block project preparation/binding. Do not bypass these warnings with standalone preparation or a hand-edited binding. Check the namespace explicitly. Old obfuscated JARs need matching mappings; this first version cannot remap them. Do not treat raw obfuscated output as matching a named project. Do not silently substitute another Minecraft version.
5. Run `prepare --jar <jar> --project <mod directory> --verify-official --repair` only after the effective target and namespace have been reviewed. The project option adds a version gate and stores its evidence. Official verification requires matching client SHA-1 and size from Mojang metadata. If verification is unavailable, report the reason and stop; do not silently drop the flag. An explicitly requested offline or modified-JAR workflow may use standalone preparation without the flag, with provenance left unverified. A known fingerprint mismatch must be resolved or explicitly identified as a modified input before proceeding. If the static parser cannot handle a project, explain the limitation and verify the actual target with the agent before using standalone `prepare`; do not bypass an unresolved mismatch. It builds the pinned CFR tool and creates a new output directory without modifying the target project.
6. Inspect `REFERENCE.json`, the CFR summary, and a few relevant source files. Report incomplete methods. Verify affected behavior against `javap` or a second official decompiler before relying on it. With `--repair`, reported CFR classes receive one conservative Vineflower attempt. Inspect the `fallback` record; `recovered_unverified` is not a correctness guarantee. If unresolved, stop relying on affected methods. For an existing kit reference use `repair --jar <same jar> --reference <directory>`; it checks the original SHA-256. Do not delete attempt records or retry automatically.
7. Keep diagnostics and original-source backups. Successful recovery removes only its temporary class/output workspace. On failure, preserve it for diagnosis. Do not delete the repository, input JAR, tool cache, or source reference as setup cleanup.
Expand Down
4 changes: 2 additions & 2 deletions docs/PROJECT_BINDINGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Quote paths containing spaces. Neither command requires the original JAR, Java,

## Creating a binding

The reference must be inside this kit's `.local/references/`, have a valid completed identity (`generated_unverified`), contain the recorded number of Java files, and have no known source failure markers. Unresolved/failed references and marked validation fixtures cannot be bound. Supported project version declarations must match the reference version; unsupported builds still need a supported resolution workflow rather than a guessed binding.
The reference must be inside this kit's `.local/references/`, have a valid completed identity (`generated_unverified`), contain the recorded number of Java files, and have no known source failure markers. Unresolved/failed references and marked validation fixtures cannot be bound. Supported project version declarations must match the reference version and pass the namespace review gates; unsupported builds still need a supported resolution workflow rather than a guessed binding.

A file under `.local/bindings/` is keyed by the canonical project path. It stores:

Expand All @@ -31,7 +31,7 @@ The snapshot detects changes after binding. It does not authenticate sources aga
- `stale` (exit 2): inspected configuration, source identity, or active sources changed or became unavailable. The result includes reasons and deliberately omits the source-use instruction.
- Invalid inputs or malformed binding files produce a diagnostic and exit 1.

`resolve` is read-only. It never repairs, rebinds, downloads, runs builds, or substitutes another source version. Its configuration scope is the same bounded root-file inspection documented in PROJECT_CHECKS.md. External Gradle overrides are not detected. Changes to the kit's own parser may also require review.
`resolve` is read-only. It never repairs, rebinds, downloads, runs builds, or substitutes another source version. Its configuration scope is the same bounded root-file inspection documented in PROJECT_CHECKS.md. Current project/reference checks, including namespace review gates, are re-run even for older bindings. External Gradle overrides are not detected. Changes to the kit's own parser may also require review.

A coding agent still needs to know where this kit is. Bindings do not register themselves with Codex or other agents, and do not make external instructions load automatically. Give the agent the kit path, or manually add the returned instruction to the mod project's existing instructions. The kit does not write that instruction for you.

Expand Down
15 changes: 14 additions & 1 deletion docs/PROJECT_CHECKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Duplicate properties, conflicting versions, version ranges, unresolved expressio

- `declared_version_match` (exit 0): supported declarations agree with the JAR's version label. This is not an API compatibility approval.
- `version_mismatch` (exit 1): the supported unambiguous declarations name another version. Stop setup with this JAR.
- `needs_review` (exit 2): the static checker cannot establish a single target. Read `issues` and resolve the actual configuration before proceeding.
- `needs_review` (exit 2): the static checker cannot establish a single target, or namespace review gates block use. Read project `issues` and `namespace_review.reasons`, then resolve the actual configuration before proceeding.
- Invalid input produces an error diagnostic and exit 1.

The JSON report includes the source file and line for version declarations, configuration file SHA-256 values, and mapping/loader hints. Values are not inferred from installed caches or remembered version conventions. Only relevant declaration evidence is included, not complete build files.
Expand All @@ -38,3 +38,16 @@ The JAR's namespace and provenance remain unverified by this command. A version
## Validation boundary

Automated coverage uses small synthetic mod configurations and JARs. An integration smoke check used the local 26.2 JAR with matching 26.2 and mismatching 26.1 synthetic mod configurations; both statuses and project-file preservation were verified. This does not establish support for a real user's entire Gradle build. Real-project validation remains an acceptance gate.

## Namespace review gates

The report now includes `namespace_review` with static mapping hints, file/line evidence, source labels, reasons, and a `blocking` flag. No positive namespace-compatibility result is produced.

- Yarn, Intermediary, and Parchment hints require review because this kit does not perform the required mapping transformations.
- Multiple mapping hints require review. This may describe a legitimate layered configuration; it is not automatically diagnosed as a broken build.
- Explicit unsupported source namespace labels or a known absence of the expected named client class also require review.
- A version mismatch remains `version_mismatch` even when namespace warnings are present. Otherwise blocking namespace reasons produce `needs_review` (exit 2).

`prepare --project` and `bind` stop on that result before generating sources or writing bindings. `resolve` re-runs the current checks even for bindings created by an earlier kit; blocked old bindings become `stale` without a source-use instruction.

An official Mojang mapping hint or absence of explicit mappings does not establish compatibility: the namespace result remains `unverified`. The checker is bounded static analysis; unrecognized custom mappings, plugins, catalogs, or external overrides may not produce a hint. An agent must still inspect the effective configuration. Ordinary comments and Parchment repository URLs alone are not mapping declarations. Do not bypass mapping warnings by omitting `--project` or editing a binding by hand.
6 changes: 5 additions & 1 deletion docs/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

## Next acceptance gates

- Resolve project namespace compatibility beyond matching static version declarations and textual mapping hints.
- Expand namespace evidence beyond static review gates; full mapping resolution/conversion remains unsupported.
- Validate additional Minecraft versions and real-project mismatch cases; the 26.2 read-only matching/binding workflow is documented in VALIDATION.md.
- Compare representative API tasks with and without the kit.
- Add preview-based, user-requested cache cleanup after the preparation workflow stabilizes; never remove active references or user inputs implicitly.
Expand Down Expand Up @@ -46,3 +46,7 @@ A local smoke check paired the full 7,055-file 26.2 source reference with a synt
## Real-project validation

A user-supplied Fabric mod targeting 26.2 passed read-only declaration checks and temporary binding/resolution against the full reference. Two sampled Minecraft API signatures matched. Project Git state and root configuration hashes were preserved; temporary validation data was cleaned. See [validation results](VALIDATION.md) for scope and limits. No mod build or in-game validation was performed.

## Namespace review gates

Static mapping evidence now blocks unsupported Yarn/Intermediary/Parchment, multiple hints, unsupported source labels, and known unnamed inputs at project preparation and binding. Resolution rechecks older bindings with the current gates. This is conservative review routing, not proof of compatibility or an automatic mapping converter.
12 changes: 6 additions & 6 deletions scripts/project_binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ def resolve_project(root, project):
saved_check = binding.get("project_check")
if not isinstance(saved_check, dict) or saved_check.get("status") != "declared_version_match" or not isinstance(saved_check.get("project"), dict):
raise ValueError("Binding has no project configuration snapshot")
current = inspect_project(project)
if current["issues"] or current["declared_minecraft_version"] != saved_check["project"].get("declared_minecraft_version"):
reasons.append("project_target_needs_review")
if current["configuration_files"] != saved_check["project"].get("configuration_files"):
reasons.append("project_configuration_changed")
try:
reference, identity, record_hash = read_reference(root, root / binding["reference"])
fresh_check = check_project(project, identity)
if fresh_check["status"] != "declared_version_match":
reasons.append("project_reference_review_required")
if fresh_check["project"]["configuration_files"] != saved_check["project"].get("configuration_files"):
reasons.append("project_configuration_changed")
if record_hash != binding.get("reference_identity_sha256"):
reasons.append("reference_identity_changed")
elif not reasons and source_snapshot(reference) != binding.get("source_snapshot"):
Expand All @@ -129,4 +129,4 @@ def resolve_project(root, project):
reference = None
if reasons:
return {"status": "stale", "project_path": str(project), "reasons": reasons, "review_required": True}
return {"status": "located_unverified", "binding_file": str(target), "reference": str(reference), "project_check": saved_check, "review_required": True, "instruction": instruction(root, project, reference)}
return {"status": "located_unverified", "binding_file": str(target), "reference": str(reference), "project_check": fresh_check, "review_required": True, "instruction": instruction(root, project, reference)}
43 changes: 36 additions & 7 deletions scripts/project_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def inspect_project(path):
properties = {}
versions = []
mapping_hints = set()
mapping_evidence = []
loader_hints = set()
files = []
builds = []
Expand Down Expand Up @@ -68,12 +69,15 @@ def inspect_project(path):
loader_hints.add("neoforge")
if "net.minecraftforge" in text:
loader_hints.add("forge")
if "officialMojangMappings" in text:
mapping_hints.add("mojang")
if "net.fabricmc:yarn:" in text:
mapping_hints.add("yarn")
if "parchment" in text.lower():
mapping_hints.add("parchment")
for hint, pattern in (
("mojang", r"\bofficialMojangMappings\s*\("),
("yarn", r"net\.fabricmc:yarn:"),
("intermediary", r"net\.fabricmc:intermediary:"),
("parchment", r"org\.parchmentmc(?:\.data)?:|\bparchment\s*\("),
):
for match in re.finditer(pattern, text):
mapping_hints.add(hint)
mapping_evidence.append({"file": name, "line": text.count("\n", 0, match.start()) + 1, "hint": hint})
for match in COORDINATE.finditer(text):
dependency_found = True
quote, coordinate = match.groups()
Expand All @@ -99,23 +103,48 @@ def inspect_project(path):
"project_path": str(root), "configuration_files": files,
"declared_minecraft_version": exact[0] if len(exact) == 1 and not issues else None,
"version_candidates": exact, "evidence": evidence, "issues": issues,
"mapping_hints": sorted(mapping_hints), "loader_hints": sorted(loader_hints),
"mapping_hints": sorted(mapping_hints), "mapping_evidence": mapping_evidence, "loader_hints": sorted(loader_hints),
"inspection": "static_declarations_only",
}


def namespace_review(project, identity):
"""Conservative gates from static hints, never a namespace compatibility proof."""
hints = project["mapping_hints"]
reasons = []
if len(hints) > 1:
reasons.append("multiple_mapping_hints_require_review")
if any(hint != "mojang" for hint in hints):
reasons.append("mapping_transformation_not_supported")
if identity.get("namespace", "unverified") not in ("unverified", "mojang"):
reasons.append("source_namespace_not_supported")
if identity.get("named_client_class_present") is False:
reasons.append("named_client_source_not_established")
return {
"status": "needs_review" if reasons else "unverified",
"blocking": bool(reasons), "reasons": reasons,
"project_hints": hints, "evidence": project["mapping_evidence"],
"source_namespace": identity.get("namespace", "unverified"),
"named_client_class_present": identity.get("named_client_class_present"),
}


def check_project(path, jar_identity):
project = inspect_project(path)
declared = project["declared_minecraft_version"]
namespace = namespace_review(project, jar_identity)
if declared is None:
status = "needs_review"
elif declared != jar_identity["minecraft_version"]:
status = "version_mismatch"
elif namespace["blocking"]:
status = "needs_review"
else:
status = "declared_version_match"
return {
"schema_version": 1, "status": status, "project": project,
"jar": {key: jar_identity[key] for key in ("minecraft_version", "sha256", "namespace", "provenance", "scope")},
"namespace_review": namespace,
"api_compatibility": "unverified",
"review_required": True,
"limitations": [
Expand Down
22 changes: 22 additions & 0 deletions tests/test_project_binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,28 @@ def test_project_change_during_binding_is_rejected(self):
self.bind()
self.assertFalse((self.kit / ".local/bindings").exists())

def test_mapping_review_blocks_binding_without_writing(self):
with (self.project / "build.gradle").open("a") as stream:
stream.write('\nmappings "net.fabricmc:yarn:26.2+build.1:v2"\n')
with self.assertRaisesRegex(ValueError, "matching supported"):
self.bind()
self.assertFalse((self.kit / ".local/bindings").exists())

def test_legacy_binding_is_rechecked_against_current_mapping_gates(self):
first = self.bind()
with (self.project / "build.gradle").open("a") as stream:
stream.write('\nmappings "net.fabricmc:yarn:26.2+build.1:v2"\n')
target = Path(first["binding_file"])
legacy = json.loads(target.read_text())
# Simulate an earlier kit accepting the same unchanged Yarn configuration.
legacy["project_check"]["project"] = binding.inspect_project(self.project)
target.write_text(json.dumps(legacy), encoding="utf-8")
report = self.resolve()
self.assertEqual(report["status"], "stale")
self.assertIn("project_reference_review_required", report["reasons"])
self.assertNotIn("project_configuration_changed", report["reasons"])
self.assertNotIn("instruction", report)

def test_cli_resolve_missing_binding(self):
result = subprocess.run([sys.executable, str(SCRIPTS / "mcsource.py"), "resolve", "--project", str(self.project)], capture_output=True, text=True)
self.assertEqual(result.returncode, 2)
Expand Down
Loading
Loading