carlos / platform Public

console: declare apidemooperator.go routes in routeDecls

The four demo operator doors become declarations under gateNoHostClaim,
the early return registerDemoOperatorRoutes made on a host-claim
console. registerDemoOperatorRoutes shrinks to a registerDecls call over
that gate for the protections test, and registerCLIRoutes no longer
calls it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev a9c7d7a576d7d31c7b41fbf4be642f899993fb2f parent d261a11
3 files changed, +11 −9
  • internal/console/apidemooperator.go +4 −8
  • internal/console/authcli.go +0 −1
  • internal/console/routedecls.go +7 −0

Intent

Human

<task-notification> <task-id>b8irxa405</task-id> <summary>Monitor event: "Task 2 commits landing on design-parity-guard"</summary> <event>d261a11e console: declare apidemoreports.go routes in routeDecls</event> </task-notification>

diff --git a/internal/console/apidemooperator.go b/internal/console/apidemooperator.go
index c8e95873f..5e8e56377 100644
--- a/internal/console/apidemooperator.go
+++ b/internal/console/apidemooperator.go
@@ -10,17 +10,13 @@ import (
"time"
"github.com/carlosframework/platform/internal/demobuild"
- "github.com/carlosframework/platform/internal/svcrole"
)
+// registerDemoOperatorRoutes registers the gateNoHostClaim declarations
+// again, for the test that adds them to a server built without them.
+// Removed once that test calls registerDecls itself.
func (s *Server) registerDemoOperatorRoutes() {
- if s.cfg.HostClaim {
- return
- }
- s.cliRoute("GET /api/cli/system/demos", svcrole.Set{}, s.handleAPIDemosStatus)
- s.cliRoute("PUT /api/cli/system/demos/serving", svcrole.Set{}, s.handleAPIDemosServing)
- s.cliRoute("POST /api/cli/system/demos/takedown", svcrole.Set{}, s.handleAPIDemosTakedown)
- s.cliRoute("GET /api/cli/system/demos/takedown", svcrole.Set{}, s.handleAPIDemosTakedownStatus)
+ s.registerDecls(func(d routeDecl) bool { return d.Gate == gateNoHostClaim })
}
func (s *Server) demoOperator(w http.ResponseWriter, r *http.Request) (string, bool) {
actor, _, ok := s.apiSystemRoller(w, r)
diff --git a/internal/console/authcli.go b/internal/console/authcli.go
index 9437f601c..65100668b 100644
--- a/internal/console/authcli.go
+++ b/internal/console/authcli.go
@@ -546,7 +546,6 @@ func (s *Server) registerCLIRoutes() {
// The owner's doors onto owned environments (apienv.go): adopt, release
// and fork. Closed to every service role, owner-gated inside.
s.registerEnvironmentRoutes()
- s.registerDemoOperatorRoutes()
}
// clientIP is who the rate limiter counts against.
diff --git a/internal/console/routedecls.go b/internal/console/routedecls.go
index beb4c1f00..a5234c5ca 100644
--- a/internal/console/routedecls.go
+++ b/internal/console/routedecls.go
@@ -1067,6 +1067,13 @@ var routeDecls = []routeDecl{
// doors, on a console without host claims (gateNoHostClaim).
{Pattern: "GET /api/cli/system/demos/reports", Kind: kindCLI, Gate: gateNoHostClaim, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDemoReports},
{Pattern: "POST /api/cli/system/demos/reports/{id}/resolve", Kind: kindCLI, Gate: gateNoHostClaim, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDemoReportResolve},
+
+ // The demo operator doors (apidemooperator.go): closed doors, on a
+ // console without host claims (gateNoHostClaim), which cannot run demos.
+ {Pattern: "GET /api/cli/system/demos", Kind: kindCLI, Gate: gateNoHostClaim, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDemosStatus},
+ {Pattern: "PUT /api/cli/system/demos/serving", Kind: kindCLI, Gate: gateNoHostClaim, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDemosServing},
+ {Pattern: "POST /api/cli/system/demos/takedown", Kind: kindCLI, Gate: gateNoHostClaim, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDemosTakedown},
+ {Pattern: "GET /api/cli/system/demos/takedown", Kind: kindCLI, Gate: gateNoHostClaim, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDemosTakedownStatus},
}
// registerDecls is THE loop: every declaration match accepts and whose gate