mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-15 20:05:13 +02:00
[pitboss/grind] deferred session-0015 (20260520T233019Z-6958)
This commit is contained in:
parent
ba0f83a855
commit
1e122b615e
5 changed files with 128 additions and 19 deletions
|
|
@ -1101,6 +1101,7 @@ fn generate_go_mod() -> String {
|
|||
fn emit_class_method_harness(class: &str, method: &str) -> HarnessSource {
|
||||
let shim = probe_shim();
|
||||
let go_mod = generate_go_mod();
|
||||
let auto_registry = generate_auto_receiver_registry(class);
|
||||
let source = format!(
|
||||
r##"// Nyx dynamic harness — class method (Phase 19 / Track M.1).
|
||||
package main
|
||||
|
|
@ -1118,9 +1119,13 @@ import (
|
|||
func nyxBuildReceiver(structName string) (reflect.Value, error) {{
|
||||
// Look up the exported type by name on the entry package. Go's
|
||||
// reflect API does not expose package-level reflection over types
|
||||
// directly, so the dispatcher uses the package's well-known
|
||||
// `NyxReceivers` registry the entry file is expected to publish.
|
||||
if r, ok := entry.NyxReceivers[structName]; ok {{
|
||||
// directly, so the dispatcher uses a generated `NyxAutoReceivers`
|
||||
// registry that the harness ships into the entry package at
|
||||
// compile time (see `entry/nyx_auto_registry.go`). Real-world
|
||||
// projects under test never need to hand-declare the registry —
|
||||
// the auto-generated file references the target type by name and
|
||||
// the Go compiler enforces the contract.
|
||||
if r, ok := entry.NyxAutoReceivers[structName]; ok {{
|
||||
return reflect.ValueOf(r), nil
|
||||
}}
|
||||
return reflect.Value{{}}, fmt.Errorf("class not found: %s", structName)
|
||||
|
|
@ -1180,11 +1185,40 @@ func main() {{
|
|||
source,
|
||||
filename: "main.go".to_owned(),
|
||||
command: vec!["./nyx_harness".to_owned()],
|
||||
extra_files: vec![("go.mod".to_owned(), go_mod)],
|
||||
extra_files: vec![
|
||||
("go.mod".to_owned(), go_mod),
|
||||
(
|
||||
"entry/nyx_auto_registry.go".to_owned(),
|
||||
auto_registry,
|
||||
),
|
||||
],
|
||||
entry_subpath: Some("entry/entry.go".to_owned()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate an `entry/nyx_auto_registry.go` source that publishes a
|
||||
/// `NyxAutoReceivers` map keyed by the target class name to a
|
||||
/// zero-constructed instance. The generated file lives in package
|
||||
/// `entry` so it can reference `class` by bare identifier without
|
||||
/// re-exporting through the harness package. Compile-time enforcement
|
||||
/// of the contract is delegated to the Go compiler — if the entry
|
||||
/// package does not declare `class`, the build fails with a clear
|
||||
/// `undefined: <class>` error.
|
||||
fn generate_auto_receiver_registry(class: &str) -> String {
|
||||
format!(
|
||||
r##"// Code generated by Nyx — DO NOT EDIT.
|
||||
package entry
|
||||
|
||||
// NyxAutoReceivers maps a class name to a zero-constructed instance
|
||||
// the dynamic harness uses to reflect on methods at runtime.
|
||||
var NyxAutoReceivers = map[string]interface{{}}{{
|
||||
"{class}": {class}{{}},
|
||||
}}
|
||||
"##,
|
||||
class = class,
|
||||
)
|
||||
}
|
||||
|
||||
/// Phase 20 (Track M.2) — message-handler harness for Go.
|
||||
///
|
||||
/// The entry package is expected to declare a top-level handler
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue