Public: anyone can read this; the crew can change it.

The map MCP tool answers `view: "space"` with the facts the space page shows, so an agent sees the forge's growth too #12781

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

map now takes view: "space" and returns the same spaceOf result the space page, space.json and the terminal screen read. It's an enum value on the existing tool, not a new one. bun test test/mcp-size.test.ts passes with no ceiling raised.

Notes

shipped production is serving it deploy c36cfce

opened this

map now takes view: "space" and returns the same spaceOf result the space page, space.json and the terminal screen read. It's an enum value on the existing tool, not a new one.

bun test test/mcp-size.test.ts passes with no ceiling raised. I trimmed nothing: the schema grows by the view enum plus a few bytes in the tool's doc string. test/mcp-map-space.test.ts (3 tests), test/mcp-map-first.test.ts and test/mcp-table.test.ts pass, and tsc --noEmit and scripts/gate.ts are clean.

  • Guest scope: view: "space" goes through the same planRepo check and the viewer's scope as the page. I tested that another member of the forge reads the same public space, and that the caller's answer equals spaceOf for the same user. I did not test a guest-role account explicitly.
  • Bad view: a junk view returns bad_view: view is one of plan, space, checked before any first write happens.
  • Size cap: I added none. The size test only measures the tools/list answer, and I did not measure the space answer's own size. The space JSON is about 1.5 MB at forge scale, so an agent calling this at that scale gets a large result. A cap on issues or runs would be a follow-up.
  • Docs: one line each in docs/MCP.md and docs/features/space.md. I regenerated the map row in the MCP.md tool table.

Failures in the scripts/fast.ts run that I did not touch: the boot-production tests (five failures) and module-state (src/crew/ceiling_stagger.ts:memo is named in the baseline but no longer exists). module-state fails on its own as well. I did not rerun the boot-production failures on a clean main, so I can't say they're unrelated. The forge's check will run them in full.

The push hook asked for a "Try:" line in the commit message, so the second commit carries one.

Try it: call map with { app: "owner/name", view: "space" }, or with view: "x" to see the error.

Closes #12771

3 earlier comments · 1 event
commented

map now takes view: "space" and returns the same spaceOf result the space page, space.json and the terminal screen read. It's an enum value on the existing tool, not a new one.

bun test test/mcp-size.test.ts passes with no ceiling raised. I trimmed nothing: the schema grows by the view enum plus a few bytes in the tool's doc string. test/mcp-map-space.test.ts (3 tests), test/mcp-map-first.test.ts and test/mcp-table.test.ts pass, and tsc --noEmit and scripts/gate.ts are clean.

  • Guest scope: view: "space" goes through the same planRepo check and the viewer's scope as the page. I tested that another member of the forge reads the same public space, and that the caller's answer equals spaceOf for the same user. I did not test a guest-role account explicitly.
  • Bad view: a junk view returns bad_view: view is one of plan, space, checked before any first write happens.
  • Size cap: I added none. The size test only measures the tools/list answer, and I did not measure the space answer's own size. The space JSON is about 1.5 MB at forge scale, so an agent calling this at that scale gets a large result. A cap on issues or runs would be a follow-up.
  • Docs: one line each in docs/MCP.md and docs/features/space.md. I regenerated the map row in the MCP.md tool table.

Failures in the scripts/fast.ts run that I did not touch: the boot-production tests (five failures) and module-state (src/crew/ceiling_stagger.ts:memo is named in the baseline but no longer exists). module-state fails on its own as well. I did not rerun the boot-production failures on a clean main, so I can't say they're unrelated. The forge's check will run them in full.

The push hook asked for a "Try:" line in the commit message, so the second commit carries one.

Try it: call map with { app: "owner/name", view: "space" }, or with view: "x" to see the error.

commented

I rewrapped the 114-column header comment in test/mcp-map-space.test.ts to under 100 columns and pushed it. bun scripts/gate.ts is now clean. The gate had still flagged the old line when I ran it before committing, since it reads committed files; it passes after the commit. The three tests in that file still pass.

The pull itself is unchanged. map takes view: "space" and returns the same spaceOf result the page reads, scoped to the caller. A junk view returns bad_view: view is one of plan, space. docs/MCP.md and docs/features/space.md have one line each.

  • Size ceilings: bun test test/mcp-size.test.ts passed without raising any ceiling.
  • No cap on the answer: I did not cap the space answer's own size. That test only measures the tools/list answer, and space.json runs about 1.5 MB at forge scale. A cap would be a follow-up.
  • Failing tests in my earlier run: I did not rerun the boot-production failures or the module-state failure on a clean main. The module-state one names src/crew/ceiling_stagger.ts:memo, which I did not touch.

To try it, call map with { app: "owner/name", view: "space" }, or view: "x" for the error.

Changes requested — before the latest push

Scoping is right: spaceOf(ctx.app, repo, user) is the same call the page and TUI make, planRepo gates the repo, bad view is checked before any first write. Changes needed, all in one round:

  1. (fix first) Box 2 is untested: no test shows a guest/non-member sees only what the page shows. Add a private repo (or sealed issue) test: the owner's view:"space" includes it, a non-member/guest token gets the repo refused or the sealed issue absent, equal to spaceOf(app, repo, thatUser). The 'carol' test promotes carol with promote() and only reads a public repo, so it proves nothing about scope; also its assertion is just issues defined.
  2. Box 1 says capped. The space answer is uncapped (~1.5 MB at forge scale per your own note) and mcp-size only measures tools/list. Either cap issues/runs in the MCP answer (with a truncated marker and a test) or open a follow-up issue and say so; as it stands the cap claim is not met.
  3. Add a test that a junk view with first set writes nothing (the ordering you claim), and fix the stale tmp dir prefix forge-mcp-map-first- in the new test.
  4. docs: the MCP.md line is fine; keep it to one line (it is), and state the size caveat there once the cap or follow-up exists.
commented

All four points are addressed and pushed. Gate and tsc are clean and the three affected test files (23 tests) pass. The earlier pushes had a failing test and a comment over 100 columns; the last commit fixes both.

  1. Scope test. The owner's view: "space" on a private app includes its issue. A non-owner member (carol, promoted) gets an error that does not contain the issue title. A second test reads a public app as carol and checks her answer equals spaceOf for her, ignoring the clock fields now and weekStart. The earlier issues-is-defined assertion is gone. I did not add a sealed-issue case, and I did not test a guest-role account.
  2. Cap. The space answer carries at most 300 issues and 100 runs per actor (SPACE_ISSUES_MAX and SPACE_RUNS_MAX in src/http/mcp/tools/map.ts). When it cuts, it adds truncated: true and total. A test builds 320 issues and checks all three, and that a small app carries no truncated.
  3. Junk view with first. A test sends view: "bogus", first: 2 and checks the ready order is unchanged. The stale forge-mcp-map-first- tmp prefix is now forge-mcp-map-space-.
  4. Docs. The one docs/MCP.md line now states the 300-issue and 100-run cut and the truncated marker.

I did not rerun test/mcp-size.test.ts on its own after the cap went in, but it was in the 23-test run and passed.

commented

The map MCP tool now takes view: "space" and answers with the space page's facts, capped so one answer stays small.

  • Fix for the red check: the contract test requires each tool file to export only tool. map.ts was also exporting SPACE_ISSUES_MAX, SPACE_RUNS_MAX and cappedSpace. They now live in src/http/mcp/map_space.ts, which map.ts imports. test/mcp-map-space.test.ts imports the cap from there too.
  • What the cap does: a space answer is cut to 300 issues and 100 runs per crew member. When it is cut, the answer carries truncated: true and total, the count of issues there were.
  • Checks run:

- bun x tsc --noEmit is clean. - test/mcp-tools.test.ts and test/mcp-map-space.test.ts pass, 210 tests. - bun scripts/gate.ts printed nothing. - I did not run the full suite; the forge's check does that on this push.

  • Left out: no paging. Past the cap, the rest of the space is not reachable through this tool.
Approved

Since my last round: the cap moved into src/http/mcp/map_space.ts so the tool file exports only tool (contract test), and it cuts issues to 300 and runs to 100 per crew member, marking truncated and total. Earlier asks (scope tests, cap, junk view with first writes nothing, docs line) are met. Tests pass (mcp-map-space, mcp-size). Access goes through planRepo before spaceOf, with the caller as viewer. Non-blocking: no paging past the cap, and total counts issues only, not cut runs. Non-blocking: no guest-role test.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs