fix(build-gate): resolve commands by toolchain (#40)
This commit is contained in:
@@ -16,6 +16,7 @@ CORREX kernel team.
|
||||
- `ArtifactState` rebuilt from events via `DefaultArtifactReducer` (in `core:events` `ArtifactEvents.kt`) + `ArtifactProjector`.
|
||||
- `TypedArtifactSlot<T>` — typed accessor for well-known artifact slots.
|
||||
- `ArtifactSerializationModule` — registers artifact polymorphic types; must be included in serialization setup.
|
||||
- `KindContractTable.toolchainFor` maps checked-in Node and JVM kinds to the execution-gate command namespace.
|
||||
- Hard Invariant #1: artifact state is always rebuilt from events. `ArtifactRepository` wraps `EventReplayer<ArtifactState>`.
|
||||
|
||||
## Work Guidance
|
||||
|
||||
@@ -18,6 +18,12 @@ package com.correx.core.artifacts.kind
|
||||
*/
|
||||
object KindContractTable {
|
||||
|
||||
/** Toolchain selected by the build gate for a produced source or manifest kind. */
|
||||
enum class Toolchain(val profileKey: String) {
|
||||
NODE("node"),
|
||||
JVM("jvm"),
|
||||
}
|
||||
|
||||
/** A single assertion template — a kind's requirement before it is bound to a concrete path. */
|
||||
private data class Template(
|
||||
val id: String,
|
||||
@@ -133,6 +139,9 @@ object KindContractTable {
|
||||
|
||||
private val CHECKED_IN: Map<String, List<Template>> = TS_REACT + KOTLIN + GENERIC
|
||||
|
||||
private val TOOLCHAINS = TS_REACT.keys.associateWith { Toolchain.NODE } +
|
||||
KOTLIN.keys.associateWith { Toolchain.JVM }
|
||||
|
||||
/** Project-supplied additive overrides, keyed by kind id. Set at wiring time; empty by default. */
|
||||
@Volatile
|
||||
var projectOverrides: Map<String, List<ContractAssertion>> = emptyMap()
|
||||
@@ -157,5 +166,8 @@ object KindContractTable {
|
||||
return (base + overrides).filterNot { it.id == "file_nonempty" && isDotfile(path) }
|
||||
}
|
||||
|
||||
/** The build toolchain implied by a checked-in kind, or null for stack-neutral kinds. */
|
||||
fun toolchainFor(kindId: String): Toolchain? = TOOLCHAINS[kindId]
|
||||
|
||||
private fun isDotfile(path: String): Boolean = path.substringAfterLast('/').startsWith(".")
|
||||
}
|
||||
|
||||
@@ -101,4 +101,13 @@ class KindContractTableTest {
|
||||
assertTrue("contains" in ids, "override assertion must be appended")
|
||||
assertTrue("file_nonempty" in ids, "checked-in assertions remain")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `toolchain follows checked in source and manifest kinds`() {
|
||||
assertEquals(KindContractTable.Toolchain.NODE, KindContractTable.toolchainFor("react_entry"))
|
||||
assertEquals(KindContractTable.Toolchain.NODE, KindContractTable.toolchainFor("package_json"))
|
||||
assertEquals(KindContractTable.Toolchain.JVM, KindContractTable.toolchainFor("kotlin_service"))
|
||||
assertEquals(KindContractTable.Toolchain.JVM, KindContractTable.toolchainFor("gradle_module"))
|
||||
assertEquals(null, KindContractTable.toolchainFor("docs"))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user