You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* refactor(platform): tighten EvaluatorResponse — ExecTime, ScriptExeID, AsMap
Three breaking changes to the platform.EvaluatorResponse interface:
1. GetScriptExeID() string → ScriptExeID() string (drop Get prefix)
2. GetExecTime() string → ExecTime() time.Duration (no longer stringified
at the boundary; implementations already stored time.Duration internally)
3. New AsMap() (map[string]any, error) — returns the result as a typed map,
with an error of the form "AsMap: expected map[string]any, got <T>" when
the underlying value has a different shape
Migrates 40+ existing `result.Interface().(map[string]any); require.True(t, ok)`
test sites to `result.AsMap(); require.NoError(t, err)`, which validates the
helper's value. Other typed accessors (AsString, AsBool, AsInt, AsSlice) are
not added — they have zero current usage and YAGNI applies.
Updates the three implementations (extism, risor, starlark) and all consuming
tests/mocks (platform/mocks_test.go, polyscript_mocks_test.go,
engines/integration_test.go, readme_test.go, polyscript_*_test.go).
Closes#86.
https://claude.ai/code/session_01C61VEAmjxSnX5Xhbab8NvL
* test(evaluator): cover AsMap error paths in all three engines
SonarQube reported 30% coverage on new code (required ≥80%) because
the AsMap() error branch (non-map underlying value) was unexercised.
The 40+ migrated test sites cover only the success path.
Adds TestExecResultAsMap to each engine's response_test.go with three
subtests:
- success: underlying value is a real map
- error on string: returns the typed error message
- error on nil/int: confirms the %T format string reports the actual type
Per-package coverage after these tests:
- extism/evaluator: 96.2%
- risor/evaluator: 90.8%
- starlark/evaluator: 83.5%
https://claude.ai/code/session_01C61VEAmjxSnX5Xhbab8NvL
* test(mocks): harden mockEvaluatorResponse.AsMap type-assertion
Per Copilot review on #141 — the mock previously discarded the type
assertion result and could return (nil, nil) when a test author
configured a non-map Return value, silently diverging from the real
AsMap contract.
The mock now:
- Returns (nil, nil) only when explicitly configured with nil + nil
- Returns the configured error when the asserted value isn't a map but
an error was provided
- Synthesizes the production error format ("AsMap: expected
map[string]any, got %T") when the asserted value isn't a map and no
error was provided
Applies to both platform/mocks_test.go and polyscript_mocks_test.go.
https://claude.ai/code/session_01C61VEAmjxSnX5Xhbab8NvL
* refactor(evaluator): introduce per-engine ErrAsMapTypeMismatch sentinels
Replaces the inline `fmt.Errorf("AsMap: expected map[string]any, got %T", v)`
with a wrapped sentinel in each engine's evaluator package:
- engines/extism/evaluator.ErrAsMapTypeMismatch
= "extism: AsMap expected map[string]any"
- engines/risor/evaluator.ErrAsMapTypeMismatch
= "risor: AsMap expected map[string]any"
- engines/starlark/evaluator.ErrAsMapTypeMismatch
= "starlark: AsMap expected map[string]any"
Each AsMap now returns `fmt.Errorf("%w, got %T", ErrAsMapTypeMismatch, v)`,
so callers can `errors.Is(err, evaluator.ErrAsMapTypeMismatch)` for the
type-mismatch case and still read the concrete Go type from err.Error().
Matches the existing per-package sentinel pattern in
engines/{extism,risor,starlark}/compiler/errors.go.
Tests switched from substring assertions on the full message to
require.ErrorIs(t, err, ErrAsMapTypeMismatch) + a smaller substring
assertion on just the "got <T>" tail.
https://claude.ai/code/session_01C61VEAmjxSnX5Xhbab8NvL
* docs(changelog): trim Unreleased entries to match project's terse style
Earlier entries (v0.6.0, v0.7.0) keep each item to 1–3 lines of plain
facts. The recent additions ballooned into multi-paragraph descriptions
with nested bullets and editorial commentary. This brings them back into
the established style: 1–3 lines per item, **BREAKING** matching the
existing prefix capitalization, just the trailing PR link for traceability.
Net change: -41 lines, +20 lines.
https://claude.ai/code/session_01C61VEAmjxSnX5Xhbab8NvL
---------
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments