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
Add refactoring alternative to Alternatives Considered
Add Alternative 2 covering Go code refactoring as a competing approach.
Acknowledge its value while noting it doesn't address configurability
or cross-cutting concerns. Include AI-driven development observation.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: rfcs/THV-0060-starlark-programmable-middleware.md
+11-3Lines changed: 11 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -576,21 +576,29 @@ Scripts have no access to secrets. Backend authentication is handled below the s
576
576
-**Cons**: Interaction matrix grows quadratically. Bugs like #4287 from non-obvious interactions. Testing becomes intractable.
577
577
-**Why not chosen**: Already causing problems at current feature count.
578
578
579
-
#### Alternative 2: Declarative pipeline (ordered stages)
579
+
#### Alternative 2: Refactor the existing Go code
580
+
581
+
Invest in better code organization — clearer interfaces between features, a well-defined internal pipeline, better test coverage for combinations.
582
+
583
+
-**Pros**: No new language or dependency. Directly improves code quality and maintainability.
584
+
-**Cons**: Addresses maintainability but not configurability — every new behavior still requires a code change and release. Code organization works best when concerns have clean boundaries, but vMCP's concerns are cross-cutting: the optimizer rewrites tool names that authorization policies reference, rate limiting must track names after conflict resolution, and an elicitation gate needs annotations that aggregation doesn't surface. These concerns cut across module boundaries rather than fitting neatly within them. Additionally, with AI-driven development, code quality in a complex, cross-cutting codebase is harder to police. A model where new capabilities ship as isolated built-in functions is more resistant to quality erosion — each built-in has a single, self-contained implementation.
585
+
-**Why not chosen**: Refactoring is valuable and should continue regardless, but it doesn't address the configurability gap. Administrators who need deployment-specific policies are still waiting for ToolHive to build them.
586
+
587
+
#### Alternative 3: Declarative pipeline (ordered stages)
580
588
581
589
Instead of a scripting language, make the config ordering explicit — a pipeline of named stages (like Envoy filter chains or Traefik middleware stacks).
582
590
583
591
-**Pros**: Declarative, no scripting language to learn, explicit ordering solves the interaction problem.
584
592
-**Cons**: A declarative pipeline can express ordering and filtering, but cannot express computed values (dynamic descriptions based on available tools), conditional logic (different behavior based on annotations), or new synthetic tools (a `find_tool` with a generated description). Every new behavior still requires a new stage type implemented in Go.
585
593
-**Why not chosen**: The problem isn't just ordering — it's that administrators need to express logic that varies per deployment. A pipeline makes ordering explicit but keeps the "new knob per behavior" problem.
586
594
587
-
#### Alternative 3: Starlark for composite tools only (THV-0051 as-is)
595
+
#### Alternative 4: Starlark for composite tools only (THV-0051 as-is)
588
596
589
597
-**Pros**: Smaller scope
590
598
-**Cons**: Misses the opportunity to unify. Interaction problem remains for optimizer + filter + rate limiting. Expanding scope later means a second migration.
591
599
-**Why not chosen**: Design for the broader use case from day one.
592
600
593
-
#### Alternative 4: Use webhooks for everything
601
+
#### Alternative 5: Use webhooks for everything
594
602
595
603
-**Pros**: Maximum flexibility, language-agnostic
596
604
-**Cons**: External services for simple policies. Network latency on every call. Overkill for "hide these tools."
0 commit comments