mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-09 19:45:13 +02:00
[pitboss] phase 03: Track A.3 — LangEmitter::entry_kinds_supported + actionable Inconclusive hints
This commit is contained in:
parent
8211d4fd47
commit
364d09d6a8
16 changed files with 830 additions and 35 deletions
|
|
@ -13,10 +13,35 @@
|
|||
//! - `PayloadSlot::EnvVar(name)` — set env var before calling.
|
||||
//! - Other slots produce `UnsupportedReason::EntryKindUnsupported`.
|
||||
|
||||
use crate::dynamic::lang::HarnessSource;
|
||||
use crate::dynamic::spec::{HarnessSpec, PayloadSlot};
|
||||
use crate::dynamic::lang::{HarnessSource, LangEmitter};
|
||||
use crate::dynamic::spec::{EntryKind, HarnessSpec, PayloadSlot};
|
||||
use crate::evidence::UnsupportedReason;
|
||||
|
||||
/// Zero-sized [`LangEmitter`] handle for Python. Registered in the
|
||||
/// `lang::dispatch` table; method bodies delegate to the existing free
|
||||
/// functions in this module.
|
||||
pub struct PythonEmitter;
|
||||
|
||||
/// Entry kinds the Python emitter currently understands. Extended in Phase 12
|
||||
/// (Track B Python vertical) to include `HttpRoute`, `CliSubcommand`, etc.
|
||||
const SUPPORTED: &[EntryKind] = &[EntryKind::Function];
|
||||
|
||||
impl LangEmitter for PythonEmitter {
|
||||
fn emit(&self, spec: &HarnessSpec) -> Result<HarnessSource, UnsupportedReason> {
|
||||
emit(spec)
|
||||
}
|
||||
|
||||
fn entry_kinds_supported(&self) -> &'static [EntryKind] {
|
||||
SUPPORTED
|
||||
}
|
||||
|
||||
fn entry_kind_hint(&self, attempted: EntryKind) -> String {
|
||||
format!(
|
||||
"python emitter supports {SUPPORTED:?}; this finding's enclosing context is `EntryKind::{attempted}` — Track B will add framework + CLI shapes in phase 12"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Emit a Python harness for `spec`.
|
||||
pub fn emit(spec: &HarnessSpec) -> Result<HarnessSource, UnsupportedReason> {
|
||||
// Validate payload slot.
|
||||
|
|
@ -237,6 +262,21 @@ mod tests {
|
|||
assert_eq!(module_name("no_ext"), "no_ext");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn entry_kinds_supported_is_non_empty() {
|
||||
assert!(!PythonEmitter.entry_kinds_supported().is_empty());
|
||||
assert!(PythonEmitter
|
||||
.entry_kinds_supported()
|
||||
.contains(&EntryKind::Function));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn entry_kind_hint_names_attempted_and_phase() {
|
||||
let hint = PythonEmitter.entry_kind_hint(EntryKind::HttpRoute);
|
||||
assert!(hint.contains("HttpRoute"));
|
||||
assert!(hint.contains("phase 12"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unsupported_lang_returns_err() {
|
||||
let mut spec = make_spec(PayloadSlot::Param(0));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue