Developer-Dashboard

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

    set) now runs a real Anthropic tool_use round-trip loop instead of a
    single non-streaming POST, offering two read-only tools (read_file,
    grep_repo) scoped to the current project root - closing the gap
    where only the CLI-fallback path could answer genuinely
    repo-specific questions. A plain question needing no repo search is
    unchanged (one request, same shape as before).

4.50  2026-09-18

  - DD-952: added Amazon Nova as a dashboard ask backend (--nova), against
    Nova's own standalone REST endpoint (api.nova.amazon.com/v1/chat/
    completions, bearer-token auth via NOVA_API_KEY) - the same direct-API
    shape --claude already uses, not AWS Bedrock/SigV4.

4.49  2026-09-18

  - DD-954: a skill's own cli/__init__.<ext> self-script now runs when
    it is invoked with no subcommand at all - d2 <skill-name> (bare) and
    d2 <skill>.<nested-skill> (dotted, when no explicit subcommand file
    exists) both fall back to it, any extension. An explicit top-level or
    subcommand always wins over the fallback.

README.md  view on Meta::CPAN


Saved bookmark
editor pages also stay on their named `/app/<id>/edit` and
`/app/<id>` routes when you save from the browser, so editing an
existing bookmark file does not fall back to transient `token=` URLs under the
default deny policy.

`Ajax` helper calls inside saved bookmark `CODE*` blocks should use
an explicit `file => 'name.json'` argument. When a saved page supplies that
name, the helper stores the Ajax Perl code under the saved dashboard ajax tree and emits a
stable saved-bookmark endpoint such as
`/ajax/name.json?type=text`.

Skill pages use the same helper contract. Without
extra skill route metadata the generated saved endpoint is namespaced under the
longest matching skill route, for example
`/ajax/example-skill/name.json?type=text` or
`/ajax/example-skill/sub-skill/name.json?type=text`.

The runtime config tree
and installed skills can both ship `config/routes.json` to declare canonical
custom paths for normal saved app pages, skill-local app pages, Ajax handlers,
JavaScript assets, CSS assets, and other public assets. The schema is a JSON
object whose keys are the public custom paths and whose values are either one
smart local route string or an object with `to` plus an optional `type`, for

README.md  view on Meta::CPAN

contains HTML such as `/script`, the editor now escapes the inline JSON
assignment used to reload the source text, so the browser keeps the full
bookmark source inside the editor instead of spilling raw text below the page.

Saved browser workspaces can also show a request-specific token form above the
editor whenever the current request uses `{{token}}` placeholders, carrying
those token values across matching placeholders in the same workflow so later
requests can reuse the operator-supplied values without manual copy-and-paste.

Bookmark rendering now emits saved `set_chain_value()` bindings after
the bookmark body HTML, so pages that declare `var endpoints = {}` and then
call helpers from `$(document).ready(...)` receive their saved `/ajax/...`
endpoint URLs without throwing a play-route JavaScript `ReferenceError`.

Bookmark pages now also expose
`fetch_value(url, target, options, formatter)`,
`stream_value(url, target, options, formatter)`, and
`stream_data(url, target, options, formatter)` helpers so a bookmark can bind
saved Ajax endpoints into DOM targets without hand-writing the fetch and
render boilerplate. `stream_data()` and `stream_value()` now use
`XMLHttpRequest` progress events for browser-visible incremental updates, so
a saved `/ajax/...` endpoint that prints early output updates the DOM before
the request finishes.

Those helpers support plain text, JSON, and HTML output. Saved Ajax bindings
are available after the page declares its endpoint root, so
`$(document).ready(...)` callbacks can call helpers such as
`fetch_value(endpoints.foo, '#foo')` on first render.

For response inspection panels, place the Response Body and Response Headers
tabs below the response `pre` box. This keeps the main response visible while
the details remain accessible.

## User CLI Extensions

Unknown top-level subcommands can be provided by executable files under
the current working directory's `./.developer-dashboard/cli` first, then the
nearest git-backed project runtime `./.developer-dashboard/cli` when it is a

doc/ask.md  view on Meta::CPAN


One flag selects the backend for the turn, and the choice becomes **sticky** for
the workspace until you pick another:

- `--claude` (default) — answers over the Anthropic API when a key is available,
  otherwise falls back to the local `claude` CLI (Claude Code).
- `--codex` — shells out to the Codex CLI (`codex exec`), forced to a read-only
  sandbox so an ask can never mutate the tree.
- `--copilot` — shells out to the Copilot CLI (`copilot -p ... --allow-all-tools`).
- `--gemini` — shells out to the Gemini CLI (`gemini -p ...`).
- `--nova` — answers over Amazon Nova's own standalone REST endpoint
  (`api.nova.amazon.com`), authenticated with a plain bearer token in
  `NOVA_API_KEY` (not an AWS credential). Image attachments are not supported
  with this backend.

Each CLI backend is invoked non-interactively. If the selected CLI is not
installed, `ask` reports which package to install rather than failing silently.

Run `d2 ask --help` at any time to see the full, current usage text -
every backend flag and every option, generated from the same source the CLI
itself uses so it can never drift out of sync with what `ask` actually

doc/goroutine-collector-supervisor.md  view on Meta::CPAN

Perl builds that do not provide it continue to use the supported pointer-table
flag rather than failing to compile. `t/238-goroutine-routine-controls.t`
checks the clone call and guarded Windows branch. Native Windows runtime
behavior still requires the hosted Windows workflow for direct validation.

## POSIX web-service launch

The POSIX background web path also uses `Developer::Dashboard::GoRoutine::spawn`.
It starts the private `web-foreground` helper with an argument vector, null
stdin, and explicit dashboard stdout/stderr log paths. It records the listener
PID and endpoint only after the requested port accepts a connection. If the
readiness poll budget expires, it terminates and waits for the spawned child,
then reports the child status and both log paths rather than returning a
possibly dead PID as though startup succeeded. Windows retains its existing
native detached-launch path pending the hosted GoRoutine validation.

The focused test `t/235-runtime-manager-goroutine-supervisor.t` checks the
shell-free command, redirection, listener-state persistence, timeout
termination and wait. Run it with the checkout XS paths inside Docker:

```sh
d2 docker compose exec dev prove -Iblib/arch -Iblib/lib -Ilib -lv t/235-runtime-manager-goroutine-supervisor.t
```

## SSL frontend and shared client routines

SSL mode now starts a separate internal Starman backend by passing an argv
vector for the staged `web-ssl-backend-foreground` helper to GoRoutine's native
process API. The helper rebuilds the normal application from the layered
configuration and serves only the internal loopback endpoint. It is not
implemented by running Starman from a GoRoutine thread because Starman's
prefork worker model requires an independent OS process.

The public SSL frontend handles each accepted socket in a GoRoutine worker. It
shares the fd-backed socket and the minimal server/daemon data needed by the
request handler; it does not share the application object graph. Shutdown
cancels active routines, waits for them to unwind, reports handler and socket
close errors, then terminates and waits for the backend process. The backend
child is reaped exactly once even when a signal handler and normal cleanup both
request shutdown.

doc/integration-test-plan.md  view on Meta::CPAN

    streamed live. With the service already running, verify no `up`/build
    command occurs, including when `-C` was requested. Repeat without the
    service and verify the setup error occurs with no `exec` calls. Also
    verify `-d` without `-c` fails before Compose is invoked, and no `-d`
    preserves the local tmux behavior.
21. Start the installed web service.
22. Confirm exact-loopback access reaches the editor page in Chromium.
23. Confirm the browser can render a saved fake-project bookmark page from the fake project bookmark directory.
24. Confirm the browser inserts sorted rendered `nav/*.tt` bookmark fragments between the top chrome and the main page body.
25. Confirm the browser top-right status strip shows configured collector icons, not collector names, that UTF-8 icons such as `🐳` and `💰` are visibly rendered, and that renamed collectors no longer leave stale managed indicators behind.
26. Confirm an installed saved bookmark page can declare `var endpoints = {};`, then use `fetch_value()` and `stream_value()` from `$(document).ready(...)` against saved `/ajax/<file>` routes without inline-script ordering failures or browser console...
27. Confirm an installed long-running saved `/ajax/<file>` route starts streaming the first output chunks promptly instead of buffering until the worker exits.
28. Confirm an installed skill page that ships `config/routes.json` emits the declared canonical custom ajax path, that the custom path resolves, that the smart `/ajax/<repo-name>/...` route still resolves for the same handler, and that a route-level...
29. Confirm non-loopback self-access returns `401` with an empty body and without a login form before any helper user exists in the active runtime.
30. Add a helper user for the outsider browser flow, then confirm non-loopback self-access reaches the helper login page in Chromium.
31. Log in as a helper through the HTTP helper flow.
32. Confirm helper page chrome shows `Logout`.
33. Log out and confirm the helper account is removed.
34. Restart the installed runtime from the extracted tarball tree and confirm the web service comes back.
35. Stop the runtime and confirm the web service is gone.

doc/integration-test-plan.md  view on Meta::CPAN

- a killed managed collector loop is restarted automatically by the watchdog, and repeated crash loops eventually surface `watchdog_attention_required` in `d2 collector status <name>` instead of going silent
- a live managed collector loop that stops updating its status or completion timestamps is treated as stalled, recycled automatically by the watchdog, and reported explicitly in `d2 collector status <name>` instead of sitting silent forever
- `d2 collector log` prints aggregated collector transcripts, `d2 collector log <name>` prints the named collector transcript, and configured collectors that have not run yet report an explicit no-log message instead of blank output
- TT-backed collector icons render from stdout JSON and stay rendered through later config-sync reads instead of reverting to raw `[% ... %]` text
- the web service serves the root editor on `127.0.0.1:7890`
- the browser can load both the editor and a saved fake-project bookmark page from the fake project bookmark directory
- the browser sees sorted shared `nav/*.tt` fragments above the main page body on that fake-project bookmark page
- the browser top-right status strip shows configured collector icons and does not leave stale renamed collector indicators behind
- nested `DD-OOP-LAYERS` collector prompts do not let a child-layer placeholder `missing` state override a healthy inherited parent-layer collector indicator when the child config adds no collector override
- under `DD-OOP-LAYERS`, `d2 path add` writes only the new child-layer alias delta into the deepest child `config/config.json` instead of copying inherited parent config domains into that file
- bookmark pages can use `fetch_value()`, `stream_value()`, and `stream_data()` helpers against saved `/ajax/...` endpoints on first render
- the installed `/ajax/<file>` route streams early output chunks promptly enough to prove browser-visible progress instead of silent buffering
- skill pages that ship `config/routes.json` emit their declared canonical custom ajax paths, while the smart `/ajax/<repo-name>/...` route still works as the parent compatibility resolver and custom paths stay fallback-only before a normal `404`
- layered `config/api.json` files under both runtime roots and installed skills can authorize selected saved `/ajax/...` routes for machine callers, those callers must present matching `X-DD-API-Key` and `X-DD-API-Secret` headers, helper-session auth...
- the built-in `d2 api` command can list that effective merged registry, hash raw secrets from `--secret` or `--maybe-secret` before saving them, add and remove exact saved ajax routes, and write only to the deepest writable `config/api.json` layer w...
- non-loopback access produces `401` with an empty body and without a login page until a helper user exists in the active runtime
- under `d2 serve --ssl`, plain `http://HOST:PORT/...` requests on the public listener return a same-port `307` redirect to `https://HOST:PORT/...`, the generated cert advertises SAN coverage for `localhost`, `127.0.0.1`, and `::1`, and a browser the...
- after a helper user exists, non-loopback access produces the helper login page
- helper logout removes both the helper session and the helper account
- `d2 stop` leaves no active listener on port `7890`
- `d2 stop` and `d2 restart` still control the real serving pid

doc/problem-48-performance-research.md  view on Meta::CPAN

status-path joins for every discovered indicator: the directory-inventory
validation checked that each candidate file was in the persistent signature
cache, then active-collector validation rebuilt and checked the same paths.
The red-first Docker test reproduced 24 `File::Spec->catfile` calls for 12
entries. The validator now records whether each discovered name has a present
status file during its first pass and reuses that result for active jobs. It
still stats every cached candidate using the same high-resolution signature,
so external updates remain visible; it does not trade away freshness.

The focused Docker tests pass with exactly 12 joins for 12 fixture entries.
The matched 50-collector endpoint returned byte-identical 12,687-byte bodies
and measured 34.307 ms/request on v5.88 versus 0.437 ms/request on current
source (78.50x) across 31 samples. This is a route-specific measurement, not
evidence for the requirement that every subroutine improve by at least 50x.
The full Docker coverage gate passed statement, branch, condition, and
subroutine totals at 100.0% (48,438 detail rows, with no stale uncoverable
annotations). After that gate, `perldoc perlsec` rendered successfully and the
required web/security regression set passed 622 assertions across four files.

Security applicability review: V1, V7, V12, and V13 were relevant. The change
retains the existing filesystem roots and high-resolution signatures, closes a

doc/problem-48-performance-research.md  view on Meta::CPAN

25% slower). Both returned 9,573-byte bodies; their SHA-256 matched after
normalizing the live datetime field. FFI call and allocation overhead erased
the isolated helper gain on this request, so no production change was made.

### Collector-backed status route profile (2026-10-15)

Expected outcome: repeated `/system/status` requests with unchanged collector
configuration should compare each persisted indicator once per synchronization,
return byte-identical response data, and observe disk changes on the next
request. Reproduction: in an isolated HOME, seed 50 collector indicators, warm
the endpoint once, then profile 100 `Web::App->handle('/system/status')`
requests with NYTProf enabled only around the request loop. The Docker profile
returned HTTP 200 and a 12,687-byte body on every request. Before the fix it
recorded 5,000 calls to `_collector_sync_plan`, 15,000 calls to
`_read_indicator_file`, and 15,100 calls to `PathRegistry::indicators_roots`;
`sync_collectors` had 2.40 seconds inclusive profile time over the 100 calls.
The root cause was that each collector sync separately resolved the same roots
for effective state, local state, and final inventory, then decoded each file
again at each lookup.

The first Docker regression run was red: a 12-indicator steady-state sync

doc/problem-48-performance-research.md  view on Meta::CPAN

directly in three consecutive ranges. This closes the current coverage gate,
not the all-subroutine 50x performance objective or remaining delivery gates.

### Matched status-route rerun and current NYTProf call tree (2026-10-15)

The production-boundary benchmark was rerun with 50 synthetic collectors,
100 requests per sample, and 21 samples against both the v5.88 tree and the
current source. Both returned HTTP 200 and byte-identical 12,864-byte bodies
(SHA-256 `da887f795a1b16c65b1c3b8d54a7e390425b1dd0b19731cac0b437dd95d9ac68`).
Median latency was 72.415810 ms/request on v5.88 and 0.249081 ms/request on the
current source (290.73x for this endpoint and fixture only). Run-to-run variance
means this is a refreshed measurement, not an incremental gain attributed to
the config-merge follow-up.

A current-source NYTProf run profiled only the warmed 500-request loop and kept
the same body hash. The instrumented request median was 1.313282 ms; it is not
a wall-clock performance figure. The largest application source-line totals in
the generated CSV were JSON decode (22.703 ms / 500 calls), JSON encode
(15.320 ms / 1,000 calls), indicator projection (10.122 ms / 25,000 entries),
and `dispatch_request` (9.960 ms / 500 calls). Path discovery and secure
runtime metadata checks also recur on the request path. These results identify

doc/problem-report.md  view on Meta::CPAN

coverage (45,841 detail rows, no stale uncoverable annotations). Devel::Cover
also printed missing-digest diagnostics for temporary test-generated helpers
that had already been removed; the canonical gate exited 0 and confirmed the
complete library metrics. The focused security/web trio passed 459 assertions;
the release kwalitee, source POD, and release-metadata gates passed 5,783
assertions, including 100% kwalitee. The final 5.67 archive contains no
`cover_db`. The blank Docker environment installed the same 5.67 release code
with `cpanm` and its normal test execution (no `--notest`); the complete
installed-runtime integration runner reported success. The installed Perl
`perlsec` documentation was reviewed after the gate. No new command execution,
dependency, SQL, endpoint, credential, or authentication surface was
introduced.

### Problem 42: Let skill environment values override home defaults (done in 5.68)

Expected: when a skill command runs, matching values from that skill's `.env`
or `.env.pl` override home runtime values from `~/.d2` or
`~/.developer-dashboard`. A deeper project runtime layer continues to override
both. Non-skill commands keep their current runtime-layer behavior.

Root cause: `SkillDispatcher` loaded skill and skill-CLI files, then called

doc/problem-report.md  view on Meta::CPAN

test reproduced the issue: a 12-indicator sync resolved roots 37 times instead
of once.

`sync_collectors` now shares ordered roots and decoded status records only for
its own operation; writes/deletions invalidate their entries. The cache is
discarded before a subsequent sync. Docker regressions verify one roots lookup,
one disk read per indicator, changed-state visibility on a later sync, and
correct inventory after collector retirement. The focused IndicatorStore and
new regression suites pass 229 assertions.

In 15 alternating Docker runs, the same 50-collector endpoint measured 9.203
ms/request before and 2.689 ms/request after (3.42x), with exact response-byte
parity. The post-change profile recorded 100 root resolutions, 5,000 file
reads, and 513 ms inclusive in `sync_collectors` over 100 requests. This
advances one collector-heavy route; Problem 48's full 50x-per-subroutine
objective remains open.

### Problem 48 single-root collector-plan follow-up (2026-10-15)

Expected outcome: for a collector sync with exactly one indicator state root,
the already-resolved effective record is also the local record, and no

doc/problem-report.md  view on Meta::CPAN

12,687-byte responses and measured 7.708 ms/request for the previous strategy
versus 2.195 ms/request for current source (3.51x). This is a modest, scoped
increment; Problem 48 remains in progress because the all-routine 50x target is
not met.

### Problem 48 direct v5.88 status baseline check (2026-10-15)

Expected outcome: compare the same collector-heavy status route on the named
v5.88 baseline and current checkout, preserving exact response bytes, before
claiming baseline speedup. A Docker benchmark loaded each source tree explicitly
through `@INC`, used an isolated HOME and 50 collectors, warmed the endpoint,
and measured 100 requests in each of 15 samples. Both trees returned HTTP 200
and identical 12,687-byte bodies. The median was 35.090 ms/request for v5.88
and 1.624 ms/request for the current checkout (21.61x). This proves meaningful
progress for one route, not the required 50x improvement for every subroutine;
Problem 48 remains in progress.

### Problem 49: Remove the install test's hardcoded `/tmp` assumption (done)

GitHub issue 59 reported assertion 195 in `t/40-install-bootstrap.t` failing
when the host's `TMPDIR` was not `/tmp`. The expected outcome is that the

doc/problem-report.md  view on Meta::CPAN

assertions. Problem 48 remains open.

### Problem 48 validated status-response reuse (2026-10-15)

Expected outcome: repeated `/system/status` calls with unchanged collector
configuration and persisted indicator files return the exact prior response
without repeating status-payload construction; a changed indicator or config
must produce a fresh response on the next request.

Reproduction: in Docker with an isolated HOME, seed 50 collectors, warm the
status endpoint, then issue repeated requests while counting status JSON
encodes and `page_header_payload` calls. Next, persist a changed indicator and
request status again. Before the optimization, an unchanged request still
rebuilt the payload and encoded JSON. The red-first regression in
`t/668-problem48-status-response-cache.t` failed those stable-path call-count
assertions.

Root cause: collector synchronization already proved whether the configuration,
status-file signatures, and directory inventory were unchanged, but the web
route discarded that result and rebuilt/sorted the same payload and serialized
the same JSON anyway. `sync_collectors` now exposes its validated unchanged

doc/problem-report.md  view on Meta::CPAN


Root cause: inventory validation checked each candidate status path and then
active collector validation rebuilt and rechecked the same path. The first
pass now records which names have a present cached status file; active jobs
reuse that map. All candidate signatures are still checked, so file
modifications, replacement, or removal continue to force reconciliation.

Evidence: the focused Docker suite now verifies exactly 12 joins for 12
entries. A fresh 31-sample, 50-collector `/system/status` comparison returned
byte-identical 12,687-byte responses: 34.307 ms/request on v5.88 and 0.437
ms/request currently (78.50x for this endpoint workload). This is not evidence
that every subroutine is 50x faster. The full Docker gate passed 100.0%
statement, branch, condition, and subroutine coverage (48,438 detail rows,
with no stale uncoverables). Post-gate `perldoc perlsec` and the required web
security regression suite passed; its four files covered 622 assertions.
Packaging, image, delivery gates, and the all-subroutine 50x objective remain
open, so Problem 48 is still in progress.

Problem 48 blank-container package-test isolation follow-up (2026-10-15)

Expected outcome: the distribution's cpanm test install passes regardless of

doc/problem-report.txt  view on Meta::CPAN


Problem 20 resumed audit (2026-09-30, source commit f56aedc2):
The first full-gate attempt used root with DAC-bypass capabilities dropped while the checkout was mounted as ubuntu-owned; t/110 and t/111 could not create fixtures, so that run was invalid and was stopped. A clean root-owned clone of the same commit...

Resumed coverage iteration (2026-09-30): A non-root Ubuntu test run in the `dev` Docker service passed 204 files / 19,319 tests. `t/09` initially exposed a fixture hard-coded under `/tmp/user`; it now directs state into its temporary HOME. Iteration ...

Iteration 8 used that git-backed isolated clone, passed 204 files / 19,212 tests, and ran `t/139` plus the source-tree guardrails. The strict gate still fails: statement 99.9%, branch 99.6%, condition 99.3%, subroutine 99.9%, aggregate 99.7%. Remaini...

Coverage-gap reproduction exposed an additional bookmark crash: save `//example.test/path` as a bookmark and call `_legacy_app_response`; before the fix it died because `URI::_generic` has no `host` method. The expected result is an HTTP redirect pre...

Scorecard gate (2026-09-30, after pushed commit 93218224): status incomplete, 8.0/10. Live output is from `bash -ic "scorecard --repo=github.com/manif3station/developer-dashboard"`. All checks other than Branch-Protection, CII-Best-Practices, Code-Re...

Problem 25: Complete help and shell-completion coverage for internal CLI commands (status: original help catalog delivered; delegated CLI help regression fixed in 5.42)
Expected outcome: every shipped internal CLI command and each actionable subcommand supports `--help`, `-h`, and/or an explicit `help` form with actionable syntax, exits successfully without performing the command, and appears in relevant TAB complet...
Scope discovered: all 39 assets registered by `Developer::Dashboard::InternalCLI::helper_names()` under `share/private-cli/`, plus the direct switchboard `version` command. This includes direct helpers (`jq`, `yq`, `tomq`, `propq`, `iniq`, `csvq`, `x...
Nested action inventory verified against dispatch: `api` = `ls add rm`; `auth` = `add-user list-users remove-user`; `collector` = `write-result status list job output inspect log run start stop restart`; `config` = `init show`; `docker` = `compose li...
Reproduction in isolated Docker: `d2 docker compose --project-name problem25 run --rm --no-deps dev ...`; use a temporary HOME and invoke `/work/bin/dashboard`. Observed `api --help` reports `Unknown option: help` and continues into API listing; `fil...
Root cause: help behavior was scattered across the top-level POD, `ask`, and `docker`, while many internal helpers only emitted usage on invalid input. Second-level completion was maintained as a separate partial hard-coded list, already out of sync ...

Red-first evidence: the initial Docker subprocess test failed because `api --help` emitted a Getopt warning and continued into the listing, file/path help exited with usage failures, nested action help executed or errored instead of rendering its syn...

doc/problem-report.txt  view on Meta::CPAN

Final verification: all 258 Docker test files passed (22,645 tests); Devel::Cover
reported 100.0% statement, branch, condition, and subroutine coverage across
the library (45,841 detail rows, no stale uncoverable annotations). Its report
included missing-digest diagnostics for temporary generated helpers already
removed by their tests; the canonical gate exited successfully. The focused
web/security tests passed 459 assertions. Kwalitee, POD, and release metadata
passed 5,783 assertions, including 100% CPANTS kwalitee. The final 5.67 archive
excluded cover_db. The blank Docker environment installed the same 5.67 release
code through cpanm with tests enabled and passed the complete installed-runtime
integration runner. Perl's perlsec documentation was reviewed inside the
runtime container. No new executable, dependency, SQL, endpoint, credential,
or authentication surface was added.

Problem 42: Let skill environment values override home defaults (status: done, 5.68)

Expected outcome: matching values from a skill's `.env` or `.env.pl` override
home runtime values from `~/.d2` or `~/.developer-dashboard`. Deeper project
runtime layers keep final precedence. Non-skill environment behavior is
unchanged.

Root cause: SkillDispatcher loaded skill and skill-CLI files before loading

doc/problem-report.txt  view on Meta::CPAN


Root cause: inventory validation checked each candidate status path and then
active collector validation rebuilt and rechecked the same path. The first
pass now records which names have a present cached status file; active jobs
reuse that map. All candidate signatures are still checked, so file
modifications, replacement, or removal continue to force reconciliation.

Evidence: the focused Docker suite now verifies exactly 12 joins for 12
entries. A fresh 31-sample, 50-collector /system/status comparison returned
byte-identical 12,687-byte responses: 34.307 ms/request on v5.88 and 0.437
ms/request currently (78.50x for this endpoint workload). This is not evidence
that every subroutine is 50x faster. The full Docker gate passed 100.0%
statement, branch, condition, and subroutine coverage (48,438 detail rows,
with no stale uncoverables). Post-gate perldoc perlsec and the required web
security regression suite passed; its four files covered 622 assertions.
Packaging, image, delivery gates, and the all-subroutine 50x objective remain
open, so Problem 48 is still in progress.

Problem 48 blank-container package-test isolation follow-up (2026-10-15)

Expected outcome: the distribution cpanm test install passes regardless of

doc/static-file-serving.md  view on Meta::CPAN

<img src="/others/logo.png">
<link rel="icon" href="/others/favicon.ico">
<script src="/others/config.json" type="application/json"></script>
<img src="/others/example-skill/icon.svg">
<img src="/others/example-skill/sub-skill/path/file.txt">
```

### Skill-local Ajax Endpoints
```html
<script>
var endpoints = {};
</script>
```

Skill bookmark CODE blocks can publish stable endpoints such as:

```perl
CODE1: Ajax jvar => 'endpoints.status', file => 'status', code => q{
print "ok\n";
};
```

When that page lives inside `~/.developer-dashboard/skills/example-skill/dashboards/...`,
the browser-facing endpoint becomes:

```text
/ajax/example-skill/status?type=text
```

Nested child skills extend that pattern:

```text
/ajax/example-skill/sub-skill/status?type=text
```

doc/testing.md  view on Meta::CPAN

  --expect-ajax-body 123 \
  --expect-dom-fragment '<span class="display">123</span>'
```

For a skill page that declares `config/routes.json`, assert the canonical
custom ajax path rather than the default smart `/ajax/<repo-name>/...` path:

```bash
integration/browser/run-bookmark-browser-smoke.pl \
  --bookmark-file ~/.developer-dashboard/skills/example-skill/dashboards/index \
  --expect-page-fragment "set_chain_value(endpoints,'status','/v1/status')" \
  --expect-ajax-path /v1/status \
  --expect-ajax-body '{"status":"ok"}'
```

For long-running saved bookmark Ajax handlers that would otherwise survive a
browser refresh, prefer `Ajax(..., singleton => 'NAME', ...)`. The runtime will
rename the Perl worker to `d2 ajax: NAME`, terminate the older matching
Perl stream before it starts the refreshed one, and also tear down matching
singleton workers during `d2 stop`, `d2 restart`, and browser
`pagehide` cleanup beacons. For browser streaming checks, use `stream_data()`

doc/update-and-release.md  view on Meta::CPAN

for failing or missing checks. `d2 shell` now emits shell-specific
bootstrap for bash, zsh, POSIX `sh`, and PowerShell `ps`, so release
validation should cover whichever interactive shell bootstrap a new feature
touches. PowerShell verification should check the generated `prompt`
function rather than looking for a POSIX `PS1` export.
The browser top-right status strip should also show the configured collector
icon instead of the collector name, and a collector rename should remove the
old managed indicator from both `/system/status` and `d2 ps1`. Verify
that UTF-8 icons such as `🐳` and `💰` are actually visible in the browser
chrome, not just present in `/system/status` JSON. For bookmark Ajax helper
pages that declare `var endpoints = {};`, verify the saved `set_chain_value()`
bindings run after that declaration so `$(document).ready(...)` helper calls
populate the DOM without a console `ReferenceError`.
Permission-sensitive changes should also verify that `d2 doctor`
reports insecure older or home-runtime paths before repair and returns clean
after `--fix`.

Render prompt in extended colored mode:

```bash
perl -Ilib bin/d2 ps1 --jobs 1 --mode extended --color

doc/update-and-release.md  view on Meta::CPAN


That helper keeps the Windows VM flow rerunnable by loading a reusable env
file, rebuilding the latest tarball when needed, and then delegating to the
checked-in QEMU launcher. The supported Windows runtime baseline is PowerShell
plus Strawberry Perl. Git Bash is optional. Scoop is optional. They are setup
helpers only.

For browser-facing bookmark Ajax changes, also run a real browser smoke that
verifies saved Ajax bindings are emitted before inline page scripts and that
helpers such as `fetch_value()`, `stream_value()`, and `stream_data()` can
populate the DOM from saved `/ajax/...` endpoints without manual bootstrap
ordering fixes or whole-response buffering.

For seeded UI workspaces, run a browser smoke from a fresh project-local
runtime and verify the real rendered DOM includes the expected controls and
navigation rather than only checking the saved bookmark source text.

Command-output capture is implemented with `Capture::Tiny` `capture`, with exit codes returned from the capture block. The core runtime does not currently make outbound HTTP client requests.

## Coverage Verification

integration/blank-env/run-integration.pl  view on Meta::CPAN

    );
    _write_text(
        File::Spec->catfile( $bookmarks, 'legacy-ajax' ),
        <<'BOOKMARK'
TITLE: Legacy Ajax
:--------------------------------------------------------------------------------:
BOOKMARK: legacy-ajax
:--------------------------------------------------------------------------------:
HTML: <script>var configs = {};</script>
:--------------------------------------------------------------------------------:
CODE1: Ajax jvar => 'configs.project.endpoint', type => 'text', file => 'project-endpoint.json', code => q{
print "saved-start\n";
warn "saved-warn\n";
system 'sh', '-c', 'printf "saved-child-out\n"; printf "saved-child-err\n" >&2';
die "saved-die\n";
};
BOOKMARK
    );
    _write_text(
        File::Spec->catfile( $bookmarks, 'legacy-ajax-stream' ),
        <<'BOOKMARK'

integration/blank-env/run-integration.pl  view on Meta::CPAN


    my $project_dom = _run_browser_dom( 'browser fake project page', 'http://127.0.0.1:7890/app/project-home', user_data_dir => $profile );
    _assert_match( $project_dom, qr/project-marker/, 'browser renders fake project bookmark page' );
    _assert_match( $project_dom, qr/Fake Project Home/, 'browser renders fake project bookmark content' );
    _assert_match( $project_dom, qr/dashboard-nav-items/, 'browser renders shared nav container on fake project bookmark page' );
    _assert_match( $project_dom, qr/Alpha Nav Current/, 'browser renders shared nav TT output against the outer page path' );
    _assert_match( $project_dom, qr{<div id="nav-beta">/app/project-home / /app/project-home</div>}, 'browser exposes current_page through env and env.runtime_context for shared nav TT fragments' );
    _assert( index( $project_dom, 'nav-alpha' ) < index( $project_dom, 'nav-beta' ), 'browser renders shared nav bookmark fragments in sorted filename order' );
    _assert( index( $project_dom, 'dashboard-nav-items' ) < index( $project_dom, 'project-marker' ), 'browser renders shared nav fragments before the main page body' );
    my $legacy_ajax_page = _run_shell( 'curl legacy ajax saved page', q{curl -fsS http://127.0.0.1:7890/app/legacy-ajax} );
    _assert_match( $legacy_ajax_page->{stdout}, qr{/ajax/project-endpoint\.json\?type=text}, 'saved bookmark Ajax renders a stable file-backed ajax endpoint by default' );
    my $legacy_ajax_saved = _run_shell( 'curl saved bookmark ajax endpoint', q{curl -fsS 'http://127.0.0.1:7890/ajax/project-endpoint.json?type=text'} );
    _assert_match( $legacy_ajax_saved->{stdout}, qr/saved-start/, 'saved bookmark ajax endpoint streams direct perl stdout' );
    _assert_match( $legacy_ajax_saved->{stdout}, qr/saved-warn/, 'saved bookmark ajax endpoint streams perl stderr warnings' );
    _assert_match( $legacy_ajax_saved->{stdout}, qr/saved-child-out/, 'saved bookmark ajax endpoint streams child stdout' );
    _assert_match( $legacy_ajax_saved->{stdout}, qr/saved-child-err/, 'saved bookmark ajax endpoint streams child stderr' );
    _assert_match( $legacy_ajax_saved->{stdout}, qr/saved-die/, 'saved bookmark ajax endpoint streams uncaught perl die output' );
    my $legacy_ajax_stream_page = _run_shell( 'curl legacy ajax stream saved page', q{curl -fsS http://127.0.0.1:7890/app/legacy-ajax-stream} );
    _assert_match( $legacy_ajax_stream_page->{stdout}, qr{/ajax/project-stream\.txt\?type=text}, 'saved bookmark ajax stream page renders a stable default text ajax endpoint' );
    my $legacy_ajax_stream = _capture_stream_prefix(
        'curl saved bookmark ajax stream endpoint',
        q{curl --no-buffer -fsS 'http://127.0.0.1:7890/ajax/project-stream.txt'},
        expected_chunks => [ 'stream1', 'stream2' ],
        timeout         => 4,
    );
    _assert( @{ $legacy_ajax_stream->{events} || [] } >= 2, 'saved bookmark ajax stream endpoint produced multiple early chunks before process exit' );
    _assert( ( $legacy_ajax_stream->{events}[0]{at} || 99 ) < 1.5, 'saved bookmark ajax stream endpoint flushes the first chunk before the long-running ajax loop finishes' );
    _assert( ( $legacy_ajax_stream->{events}[1]{at} || 99 ) < 2.5, 'saved bookmark ajax stream endpoint keeps flushing later chunks during the long-running ajax loop' );

    my $container_ip = _trim( _run_shell( 'container ip', q{hostname -I | awk '{print $1}'} )->{stdout} );
    _assert( $container_ip ne '', 'container ip discovered for helper-access path' );

    my $helper_root_disabled = _run_shell(
        'curl helper root before helper user exists',
        'curl -sS -o /tmp/helper-root.html -w \'%{http_code}\' http://' . $container_ip . ':7890/'
    );
    _assert_match( $helper_root_disabled->{stdout}, qr/^401$/, 'non-loopback self-access stays unauthorized before any helper user exists' );
    _assert( _read_text('/tmp/helper-root.html') eq q{}, 'outsider bootstrap response keeps the body empty before any helper user exists' );

integration/browser/run-bookmark-browser-smoke.pl  view on Meta::CPAN

Example 1:

  perl integration/browser/run-bookmark-browser-smoke.pl --keep-temp

Keep the temporary project, home, and browser profile directories around for debugging after a failure.

Example 2:

  perl integration/browser/run-bookmark-browser-smoke.pl --bookmark-file /tmp/sample.page --expect-ajax-path '/ajax/test?type=text' --expect-ajax-body 'ok'

Exercise one saved Ajax endpoint as part of the bookmark smoke.

Example 3:

  perl integration/browser/run-bookmark-browser-smoke.pl --bookmark-file /tmp/sample.page --expect-page-fragment 'Hello' --expect-dom-fragment 'Hello'

Point the smoke runner at one explicit bookmark file and assert both raw page and browser DOM output.

Example 4:

  perl integration/browser/run-bookmark-browser-smoke.pl

integration/windows/run-strawberry-smoke.ps1  view on Meta::CPAN


    foreach ($candidate in $candidates) {
        if (Test-Path $candidate) {
            return $candidate
        }
    }

    return $null
}

# Purpose: wait until the dashboard HTTP endpoint responds.
# Input: target URL string.
# Output: returns when the URL responds with a non-5xx code or throws on timeout.
function Wait-HttpOk {
    param([Parameter(Mandatory = $true)][string]$Url)

    $deadline = (Get-Date).AddSeconds(20)
    while ((Get-Date) -lt $deadline) {
        try {
            $response = Invoke-WebRequest -UseBasicParsing -Uri $Url -TimeoutSec 2
            if ($response.StatusCode -ge 200 -and $response.StatusCode -lt 500) {

lib/Developer/Dashboard.pm  view on Meta::CPAN


Saved bookmark
editor pages also stay on their named C</app/E<lt>idE<gt>/edit> and
C</app/E<lt>idE<gt>> routes when you save from the browser, so editing an
existing bookmark file does not fall back to transient C<token=> URLs under the
default deny policy.

C<Ajax> helper calls inside saved bookmark C<CODE*> blocks should use
an explicit C<file =E<gt> 'name.json'> argument. When a saved page supplies that
name, the helper stores the Ajax Perl code under the saved dashboard ajax tree and emits a
stable saved-bookmark endpoint such as
C</ajax/name.json?type=text>.

Skill pages use the same helper contract. Without
extra skill route metadata the generated saved endpoint is namespaced under the
longest matching skill route, for example
C</ajax/example-skill/name.json?type=text> or
C</ajax/example-skill/sub-skill/name.json?type=text>.

The runtime config tree
and installed skills can both ship C<config/routes.json> to declare canonical
custom paths for normal saved app pages, skill-local app pages, Ajax handlers,
JavaScript assets, CSS assets, and other public assets. The schema is a JSON
object whose keys are the public custom paths and whose values are either one
smart local route string or an object with C<to> plus an optional C<type>, for

lib/Developer/Dashboard.pm  view on Meta::CPAN

contains HTML such as C</script>, the editor now escapes the inline JSON
assignment used to reload the source text, so the browser keeps the full
bookmark source inside the editor instead of spilling raw text below the page.

Saved browser workspaces can also show a request-specific token form above the
editor whenever the current request uses C<{{token}}> placeholders, carrying
those token values across matching placeholders in the same workflow so later
requests can reuse the operator-supplied values without manual copy-and-paste.

Bookmark rendering now emits saved C<set_chain_value()> bindings after
the bookmark body HTML, so pages that declare C<var endpoints = {}> and then
call helpers from C<$(document).ready(...)> receive their saved C</ajax/...>
endpoint URLs without throwing a play-route JavaScript C<ReferenceError>.

Bookmark pages now also expose
C<fetch_value(url, target, options, formatter)>,
C<stream_value(url, target, options, formatter)>, and
C<stream_data(url, target, options, formatter)> helpers so a bookmark can bind
saved Ajax endpoints into DOM targets without hand-writing the fetch and
render boilerplate. C<stream_data()> and C<stream_value()> now use
C<XMLHttpRequest> progress events for browser-visible incremental updates, so
a saved C</ajax/...> endpoint that prints early output updates the DOM before
the request finishes.

Those helpers support plain text, JSON, and HTML output. Saved Ajax bindings
are available after the page declares its endpoint root, so
C<$(document).ready(...)> callbacks can call helpers such as
C<fetch_value(endpoints.foo, '#foo')> on first render.

For response inspection panels, place the Response Body and Response Headers
tabs below the response C<pre> box. This keeps the main response visible while
the details remain accessible.

=head2 User CLI Extensions

Unknown top-level subcommands can be provided by executable files under
the current working directory's F<./.developer-dashboard/cli> first, then the
nearest git-backed project runtime F<./.developer-dashboard/cli> when it is a

lib/Developer/Dashboard/CLI/Ask.pm  view on Meta::CPAN

      if @{ $a{images} };
    my $cli = $a{detect}->('claude')
      or die "No ANTHROPIC_API_KEY set and no `claude` CLI found. Set the key or install Claude Code.\n";
    my $prompt = _compose_cli_prompt( $a{history}, $a{prompt}, $a{text_files} );
    my @argv = ( command_argv_for_path($cli), '-p', $prompt, '--output-format', 'text' );
    push @argv, ( '--model', $a{model} ) if defined $a{model};
    return _capture_backend( 'claude', \@argv, $a{runner} );
}

# _ask_nova(%args)
# Answers via Amazon Nova's own standalone REST endpoint (DD-952) -
# api.nova.amazon.com/v1/chat/completions, bearer-token auth. This is
# architecturally identical to _ask_claude's direct-API path (see
# docs/dashboard-ask-backend-architecture.md), never AWS Bedrock/SigV4 -
# NOVA_API_KEY is a plain bearer token, not an AWS credential.
# Input: same payload as _dispatch_backend.
# Output: answer text string; dies when no NOVA_API_KEY is set or images
# are attached (Nova's image content-block shape is not implemented here).
sub _ask_nova {
    my (%a) = @_;
    my $key = $a{env}{NOVA_API_KEY};

lib/Developer/Dashboard/CLI/Ask.pm  view on Meta::CPAN

    return _call_nova_api(
        ua       => $ua,
        key      => $key,
        base_url => $NOVA_DEFAULT_BASE_URL,
        model    => $model,
        messages => $messages,
    );
}

# _call_nova_api(%args)
# Posts one request to Nova's chat-completions endpoint and extracts the
# answer text.
# Input: ua, key, base_url, model, and messages array ref.
# Output: answer text string; dies on a non-success HTTP response or an
# unparseable/empty response body.
sub _call_nova_api {
    my (%a) = @_;
    require HTTP::Request;
    my $url = $a{base_url} . '/v1/chat/completions';
    my $req = HTTP::Request->new( POST => $url );
    $req->header( 'content-type'  => 'application/json' );

lib/Developer/Dashboard/CollectorRunner.pm  view on Meta::CPAN

        else {
            $step = 1;
        }

        my ( $start, $end );
        if ( $base eq '*' ) {
            ( $start, $end ) = ( $minimum, $maximum );
        }
        elsif ( $base =~ /\A([^,-]+)-([^,-]+)\z/ ) {
            ( $start, $end ) = ( _cron_value( $1, $names ), _cron_value( $2, $names ) );
            return ( undef, 'range endpoint is not a valid number or name' ) if !defined $start || !defined $end;
            return ( undef, 'range start exceeds range end' ) if $start > $end;
        }
        else {
            $start = _cron_value( $base, $names );
            return ( undef, 'value is not a valid number or name' ) if !defined $start;
            # Wildcards and ranges were handled above, so a slash remaining
            # here can only be an invalid scalar step (for example, 5/2).
            return ( undef, 'a step requires a wildcard or range' ) if $item =~ m{/};
            $end = $start;
        }

lib/Developer/Dashboard/ProcessSupervision.pm  view on Meta::CPAN

# supply duplicated directory entries on hosts without both descriptor trees.
# Input: none.
# Output: list of descriptor-path strings.
sub _fd_candidate_paths {
    my ($self) = @_;
    return ( glob('/proc/self/fd/*'), glob('/dev/fd/*') );
}

# _descriptor_is_inherited_pipe($fd)
# Returns whether one descriptor currently points at an inherited capture or
# IPC endpoint that a detached runtime child should close after stdio has been
# redirected.
# Input: descriptor integer.
# Output: boolean true when the descriptor target is an inherited pipe,
# socketpair, or anonymous kernel handle.
sub _descriptor_is_inherited_pipe {
    my ( $self, $fd, %args ) = @_;
    return 0 if !defined $fd || $fd !~ /^\d+$/;
    my $handle;
    open( $handle, '<&', $fd ) or open( $handle, '>&', $fd ) or return 0;
    my $pipe   = -p $handle ? 1 : 0;

lib/Developer/Dashboard/RuntimeManager.pm  view on Meta::CPAN

    return $self->_start_web_background(
        host    => $host,
        port    => $port,
        workers => $workers,
        ssl     => $ssl,
    );
}

# serve_ssl_backend_foreground(%args)
# Rebuilds the normal web application in the isolated TLS backend helper and
# runs its Starman runner against the frontend's internal loopback endpoint.
# Input: internal host, internal port, and worker count.
# Output: backend runner exit status.
sub serve_ssl_backend_foreground {
    my ( $self, %args ) = @_;
    my $host = $args{host} // die 'Missing SSL backend host';
    my $port = $args{port} // die 'Missing SSL backend port';
    my $workers = $args{workers} // 1;
    die 'SSL backend port must be a positive integer' if $port !~ /\A\d+\z/ || $port < 1;
    die 'Worker count must be a positive integer' if $workers !~ /\A\d+\z/ || $workers < 1;
    my $server = $self->{app_builder}->(

lib/Developer/Dashboard/RuntimeManager.pm  view on Meta::CPAN

        host          => $host,
        port          => $port,
        internal_host => $host,
        internal_port => $port,
    );
    return $server->_run_ssl_backend_process($daemon);
}

# _start_web_background(%args)
# Launches the web listener as an independently supervised GoRoutine child and
# persists its identity after the configured endpoint accepts connections.
# Input: host, port, worker count, and ssl flag.
# Output: listener process id; dies with the child status if startup fails.
sub _start_web_background {
    my ( $self, %args ) = @_;
    my $host = defined $args{host} ? $args{host} : '0.0.0.0';
    my $port = defined $args{port} ? $args{port} : 7890;
    my $workers = defined $args{workers} ? $args{workers} : 1;
    my $ssl = $args{ssl} ? 1 : 0;

    $self->_cleanup_web_files;

lib/Developer/Dashboard/RuntimeManager.pm  view on Meta::CPAN

        $self->{files}->write( 'web_pid', "$state->{pid}\n" );
        $self->_write_web_state($state);
        return $state->{pid};
    }

    return $pid;
}

# _running_web_satisfies_request($running, $host, $port, $workers, $ssl)
# Decides whether an already running web service satisfies a background start
# request. The endpoint decides identity and must be known: an unknown host or
# port is a mismatch, never an uninitialized-value warning. A property the
# persisted payload does not carry is unverifiable rather than different, so it
# never justifies forking a second listener onto an endpoint that already
# matches, which would strand the running child as an untrackable orphan.
# Input: running web state hash reference, requested host, port, worker count,
# and ssl flag.
# Output: boolean true when the running service already satisfies the request.
sub _running_web_satisfies_request {
    my ( $self, $running, $host, $port, $workers, $ssl ) = @_;
    return 0 if !defined $running->{host} || !defined $running->{port};
    return 0 if $running->{host} ne $host;
    return 0 if $running->{port} != $port;
    return 0 if defined $running->{workers} && $running->{workers} != $workers;

lib/Developer/Dashboard/RuntimeManager.pm  view on Meta::CPAN

    my $polls = $self->_state_settle_polls;
    for my $attempt ( 1 .. $polls ) {
        my $state = $self->web_state;
        return ( $state, 0 ) if ref($state) eq 'HASH';
        return ( undef, 0 ) if !-f $file;
        sleep $self->_state_settle_interval if $attempt < $polls;
    }
    return ( undef, 1 );
}

# _web_state_with_endpoint($state, $pid)
# Builds the running-web answer for one live managed pid, filling a host or port
# the persisted payload does not carry from the live process title. Callers
# compare the reported endpoint against a requested one, so a gap in the
# persisted payload must never surface as an unknown endpoint.
# Input: persisted state hash reference and live process id.
# Output: web state hash reference carrying the live pid.
sub _web_state_with_endpoint {
    my ( $self, $state, $pid ) = @_;
    my $running = {
        %{$state},
        pid => $pid + 0,
    };
    return $running if defined $running->{host} && defined $running->{port};

    my $title = $self->_read_process_title($pid);
    if ( defined $title && $title =~ /^d2 web:\s+(\S+):(\d+)$/ ) {
        $running->{host} = defined $running->{host} ? $running->{host} : $1;

lib/Developer/Dashboard/RuntimeManager.pm  view on Meta::CPAN

sub running_web {
    my ($self) = @_;

    my ( $settled, $unresolved ) = $self->_read_settled_web_state;
    my $state = $settled || {};
    if ( my $pid = $self->{files}->read('web_pid') ) {
        chomp $pid;
        $pid = $self->_normalized_process_id($pid);
        if ( $pid && $self->_pid_is_running($pid) && $self->_same_pid_namespace($pid) ) {
            if ( $self->_is_managed_web($pid) || ( $state->{status} || '' ) eq 'running' ) {
                return $self->_web_state_with_endpoint( $state, $pid );
            }
        }
    }

    for my $proc ( $self->_find_web_processes ) {
        if ( $proc->{args} =~ /^d2 web:\s+(\S+):(\d+)$/ ) {
            return {
                %$state,
                pid          => $proc->{pid},
                host         => $1,

lib/Developer/Dashboard/RuntimeManager.pm  view on Meta::CPAN


    my $bound_host = $daemon->sockhost;
    my $bound_port = $daemon->sockport;
    my $child_pid = $self->_normalized_process_id($$);

    # The startup pipe is a private handshake with the forking parent, which
    # persists pid and state synchronously before start_web returns. Signalling it
    # before this child's own state write therefore exposes no consumer-visible
    # window: every caller that learns about the service through start_web already
    # sees persisted state, and the write below only refreshes it with the bound
    # endpoint. Keep the order - reversing it would delay the parent's read
    # without closing any window.
    $self->_write_startup_pipe_message( $writer, join( '|', 'ok', $child_pid, $bound_host, $bound_port ) . "\n" );
    # Detached startup returned above, so this child path only needs the
    # inherited-fd cleanup when its I/O was redirected.
    $self->_close_inherited_fds( close_ipc => 1 ) if $redirect;

    $self->_write_web_state(
        {
            host         => $host,
            pid          => $child_pid,

lib/Developer/Dashboard/RuntimeManager.pm  view on Meta::CPAN


Use this file when changing how the web process is launched, how restart waits for ports to free up, how collectors are stopped, restarted, or watchdog-supervised with the web process, or how runtime state is validated before a lifecycle command acts...

For cron collectors, keep scheduler-loop heartbeat separate from job progress:
an old execution timestamp is normal between scheduled runs, while a stale
loop heartbeat still indicates that the scheduler may need recovery.

The C<serve_ssl_backend_foreground> helper entry point rebuilds the normal
dashboard application in the separately supervised internal TLS backend
process. It accepts a host, positive port, and positive worker count, then
serves the TLS Starman runner on that internal endpoint and returns its exit
status. The public SSL frontend launches it through GoRoutine's native process
API so foreground and managed web serving share the same lifecycle contract.

The C<web_log> method reads the d2 log, optionally returns only the last
N lines, or follows appended data after printing that tail. A zero line count
prints no existing lines before follow mode begins; line counts must be
non-negative integers.

=head1 HOW TO USE

lib/Developer/Dashboard/SKILLS.pm  view on Meta::CPAN

=item *

C<stream_data(url, target, options, formatter)>

=back

Bookmark pages can also use the built-in C</js/jquery.js> compatibility shim
for C<$>, C<$(document).ready(...)>, and C<$.ajax(...)>.

For normal saved runtime bookmarks, C<Ajax(file =E<gt> 'name', ...)> can create
stable saved Ajax endpoints. That capability is tied to the saved runtime
bookmark path. Skill bookmarks render through the skill route surface, so do
not assume stable saved C</ajax/E<lt>fileE<gt>> handlers there unless you have
tested that path explicitly.

=head1 NAV AND DASHBOARD-WIDE CLI

Normal runtime bookmarks support shared C<nav/*.tt> fragments above non-nav
saved pages. Skill pages auto-load C<dashboards/nav/*> into
C</app/E<lt>repo-nameE<gt>> and C</app/E<lt>repo-nameE<gt>/...> routes, and
the same installed skill nav fragments are also rendered above normal saved

lib/Developer/Dashboard/Web/App.pm  view on Meta::CPAN


  my $app = Developer::Dashboard::Web::App->new(
      auth     => $auth,
      pages    => $pages,
      sessions => $sessions,
  );

=head1 DESCRIPTION

This module handles the browser-facing dashboard routes, helper login flow,
page rendering modes, and page/action execution endpoints. It also provides
static file serving for JavaScript, CSS, and other assets from the public
directory structure (~/.developer-dashboard/dashboard/public/{js,css,others}).
The browser tab icon at C</favicon.ico> is served from the same layered
C<others> roots with a bundled fallback, and resolves before the authorization
gate because browsers request it implicitly on every page load.

Cross-site request forgery defense: every state-changing request (POST, PUT,
DELETE, PATCH) passes one origin check before any trust-tier dispatch. When
the request carries an C<Origin> header (or, absent that, a C<Referer>), its
authority must equal the request's own C<Host> header or name a trusted local

lib/Developer/Dashboard/Web/App.pm  view on Meta::CPAN


Input: $type (js, css, or others), $filename (requested filename).
Output: MIME type string suitable for Content-Type header.

Supports: JS, CSS, JSON, XML, HTML, SVG, PNG, JPEG, GIF, WebP, ICO, and others.

=for comment FULL-POD-DOC START

=head1 PURPOSE

This module is the main route backend for the browser application. It handles login and logout, saved and transient page render/source/edit routes, status endpoints, saved Ajax endpoints, and the auth checks that decide whether a request is local adm...

=head1 WHY IT EXISTS

It exists because the dashboard browser surface is large and security-sensitive. Centralizing route behavior, auth gating, saved-page handling, Ajax endpoints, layered C<config/api.json> machine auth, and response shaping keeps the product behavior c...

=head1 WHEN TO USE

Use this file when changing browser routes, helper login behavior, page render/source/edit flows, saved Ajax endpoints, or the runtime JSON and HTML responses for dashboard workspaces.

=head1 HOW TO USE

Construct it with the action runner, auth service, config service, page store, prompt, page resolver, page runtime, and session store, then hand it to the Dancer adapter or PSGI bootstrap. Route-specific behavior belongs here rather than in the trans...

For each request, C<handle()> lazily captures merged runtime configuration
only when web settings or collector status needs it. Authorization, page chrome,
and status assembly share that request-local snapshot, including its skill
config entries; the snapshot is discarded on return so changes appear on the
next request. Across requests, Linux may use inotify as an invalidation hint;

lib/Developer/Dashboard/Web/Server.pm  view on Meta::CPAN

        }
        sleep 0.05;
    }
    _stop_ssl_backend($pid);
    die 'Timed out waiting for SSL backend listener readiness';
}

# _ssl_backend_command($daemon)
# Builds the staged-core command that runs the isolated SSL Starman backend,
# resolving the core dispatcher beside the current helper wrapper.
# Input: daemon descriptor with public and internal endpoints.
# Output: argv array reference safe for GoRoutine's native process API.
sub _ssl_backend_command {
    my ( $self, $daemon ) = @_;
    if ( ref( $self->{ssl_backend_command_builder} ) eq 'CODE' ) {
        my $command = $self->{ssl_backend_command_builder}->(
            $daemon->internal_sockhost,
            $daemon->internal_sockport,
            $self->{workers},
        );
        die 'SSL backend command builder must return an argv array reference'

lib/Developer/Dashboard/Web/Server.pm  view on Meta::CPAN


=head1 SSL SUPPORT

The public front-proxy owns the external listener. It starts the internal
Starman server with the private C<web-ssl-backend-foreground> helper using an
argument vector, not a shell command. The command targets the staged
C<_dashboard-core> dispatcher beside the running helper rather than reusing
the command wrapper named by C<DEVELOPER_DASHBOARD_RUNNING_HELPER>; wrappers
prepend their own command name and would otherwise recursively start SSL
frontends. The helper reconstructs the ordinary application and serves only on
the reserved internal endpoint. Startup is not considered ready until a TLS
handshake succeeds. Readiness checks detect exited-but-unreaped child
processes, and premature helper exit and timeout are reported as errors.

Each accepted client socket is handed to a GoRoutine worker with shared socket,
daemon descriptor, and minimal host/SAN state. Workers use bounded readiness
waits so shutdown cancellation also works when a client remains idle. The
front-end cancels and joins workers before stopping and waiting for the backend,
and surfaces worker failures unless shutdown itself requested cancellation.
Socket close errors are retained while workers and the managed backend are
cleaned up, then reported so a failed close cannot strand the backend process.

lib/Developer/Dashboard/Zipper.pm  view on Meta::CPAN

        html    => sprintf(
            q{<a href="%s" target="%s">%s</a>},
            _escape_html_attr($url),
            _escape_html_attr( $args{target} || '_blank' ),
            _escape_html( $args{label} || 'Click Here' ),
        ),
    };
}

# Ajax(%args)
# Prints a older config-binding script for an encoded ajax endpoint.
# Input: jvar, type, optional file/singleton names, and optional code values.
# Output: hide marker string.
# DD-895: $path (the jvar substring after the first '.') and the ajax url
# are both JS STRING content in the emitted <script> tag, so both go
# through _js_single_quote before interpolation - matching how
# $args{singleton} was already correctly handled two lines away. $root
# (the jvar substring before the first '.') stays unescaped by design: it
# is interpolated as a bare JS identifier/property-access expression
# (e.g. `window` or `someObj`), not as string content, so JS-string
# escaping would be the wrong treatment for it.

lib/Developer/Dashboard/Zipper.pm  view on Meta::CPAN

executable files so the web runtime can run them as real processes.
When callers supply C<data>, C<Ajax> renders its C<code> string with Template
Toolkit before either storing a saved handler or encoding a transient token.
This ordering ensures the encoded payload contains executable Perl rather than
unrendered C<[% ... %]> directives.

=for comment FULL-POD-DOC START

=head1 PURPOSE

This module keeps the older bookmark and Ajax helper compatibility surface alive. It builds tokenised URLs, saved Ajax endpoints, and helper snippets such as C<Ajax()> while routing the actual encoding work through the modern codec module.

=head1 WHY IT EXISTS

It exists because older bookmarks still expect the historical helper names and URL-building patterns. Keeping those wrappers in one module preserves compatibility without forcing newer runtime code to keep re-implementing the old API directly.

=head1 WHEN TO USE

Use this file when changing older Ajax helper behavior, saved Ajax file validation, token URL generation, or the compatibility wrappers that older bookmark instructions still reference.

=head1 HOW TO USE

script/audit-action-pins  view on Meta::CPAN


=item *

C<FAIL> - the pin was resolved and is wrong: it declares a runtime below node24,
or its version comment names a tag that resolves to a different commit.

=item *

C<UNUSABLE> - the pin could not be resolved at all, so this run found nothing
out. This is never reported as success. An unauthenticated run can hit the
GitHub rate limit, and the C</repos/.../commits/{sha}> endpoint is unreliable
for some large repositories, so the manifest is read through the contents API
instead.

=back

Exit codes are C<0> clean, C<1> findings, C<2> usage error, C<3> could not
audit.

=head1 WHAT USES IT

script/problem48-saved-page-route-benchmark  view on Meta::CPAN

=head1 PURPOSE

Measures the warmed production C<Web::App-E<gt>handle('/app/welcome')> path
with a configurable number of saved C<nav/*.tt> fragments, an isolated temporary HOME, strict
HTTP/body validation, configurable installed-skill navigation fragments, and
optional collector indicators and NYTProf profiling.

=head1 WHY IT EXISTS

Problem 48 needs performance evidence at ordinary application boundaries, not
only the status endpoint. This tool compares the same fixture on v5.88 and the
current source tree and supports larger nav sets to measure how per-request
root discovery scales. It normalizes only the live status timestamp, then
requires the remainder of every response to stay byte-identical during the
run.

=head1 WHEN TO USE

Run after changes to saved-page routing, Template Toolkit preparation, page
chrome, saved navigation discovery, or request-local runtime caches. Compare
the output from both source trees before attributing a speedup to a change.

script/problem48-status-route-benchmark  view on Meta::CPAN

The profile commands keep initialization and warmup outside the timed/profiled
section. The benchmark creates and removes its synthetic HOME automatically.
Its NYTProf output path is supplied through C<NYTPROF> and should remain in an
isolated ignored working directory. C<config_merges>, C<watcher_checks>,
C<watcher_hits>, and C<collector_projections> report real cache behavior
alongside the route timing.

=head1 WHAT USES IT

Problem 48 performance research uses this script to determine whether
micro-optimizations affect the actual status endpoint and to choose subsequent
work from a production-route call tree.

=head1 EXAMPLES

Example 1: run the 50-indicator route comparison.

  d2 docker compose exec dev perl script/problem48-status-route-benchmark

Example 2: profile the currently selected library after warmup.

t/03-web-app.t  view on Meta::CPAN

like($body4, qr/Right Click Copy &amp; Share or Bookmark This Page/, 'legacy render includes top chrome share link');
unlike($body4, qr/\{legacy-welcome:[^}]+\}/, 'top chrome does not dump shell prompt project context');
unlike($body4, qr/\[\w{3}\s+\w{3}/, 'top chrome does not dump shell prompt timestamps');
like($body4, qr/id="status-on-top"/, 'legacy render includes old top-status container');
like($body4, qr/class="user-name-and-icon"/, 'legacy render includes top-right user marker');
like($body4, qr/id="status-server"/, 'legacy render includes top-right server marker');
like($body4, qr/10\.20\.30\.40/, 'legacy render includes machine ip instead of request host');
like($body4, qr/id="status-datetime"/, 'legacy render includes live-updated date-time marker');

my ($status_code, $status_type, $status_body) = @{ $app->handle(path => '/system/status', query => '', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' }) };
is($status_code, 200, 'legacy status endpoint route ok');
like($status_type, qr/application\/json/, 'legacy status endpoint returns json');
like($status_body, qr/"array"\s*:/, 'legacy status endpoint returns array payload');
$config->save_global(
    {
        collectors => [
            {
                name      => 'vpn',
                code      => 'return 0;',
                cwd       => 'home',
                indicator => {
                    icon => '🔑',
                },
            },
        ],
    }
);
my ($status_icon_code, undef, $status_icon_body) = @{ $app->handle(path => '/system/status', query => '', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' }) };
is($status_icon_code, 200, 'legacy status endpoint still responds after syncing config-backed collector indicators');
like(decode('UTF-8', $status_icon_body), qr/"alias"\s*:\s*"🔑"/, 'legacy status endpoint exposes configured collector indicator icons instead of collector names');
like($app->_prompt_summary, qr/🔑/, 'page top-right prompt summary prefers the configured collector indicator icon');
my $status_indicator_list_calls = 0;
my $list_indicators = \&Developer::Dashboard::IndicatorStore::list_indicators;
my ( $single_list_status_code, undef, $single_list_status_body );
{
    no warnings 'redefine';
    local *Developer::Dashboard::IndicatorStore::list_indicators = sub {
        $status_indicator_list_calls++;
        return $list_indicators->(@_);
    };

t/03-web-app.t  view on Meta::CPAN

$config->save_global_web_settings( no_editor => 0 );
$config->save_global_web_settings( no_indicators => 1 );
my ($noind_render_code, undef, $noind_render_body) = @{ $app->handle(path => '/app/welcome', query => '', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' }) };
is($noind_render_code, 200, 'no-indicators mode still renders saved pages');
unlike($noind_render_body, qr/id="status-on-top"/, 'no-indicators mode hides the top-right indicator strip');
unlike($noind_render_body, qr/id="status-datetime"/, 'no-indicators mode hides the top-right date-time marker');
unlike($noind_render_body, qr/id="status-server"/, 'no-indicators mode hides the top-right server marker');
unlike($noind_render_body, qr/class="user-name-and-icon"/, 'no-indicators mode hides the top-right username marker');
like($app->_prompt_summary, qr/🔑/, 'no-indicators mode does not change prompt-summary data generation');
my ($noind_status_code, undef, $noind_status_body) = @{ $app->handle(path => '/system/status', query => '', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' }) };
is($noind_status_code, 200, 'no-indicators mode keeps the status endpoint available');
like(decode('UTF-8', $noind_status_body), qr/"alias"\s*:\s*"🔑"/, 'no-indicators mode keeps status endpoint indicator payloads intact');
$config->save_global_web_settings( no_indicators => 0 );
$config->save_global(
    {
        collectors => [
            {
                name      => 'vpn-renamed',
                code      => 'return 0;',
                cwd       => 'home',
                indicator => {
                    icon => '🔑',
                },
            },
        ],
    }
);
my ($status_rename_code, undef, $status_rename_body) = @{ $app->handle(path => '/system/status', query => '', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' }) };
is($status_rename_code, 200, 'legacy status endpoint still responds after a collector rename');
unlike($status_rename_body, qr/"prog"\s*:\s*"vpn"/, 'legacy status endpoint removes stale managed collector indicators after a collector rename');
like($status_rename_body, qr/"prog"\s*:\s*"vpn-renamed"/, 'legacy status endpoint keeps the renamed collector indicator');

my $legacy_token = $store->encode_page($legacy_page);
my ($code5, undef, $body5) = @{ $app->handle(path => '/', query => "mode=render&token=$legacy_token", remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' }) };
is($code5, 200, 'legacy transient page route ok');
like($body5, qr/<div>Runtime<\/div>/, 'legacy transient pages execute CODE blocks through the same runtime');

my ($code5b, undef, $body5b) = @{ $app->handle(path => '/app/legacy-welcome', query => 'name=Michael', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' }) };
is($code5b, 200, 'legacy /app route with query params ok');
like($body5b, qr/Hello Michael/, 'legacy /app bookmark merges request params into stash');

my $legacy_ajax_page = Developer::Dashboard::PageDocument->from_instruction(<<'PAGE');
TITLE: Legacy Ajax
:--------------------------------------------------------------------------------:
BOOKMARK: legacy-ajax
:--------------------------------------------------------------------------------:
HTML: <script>var configs = {};</script>
:--------------------------------------------------------------------------------:
CODE1: Ajax jvar => 'configs.demo.endpoint', type => 'json', code => q{
  print j { ok => 1 };
}, file => 'demo.json';
PAGE
$store->save_page($legacy_ajax_page);

my ($code6, undef, $body6) = @{ $app->handle(path => '/app/legacy-ajax', query => '', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' }) };
is($code6, 200, 'legacy /app route renders bookmark');
like($body6, qr/set_chain_value\(configs,'demo\.endpoint','\/ajax\/demo\.json\?type=json/, 'legacy Ajax helper injects a saved bookmark ajax endpoint when a file is supplied');
ok( -f File::Spec->catfile( $paths->dashboards_root, 'ajax', 'demo.json' ), 'legacy Ajax helper stores the saved bookmark ajax code under the dashboards ajax tree' );

my ($code7, $type7, $body7) = @{ $app->handle(path => '/ajax/demo.json', query => "type=json", remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' }) };
is($code7, 200, 'legacy ajax endpoint executes through the saved bookmark ajax file route');
like($type7, qr/application\/json/, 'legacy ajax endpoint returns json type');
like(drain_stream_body($body7), qr/"ok"\s*:\s*1/, 'legacy ajax endpoint returns encoded payload output as a stream');

my $existing_ajax_dir = File::Spec->catdir( $paths->dashboards_root, 'ajax' );
make_path($existing_ajax_dir);
my $existing_ajax_file = File::Spec->catfile( $existing_ajax_dir, 'existing.sh' );
open my $existing_ajax_fh, '>', $existing_ajax_file or die $!;
print {$existing_ajax_fh} "#!/bin/sh\nprintf 'existing-out\\n'\nprintf 'existing-err\\n' >&2\n";
close $existing_ajax_fh;
chmod 0700, $existing_ajax_file or die $!;

my $legacy_existing_ajax_page = Developer::Dashboard::PageDocument->from_instruction(<<'PAGE');
TITLE: Legacy Existing Ajax
:--------------------------------------------------------------------------------:
BOOKMARK: legacy-ajax-existing
:--------------------------------------------------------------------------------:
HTML: <script>var configs = {};</script>
:--------------------------------------------------------------------------------:
CODE1: Ajax jvar => 'configs.demo.endpoint', type => 'text', file => 'existing.sh';
PAGE
$store->save_page($legacy_existing_ajax_page);

my ($code7b, undef, $body7b) = @{ $app->handle(path => '/app/legacy-ajax-existing', query => '', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' }) };
is($code7b, 200, 'legacy /app route renders bookmark that points at an existing ajax file');
like($body7b, qr/set_chain_value\(configs,'demo\.endpoint','\/ajax\/existing\.sh\?type=text/, 'legacy Ajax helper injects an existing saved bookmark ajax endpoint when only a file is supplied');
my $bootstrap_pos = index( $body7b, 'function set_chain_value' );
my $binding_pos   = index( $body7b, q{set_chain_value(configs,'demo.endpoint','/ajax/existing.sh?type=text'} );
ok( $bootstrap_pos > -1 && $binding_pos > $bootstrap_pos, 'legacy bootstrap is defined before saved Ajax bindings run in render mode' );

my ($code7d, $type7d, $body7d) = @{ $app->handle(path => '/ajax/existing.sh', query => "type=text", remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' }) };
is($code7d, 200, 'saved bookmark ajax file route executes an existing ajax executable from the dashboards ajax tree');
like($type7d, qr/text\/plain/, 'existing ajax executable returns text type');
my $existing_stream = drain_stream_body($body7d);
like($existing_stream, qr/existing-out/, 'existing ajax executable streams stdout');
like($existing_stream, qr/existing-err/, 'existing ajax executable streams stderr');

my ($jquery_code, $jquery_type, $jquery_body) = @{ $app->handle(path => '/js/jquery.js', query => '', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' }) };

t/03-web-app.t  view on Meta::CPAN

:--------------------------------------------------------------------------------:
CODE1: Ajax jvar => 'foo.bar', file => 'foobar', code => q{
print 123
};
PAGE
$store->save_page($legacy_jquery_ajax_page);

my ($jquery_page_code, undef, $jquery_page_body) = @{ $app->handle(path => '/app/test-jquery-ajax', query => '', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' }) };
is($jquery_page_code, 200, 'legacy jquery ajax bookmark route renders');
like($jquery_page_body, qr{<script src="/js/jquery\.js"></script>}, 'legacy jquery ajax bookmark keeps the jquery helper script tag');
like($jquery_page_body, qr{set_chain_value\(foo,'bar','/ajax/foobar\?type=text'\)}, 'legacy jquery ajax bookmark binds foo.bar to the saved ajax endpoint with default text type');
my ($jquery_ajax_code, $jquery_ajax_type, $jquery_ajax_body) = @{ $app->handle(path => '/ajax/foobar', query => '', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' }) };
is($jquery_ajax_code, 200, 'legacy jquery ajax bookmark saved endpoint is executable');
like($jquery_ajax_type, qr/text\/plain/, 'legacy jquery ajax bookmark saved endpoint defaults to text content type when no type is supplied');
is(drain_stream_body($jquery_ajax_body), '123', 'legacy jquery ajax bookmark saved endpoint returns the code output');

my $fetch_stream_page = Developer::Dashboard::PageDocument->from_instruction(<<'PAGE');
BOOKMARK: fetch-stream-helpers
:--------------------------------------------------------------------------------:
HTML: <script src="/js/jquery.js"></script>
<span id="foo"></span><br>
<div id="bar"></div>
<span id="mike"></span><br>
<script>
var endpoints = {};
$(document).ready(function () {
  fetch_value(endpoints.foo, '#foo');
  stream_value(endpoints.bar, '#bar', { type: 'text' });
  fetch_value(endpoints.mike, '#mike', { type: 'json' }, function (value) {
    return value.ok > 0 ? 'OK' : 'Error';
  });
});
</script>
:--------------------------------------------------------------------------------:
CODE1: Ajax jvar => 'endpoints.foo', file => 'foo', code => q{
  print "This is foo echo";
};
:--------------------------------------------------------------------------------:
CODE2: Ajax jvar => 'endpoints.bar', file => 'bar', singleton => 'BAR', code => q{
  print "bar-one\n";
  print "bar-two\n";
};
:--------------------------------------------------------------------------------:
CODE3: Ajax jvar => 'endpoints.mike', file => 'mike', type => 'json', code => q{
  use Developer::Dashboard::DataHelper qw( j );
  print j { ok => 1 };
};
PAGE
$store->save_page($fetch_stream_page);
my ($fetch_stream_code, undef, $fetch_stream_body) = @{ $app->handle(path => '/app/fetch-stream-helpers', query => '', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' }) };
is($fetch_stream_code, 200, 'legacy bookmark with fetch_value and stream_value helpers renders');
like($fetch_stream_body, qr/function fetch_value\(url, target, options, formatter\)/, 'legacy bookmark bootstrap exposes fetch_value helper');
like($fetch_stream_body, qr/function stream_value\(url, target, options, formatter\)/, 'legacy bookmark bootstrap exposes stream_value helper');
like($fetch_stream_body, qr/function stream_data\(url, target, options, formatter\)/, 'legacy bookmark bootstrap exposes stream_data helper');
like($fetch_stream_body, qr/new XMLHttpRequest\(\)/, 'legacy bookmark streaming helper uses XMLHttpRequest for progressive browser updates');
like($fetch_stream_body, qr/xhr\.onprogress = function \(\)/, 'legacy bookmark streaming helper updates targets from incremental ajax progress events');
my $foo_bind_pos = index($fetch_stream_body, q{set_chain_value(endpoints,'foo','/ajax/foo?type=text'});
my $bar_bind_pos = index($fetch_stream_body, q{set_chain_value(endpoints,'bar','/ajax/bar?type=text&singleton=BAR'});
my $mike_bind_pos = index($fetch_stream_body, q{set_chain_value(endpoints,'mike','/ajax/mike?type=json'});
my $endpoints_decl_pos = index($fetch_stream_body, q{var endpoints = {};});
my $fetch_call_pos = index($fetch_stream_body, q{fetch_value(endpoints.foo, '#foo');});
ok($foo_bind_pos > -1 && $bar_bind_pos > -1 && $mike_bind_pos > -1, 'legacy bookmark render includes all saved Ajax endpoint bindings for fetch_value and stream_value');
ok($endpoints_decl_pos > -1, 'legacy bookmark render keeps the caller endpoint variable declaration');
ok($foo_bind_pos > $endpoints_decl_pos && $bar_bind_pos > $endpoints_decl_pos && $mike_bind_pos > $endpoints_decl_pos, 'saved Ajax endpoint bindings render after the caller declares the endpoint root object');
ok($fetch_call_pos > -1, 'legacy bookmark render keeps the inline fetch helper call');
like($fetch_stream_body, qr/dashboard_ajax_singleton_cleanup\('BAR'\)/, 'legacy bookmark render keeps singleton cleanup bindings for stream_value pages');

my $stream_data_page = Developer::Dashboard::PageDocument->from_instruction(<<'PAGE');
BOOKMARK: stream-data-helper
:--------------------------------------------------------------------------------:
HTML: <script src="/js/jquery.js"></script>
<script>var foo = {};
$(document).ready(function () {
  stream_data(foo.bar, '.display');

t/03-web-app.t  view on Meta::CPAN

    while (1) {
      print 123;
      sleep 1;
    }
};
PAGE
$store->save_page($stream_data_page);
my ($stream_data_code, undef, $stream_data_body) = @{ $app->handle(path => '/app/stream-data-helper', query => '', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' }) };
is($stream_data_code, 200, 'legacy bookmark with stream_data helper renders');
like($stream_data_body, qr{stream_data\(foo\.bar, '\.display'\);}, 'legacy bookmark render keeps the inline stream_data helper call');
like($stream_data_body, qr{set_chain_value\(foo,'bar','/ajax/foobar\?type=text&singleton=FOOBAR'\)}, 'legacy bookmark render binds stream_data ajax endpoint before browser execution');

{
    open my $fh, '>', $store->page_file('legacy-forward') or die $!;
    print {$fh} '/ajax/demo.json?type=text';
    close $fh;
}
my $raw_named_page = eval { $app->_load_named_page('legacy-forward') };
ok(!defined($raw_named_page) && !$@, 'saved URL entries do not leak PageDocument section errors through named-page loading');
my ($code8, $type8, $body8) = @{ $app->handle(path => '/app/legacy-forward', query => '', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' }) };
is($code8, 200, 'legacy /app saved-url forwarding works');

t/05-cli-smoke.t  view on Meta::CPAN

            {},
        );
    }
    my $status_ua = LWP::UserAgent->new( timeout => 5 );
    my $status_response;
    for ( 1 .. _startup_probe_attempts() ) {
        $status_response = $status_ua->get("http://127.0.0.1:$live_status_port/system/status");
        last if $status_response->is_success;
        sleep 0.25;
    }
    ok( $status_response && $status_response->is_success, 'live foreground runtime exposes the system status endpoint' );
    like( decode( 'UTF-8', $status_response->content ), qr/"alias"\s*:\s*"🔑"/, 'live foreground runtime syncs configured collector indicator icons into system status' );
    ok( Developer::Dashboard::GoRoutine::terminate_process( $live_status_pid, 'TERM' ),
        'live foreground status process stops through the GoRoutine process API' );

    # On Windows there is no signal delivery to another process, so
    # terminate_process ends it with TerminateProcess and the exit code is
    # the XS's 128+signal convention (143 for TERM, as on Unix when a
    # process dies by SIGTERM). A clean 0 is only possible where the
    # process can catch SIGTERM and exit itself.
    my $expected_reap = $^O eq 'MSWin32' ? 143 : 0;

t/05-cli-smoke.t  view on Meta::CPAN

    unlike( $noind_render_body, qr/id="status-on-top"/, 'no-indicators live server hides the top-right indicator strip' );
    unlike( $noind_render_body, qr/id="status-datetime"/, 'no-indicators live server hides the top-right date-time marker' );
    unlike( $noind_render_body, qr/id="status-server"/, 'no-indicators live server hides the top-right server marker' );
    unlike( $noind_render_body, qr/class="user-name-and-icon"/, 'no-indicators live server hides the top-right user marker' );
    my $noind_status_response;
    for ( 1 .. 240 ) {
        $noind_status_response = $noind_ua->get("http://127.0.0.1:$noind_port/system/status");
        last if $noind_status_response->code == 200;
        sleep 0.25;
    }
    is( $noind_status_response->code, 200, 'no-indicators live server keeps the status endpoint available' );
    like( decode( 'UTF-8', $noind_status_response->decoded_content ), qr/"array"\s*:/, 'no-indicators live server still exposes status payload data' );
    my $noind_ps1 = _run_in_home( $noind_home, "$perl -I'$lib' '$dashboard' ps1 --jobs 0" );
    like( $noind_ps1, qr/\S/, 'no-indicators mode does not blank the terminal prompt output' );
    my $noind_config_file = File::Spec->catfile( $noind_home, '.developer-dashboard', 'config', 'config.json' );
    open my $noind_config_fh, '<', $noind_config_file or die "Unable to read $noind_config_file: $!";
    my $noind_config = do { local $/; <$noind_config_fh> };
    close $noind_config_fh;
    like( $noind_config, qr/"web"\s*:\s*\{[\s\S]*"no_indicators"\s*:\s*1/s, 'd2 serve --no-indicator persists no_indicators in config' );
    my $noind_restart = json_decode( _run_in_home( $noind_home, "$perl -I'$lib' '$dashboard' restart -o json --host 127.0.0.1 --port $noind_port" ) );
    ok( $noind_restart->{web_pid}, 'd2 restart keeps managing the no-indicators web service' );

t/08-web-update-coverage.t  view on Meta::CPAN

    like( $ajax_bad_file_type, qr/text\/plain/, 'legacy ajax invalid saved-file route returns plain text' );
    like( $ajax_bad_file_body, qr/invalid parent traversal/, 'legacy ajax invalid saved-file route returns the validation error text' );
}

{
    my $streaming_page = Developer::Dashboard::PageDocument->from_instruction(<<'PAGE');
BOOKMARK: ajax-stream
:--------------------------------------------------------------------------------:
HTML: <script>var configs = {};</script>
:--------------------------------------------------------------------------------:
CODE1: Ajax jvar => 'configs.demo.endpoint', type => 'text', file => 'stream.txt', code => q{
  print "first\n";
  print "second\n";
};
PAGE
    $store->save_page($streaming_page);
    my ( undef, undef, undef ) = @{ $app->handle( path => '/app/ajax-stream', query => '', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' } ) };
    my ( $ajax_stream_code, $ajax_stream_type, $ajax_stream_body ) = @{ $app->handle( path => '/ajax/stream.txt', query => 'type=text', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' } ) };
    is( $ajax_stream_code, 200, 'legacy ajax saved-file route responds successfully for streaming output' );
    like( $ajax_stream_type, qr/text\/plain/, 'legacy ajax saved-file route keeps the requested content type for streaming output' );
    is( drain_stream_body($ajax_stream_body), "first\nsecond\n", 'legacy ajax saved-file route streams raw printed output without page buffering' );
}

{
    my $process_page = Developer::Dashboard::PageDocument->from_instruction(<<'PAGE');
BOOKMARK: ajax-process
:--------------------------------------------------------------------------------:
HTML: <script>var configs = {};</script>
:--------------------------------------------------------------------------------:
CODE1: Ajax jvar => 'configs.demo.endpoint', type => 'text', file => 'process-endpoint.json', code => q{
print "perl-start\n";
warn "perl-warn\n";
if ( $^O eq 'MSWin32' ) { system 'cmd', '/d', '/c', 'echo child-out & echo child-err 1>&2'; } else { system 'sh', '-c', 'printf "child-out\n"; printf "child-err\n" >&2'; }
die "perl-die\n";
};
PAGE
    $store->save_page($process_page);
    my ( undef, undef, undef ) = @{ $app->handle( path => '/app/ajax-process', query => '', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' } ) };
    my ( $ajax_process_code, $ajax_process_type, $ajax_process_body ) = @{ $app->handle( path => '/ajax/process-endpoint.json', query => 'type=text', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' } ) };
    my $ajax_process_output = drain_stream_body($ajax_process_body);
    is( $ajax_process_code, 200, 'legacy ajax saved-file process route responds successfully for mixed stdout and stderr output' );
    like( $ajax_process_type, qr/text\/plain/, 'legacy ajax saved-file process route keeps the requested content type' );
    like( $ajax_process_output, qr/perl-start/, 'legacy ajax saved-file process route streams direct perl stdout' );
    like( $ajax_process_output, qr/perl-warn/, 'legacy ajax saved-file process route streams perl stderr warnings' );
    like( $ajax_process_output, qr/child-out/, 'legacy ajax saved-file process route streams child process stdout' );
    like( $ajax_process_output, qr/child-err/, 'legacy ajax saved-file process route streams child process stderr' );
    like( $ajax_process_output, qr/perl-die/, 'legacy ajax saved-file process route streams uncaught perl die output' );
}

{
    my $singleton_page = Developer::Dashboard::PageDocument->from_instruction(<<'PAGE');
BOOKMARK: ajax-singleton
:--------------------------------------------------------------------------------:
HTML: <script>var configs = {};</script>
:--------------------------------------------------------------------------------:
CODE1: Ajax jvar => 'configs.demo.endpoint', type => 'text', singleton => 'FOOBAR', file => 'singleton-endpoint.txt', code => q{
print "$0\n";
};
PAGE
    $store->save_page($singleton_page);
    my ( undef, undef, $singleton_page_body ) = @{ $app->handle( path => '/app/ajax-singleton', query => '', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' } ) };
    like( $singleton_page_body, qr{/ajax/singleton-endpoint\.txt\?type=text&singleton=FOOBAR}, 'saved bookmark Ajax page emits the singleton query parameter in the generated ajax url' );
    like( $singleton_page_body, qr/dashboard_ajax_singleton_cleanup\('FOOBAR'\)/, 'saved bookmark Ajax page registers browser lifecycle cleanup for singleton-managed workers' );
    my ( $ajax_singleton_code, undef, $ajax_singleton_body ) = @{ $app->handle( path => '/ajax/singleton-endpoint.txt', query => 'type=text&singleton=FOOBAR', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' } ) };
    my $ajax_singleton_output = drain_stream_body($ajax_singleton_body);
    is( $ajax_singleton_code, 200, 'legacy ajax saved-file route responds successfully for singleton-managed requests' );
    like( $ajax_singleton_output, qr/^d2 ajax: FOOBAR$/m, 'legacy ajax saved-file route renames singleton-managed Perl workers before streaming output' );
}

{
    my @patterns;
    {
        no warnings 'redefine';
        local *Developer::Dashboard::RuntimeManager::_pkill_perl = sub {

t/08-web-update-coverage.t  view on Meta::CPAN

        'singleton stop route and direct response target the matching saved ajax worker process title',
    );
}

{
    my $shebang_page = Developer::Dashboard::PageDocument->from_instruction(<<'PAGE');
BOOKMARK: ajax-shebang
:--------------------------------------------------------------------------------:
HTML: <script>var configs = {};</script>
:--------------------------------------------------------------------------------:
CODE1: Ajax jvar => 'configs.demo.endpoint', type => 'text', file => 'script-runner', code => qq{#!/bin/sh\nprintf 'shell-out\\n'\nprintf 'shell-err\\n' >&2\n};
PAGE
    $store->save_page($shebang_page);
    my ( undef, undef, undef ) = @{ $app->handle( path => '/app/ajax-shebang', query => '', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' } ) };
    my ( $ajax_shebang_code, undef, $ajax_shebang_body ) = @{ $app->handle( path => '/ajax/script-runner', query => 'type=text', remote_addr => '127.0.0.1', headers => { host => '127.0.0.1' } ) };
    my $ajax_shebang_output = drain_stream_body($ajax_shebang_body);
    is( $ajax_shebang_code, 200, 'legacy ajax saved-file route executes shebang scripts directly' );
    like( $ajax_shebang_output, qr/shell-out/, 'legacy ajax saved-file route streams direct executable stdout' );
    like( $ajax_shebang_output, qr/shell-err/, 'legacy ajax saved-file route streams direct executable stderr' );
}

t/08-web-update-coverage.t  view on Meta::CPAN

        headers     => {
            host            => $api_host,
            'x-dd-api-key'    => 'runtime-client',
            'x-dd-api-secret' => 'wrong-secret',
        },
    ) };
    is( $registered_bad_api_code, 403, 'registered remote ajax route rejects invalid API secrets' );
    is_deeply( json_decode( decode_body_text($registered_bad_api_body) ), { status => 'forbidden' }, 'registered remote ajax route keeps the forbidden JSON payload for invalid API secrets' );

    my ( $unregistered_remote_code, undef, $unregistered_remote_body ) = @{ $app->handle(
        path        => '/ajax/process-endpoint.json',
        query       => 'type=text',
        remote_addr => '127.0.0.1',
        headers     => { host => $api_host },
    ) };
    is( $unregistered_remote_code, 401, 'unregistered remote ajax routes still follow the existing helper-auth flow' );
    is( $unregistered_remote_body, '', 'unregistered remote ajax routes stay silent before helper users exist' );

    my ( $runtime_api_code, $runtime_api_type, $runtime_api_body ) = @{ $app->handle(
        path        => '/ajax/stream.txt',
        query       => 'type=text',

t/09-runtime-manager.t  view on Meta::CPAN

is(
    $ssl_backend_manager->serve_ssl_backend_foreground(
        host => '127.0.0.1', port => 17898, workers => 2,
    ),
    23,
    'foreground SSL backend delegates to the app server process runner',
);
is_deeply(
    [ @{$ssl_backend_server}{qw(host port workers ssl)} ],
    [ '127.0.0.1', 17898, 2, 1 ],
    'foreground SSL backend builds the app with its internal endpoint and SSL settings',
);
is_deeply(
    [ $ssl_backend_server->{daemon}->sockhost, $ssl_backend_server->{daemon}->sockport,
      $ssl_backend_server->{daemon}->internal_sockhost, $ssl_backend_server->{daemon}->internal_sockport ],
    [ '127.0.0.1', 17898, '127.0.0.1', 17898 ],
    'foreground SSL backend daemon binds only the supplied internal endpoint',
);

dies_like( sub { Developer::Dashboard::RuntimeManager->new }, qr/Missing config/, 'runtime manager requires config' );
dies_like( sub { Developer::Dashboard::RuntimeManager->new( config => $config ) }, qr/Missing file registry/, 'runtime manager requires files' );
dies_like( sub { Developer::Dashboard::RuntimeManager->new( config => $config, files => $files ) }, qr/Missing path registry/, 'runtime manager requires paths' );
dies_like( sub { Developer::Dashboard::RuntimeManager->new( config => $config, files => $files, paths => $paths ) }, qr/Missing collector runner/, 'runtime manager requires runner' );
dies_like( sub { Developer::Dashboard::RuntimeManager->new( config => $config, files => $files, paths => $paths, runner => $runner ) }, qr/Missing app builder/, 'runtime manager requires app builder' );

is( $manager->_web_process_title( '0.0.0.0', 7890 ), 'd2 web: 0.0.0.0:7890', 'web process title is predictable' );
like( Developer::Dashboard::RuntimeManager::_now_iso8601( tz => 'utc' ), qr/^\d{4}-\d{2}-\d{2}T/, 'timestamp helper emits ISO-8601' );



( run in 4.545 seconds using v1.01-cache-2.11-cpan-eb134014566 )