junco-profile-optimizer
Skill1 starsChanged 33 days agoMITView on GitHub
Profile and tune an existing Junco workflow pair (`workflow.yml` + `workflow.ts`) until a measured objective converges: scheduler, model-ladder and limit experiments that minimize or maximize recorded USD, tokens, memory, an existing numeric edge probe or a fixed external result while quality thresholds hold. Use when the user wants to profile, tune, cheapen, speed up or shrink a Junco/JuncoGraph workflow, compare schedulers or model ladders on it, or "optimize until it stops improving" — even without saying "profile optimizer". Not for authoring new workflows (junco-graph-create) or for unmeasured advice.
In this repository8 other files it gives its agents.
- AGENTS.mdAGENTS.md
- crates/junco-policy/AGENTS.mdAGENTS.md
- crates/marsh/AGENTS.mdAGENTS.md
- packages/junco-agent/AGENTS.mdAGENTS.md
- update-dependenciesSkill
- graftSkill
- junco-graph-createSkill
- junco-graph-optimizerSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
Never invent a quality judge, metric producer, workload, model ID, fallback model or credential.
- Distinctive: line 17
No implicit or hidden iteration cap.
- Distinctive: line 22
Read the pair and how it is invoked today (scripts, README, CI, the user's command).
- Distinctive: line 55
Follow references/profiling.md, in this order:
- Very specific: line 63
Request: Write <sessionDir>/request.json per Request schema and example.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Junco profile optimizer
This skill inspects an existing pair, asks for missing intent, prepares the target once, writes one request, invokes the optimizer once and reports. The library (workflows.optimizer, schedules.runOptimizer from junco) owns the optimizer/editor loop: fresh child executions, JsonlRecorder evidence, per-batch means and sample standard deviations, rejection of previously tried configurations, promotion and convergence, and a fixed GPT-6.1 Sol editor (github-copilot/gpt-6.1-sol, thinking high) proposing one-coordinate patches to the tuning regions. The agent proposes; the host scores, accepts and stops. Never copy, wrap or re-implement optimizer code, write an outer experiment loop, write scores, impose hidden quotas, or hand the editor a fixed candidate catalog.
references/profiling.md holds the execution model, run protocol, request schema, instrumentation template, axes, metrics and evidence contracts. Read it before preparing a target.
Hard constraints
- The YAML file stays byte-identical: no new nodes, edges, labels, probes or type changes in the file. Probes are enabled per run on a runtime copy of existing numeric edges only.
- Preserve the entrypoint, invocation, graph-building options, code-node bodies, tools, sandbox/permissions, ownership, inputs, terminal checks and every existing hard limit. Raising or removing a limit is never a candidate.
- Never invent a quality judge, metric producer, workload, model ID, fallback model or credential. External results must come from an existing fixed authoritative evaluator, not a graph change or learned judge. Missing intent → ask; missing prerequisite → report it exactly.
- No implicit or hidden iteration cap. Optional caller run/time budgets only; a budget or cancellation stop is not convergence.
- Report only what the optimizer measured. Faux/offline, parse-only or partial native measurements are never real-world savings.
1. Inspect before asking
Read the pair and how it is invoked today (scripts, README, CI, the user's command). Establish from the files:
- Graph structure: nodes, edge IDs (
edge.id ?? from + ("~>" for message | "->" for value) + to), wrapper-node paths of nested graphs, existingprobeflags and numeric edges (schema.typenumber/integer). - The runner:
JuncoGraph.fromYamlcall,args.params/args.sourceName, scheduler factory and its label dispatch, ladder and strength selection, existingschedules.limitwrappers (the hard ceilings), recorder/tracer, graph-widecollection, node-indexedtoolsandagentOptions, terminal assertion and cleanup order. - Agents and their models; deterministic targets (no agent nodes) have no ladder axis. Admitted agent tools (a tool-call cap needs at least one).
- The models pi offers: every
provider/modelwith a saved login, local/self-hosted providers from~/.pi/agent/models.jsonincluded, with its thinking levels and catalog price (Model domain). - Whether repeated runs are safe as-is or need an existing reset command.
2. Intake: ask only for what the files do not answer
Batch the questions. All six are settled before execution; never invent an answer.
- Objective — exactly one metric and a direction (
minimize|maximize):tokens,costormemory, each with a narrow recorded scope:tokensexcludesschedules.pioracle andtasksubagent usage; all-requestcostneedscostMode: "usage"and a metered scheduler;memoryis the per-activation shell-pipeline peak and needs native monitoring coverage. Details: Metrics and measurement coverage.probe— an existing numeric edge:{ node: <wrapper path, "" at the root>, edgeId: <exact local edge ID>, reduce: single|last|min|max|sum|mean }. A graph's display label is not an identity.result—{ kind: "result", name }from a fixed authoritative producer; define the producer and its full-workload coverage before execution.- Broader quantities need an existing numeric edge or fixed external-result producer; never relabel a narrower recorded quantity or change the graph.
- Quality constraints and quality index — each constraint is a metric +
<=/>=+ number, a hard gate in every run; complete outcomes below the threshold are scored but infeasible. "Keep high quality" → ask which number on which existing edge or authoritative result. SetqualityConstraint(zero-based index intoconstraints) to the authoritative quality metric so a one-SD quality gain can promote too; never guess among several — ask. Omitting it means objective-only promotion. - Fixed workload and repeats — the exact input corpus and invocation (
argv,cwd), a stableworkloadId,R >= 2repeats (3 recommended; never silently raise an approved count), and an existingresetArgvor confirmation that repeats are safe. Unsafe repetition is a prerequisite, not permission to rerun destructive effects. Stop predicates — at least one; all given must hold:
target: absolute objective value, compared to the mean;improvement:{ kind: absolute | relative, value > 0 }over the baseline mean ("must decrease/increase" needs this; an unchanged baseline does not satisfy it);plateau:{ window: integer >= 2, absoluteTolerance >= 0, relativeTolerance >= 0 }(relative is a fraction: 0.01 = 1%).
Convergence also needs a no-promotion cycle over every requested axis and a passing fresh confirmation (Execution model). Candidate exhaustion or one lucky run is never convergence.
- Axes and authorized domains — axes in the fixed order
scheduler,ladder,limits: all applicable ones by default, narrower only when the user restricts them. The ladder is inapplicable without agent nodes; a tool-call cap is inapplicable without admitted tools, though token/memory controls can keeplimitsapplicable. Report each inapplicability with its reason; never substitute model search or silently drop an axis.allowedModels(target ladders and agentic schedulers): by default every model pi offers at each supported thinking level, local ones included, plus the baseline's own, ordered by ascending catalog price (the editor sees only IDs); a narrower set only when the user names one.limitBounds.memoryBytes|tokens|toolsbound extra limits. A missinglimitBounds.toolsmeans no numeric bound, not disabled tools; with neither a bound nor useful target evidence for a cap, ask for one.- A
schedules.pialternative needs the fixed metered/domain-checkedoptimizerPiwrapper outside the regions; it may order ready work, never omit required work or choose model rungs.
- Optional budgets —
runBudget(child runs) andtimeBudgetMs. A spend/cost cap requires an authoritative external meter covering every attempt, including failures and subagents; recorded JSONL totals cannot enforce it — say so and do not accept it otherwise.
3. Prepare the target once
Follow references/profiling.md, in this order:
- Session directory. Create
/tmp/junco-profile-optimizer-workspace/if absent (mode0700; this literal path, not$TMPDIR), thenmkdtempwith prefix/tmp/junco-profile-optimizer-workspace/session-. An existing parent must be a writable directory, not a symlink, owned by the current user, with no group/other access. On any conflict or creation failure, report the exact path and error before changing the target; never overwrite, chmod, empty or follow a conflicting parent, and never fall back to another location. Keep snapshots, request, optimizer state/usage, profiles, receipts, logs and cleanup guards in that session. Before a live run, its directory must be inside a writable native Btrfs seed: the Editor opens its privateread_target/edit_tuningcollection there. Offline preparation does not open the collection. If the seed is missing, report the prerequisite; do not relocate the project, change mounts orBTRFS_ROOT, or substitute host tools. The target still runs from its original cwd with its originalargv/resetArgv. - Snapshots. Save
original.ymlandoriginal.tsthere before any change. - Regions. Move the existing tuning expressions, unchanged, into exactly one ordered marker pair per axis (all three pairs, even for unrequested axes) defining
optimizerScheduler(label),optimizerLadder/optimizerStrengthandoptimizerLimits(Tuning regions). Keep these baseline values unchanged: candidate policies and caps are generated by the editor after baseline measurement, never preinstalled. If the runner cannot be separated this way without changing its semantics, stop and report the exact integration prerequisite. - Instrumentation. Add the fixed
JUNCO_PROFILE_RUN_DIRcode in place from the instrumentation template. Its localOptimizerProfilevalidates the run request, hashes the document, enables probes on a runtime copy, checks candidate ladder rungs and extra limits againstallowedModels/limitBounds, builds each policy with the original hard limits outermost, creates theJsonlRecorderon the existing ownership path and, after the existing cleanup order, writes the completion receipt (with requested external-result metrics only after complete evaluator coverage). Agentic scheduler models are checked by the fixedoptimizerPiintegration when applicable. With the variable absent the workflow behaves exactly as before. Import only public packages, never the installed skill directory. - Prepared snapshot. Save the instrumented file as
prepared.ts(byte-identical toworkflow.ts). Check it once without paid execution (e.g.bun build --no-bundle workflow.tsor the project's typecheck). - Request. Write
<sessionDir>/request.jsonper Request schema and example.target.yaml,target.tsandtarget.cwdare absolute paths to the inspected workflow's files and its original working directory; keepsessionDir: "."(relative paths resolve against the request file). Directschedules.runOptimizercalls require an absolutesessionDirtoo.
4. Invoke once
From the original workflow project, with junco installed, passing the absolute request path:
bun run junco-profile-optimizer <sessionDir>/request.jsonExit 0 converged; 2 budget or blocked; 1 failed or invalid input; 130/143 interrupted. Stdout is one JSON summary (stop, baselineScore, incumbentScore — objective means — runCount, statePath, scoresPath, profilePaths). Programmatic use under Bun: schedules.runOptimizer(request, { signal }). If the installed package lacks the junco-profile-optimizer binary, report that an optimizer-capable junco build/install is required; do not generate a wrapper.
Before invoking, the user must have authorized paid execution of the workload, and the Sol editor and every allowed target model must pass the optimizer's preflight: catalog, saved login, account access and thinking support. There is no fallback model. Local providers have further login, server, usage and slot prerequisites: Model domain.
5. Report
From state.json, scores.jsonl and the summary:
- Stop kind and reason; after a non-converged stop, whether
original.tswas restored or preserved because the file changed outside the optimizer or cleanup was unproven. - The triplets compared (keys and changed axis) with objective and designated-quality mean, sample SD and repeat count.
- Which were promoted and which rejected (infeasible, not a one-SD non-regressing gain, or failed measurement), and the confirmation result.
- Baseline and confirmed means with units and coverage (cost = recorded USD with the target's stated request coverage, local requests at 0 USD; tokens = successful agent activations; memory = per-activation pipeline peak; probe/result = the producer's unit) and per-constraint values.
- Any configured tool cap and its scope.
- Axes tried, and axes reported inapplicable with their reasons.
- The winning region sources (a converged run leaves them saved in
workflow.tswith dormant instrumentation) and the models the trials actually used. - Run count,
statePath,scoresPathand profile paths. - Editor USD, separately and included in campaign spend.
- The absolute session path, with a warning that evidence under
/tmpcan disappear on OS cleanup or reboot. Never delete the session yourself, whatever the stop kind: it is the recovery evidence.
Promotion is a one-SD effect-size heuristic, not a significance test; plateau convergence is measured local stability, not a global optimum. Faux/offline or partial evidence is never claimed as savings.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

