refactor: move resource parsing and org connection helpers into config-free modules - #59
Open
scott-lowe-vapi wants to merge 1 commit into
Open
scott-lowe-vapi wants to merge 1 commit into
scott-lowe-vapi wants to merge 1 commit into
Conversation
…g-free modules The PR check has to read an org's resource files and resolve org keys without importing config.ts, which parses argv and exits at import time. Move the code rather than copy it, so push and the check read files the same way: - src/resource-parse.ts: FOLDER_MAP, VALID_EXTENSIONS, frontmatter and file parsing, the directory scan and loader, .vapi-ignore reading and matching, and a new orgResourcesRead(rootDir, org). The two copies of the .md body -> system message injection become one function. - src/org-connection.ts: envValue, tokensParse(envName), connectionLoad and childRun from promote-cmd.ts, parameterised on the root dir, token variable and base URL. - api.ts takes VapiApiError, parseApiMessage, shouldRetry and the backoff constants from vapi-client.ts and re-exports VapiApiError. - promotion.ts imports FOLDER_MAP/VALID_EXTENSIONS and exports SLUG_RE and the bindings parse/resolve/apply helpers. resources.ts, config.ts and promote-cmd.ts delegate, and keep their exports, logs and error messages unchanged. Refs TEST-141 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scott-lowe-vapi
force-pushed
the
fix/sim-false-green
branch
from
October 1, 2026 23:11
8a438bc to
06a1492
Compare
scott-lowe-vapi
force-pushed
the
refactor/config-free-engine-modules
branch
from
October 1, 2026 23:11
3e0e277 to
0518af1
Compare
Contributor
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced Oct 1, 2026
scott-lowe-vapi
marked this pull request as ready for review
October 1, 2026 23:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Value
V.A.L.U.E. tier: project — PR 3 of 10 for inline simulation PR checks (TEST-141); this PR is a behaviour-preserving refactor.
config.ts, which parsesargv, binds one org and canprocess.exitat import time. Copying it into the check would let push and the check drift apart, so the check could test a different payload from the one push sends..mdsystem-prompt injection).resources.ts,config.tsandpromote-cmd.tsdelegate to them and keep their exports, logs and error messages.src/resource-parse.ts:resources.ts:FOLDER_MAP,VALID_EXTENSIONS, frontmatter/file parsing, the directory scan and the loader;config.ts:.vapi-ignorereading and matching;orgResourcesRead(rootDir, org), which returns every resource of an org keyedtype:id;.mdbody → system message injection becomemarkdownResourceParse.src/org-connection.ts:envValue,tokensParse(envName),connectionLoadandchildRun, moved frompromote-cmd.tsand parameterised on the root dir, the token variable and the base URL.api.ts: takesVapiApiError,parseApiMessage,shouldRetryand the backoff constants fromvapi-client.ts, and re-exportsVapiApiError. Both clients now share one error class (soinstanceofchecks see one class) and one retry rule.promotion.ts:FOLDER_MAP/VALID_EXTENSIONSinstead of keeping its own copies;SLUG_RE,promotionBindingsParse,promotionBindingsResolve,promotionBindingsApplyandPromotionBindingsResolved, for the check config (PR 4) and the payload builder (PR 5).FOLDER_TO_TYPEmap inresources.ts.Evidence of value
The output is byte-identical before and after. The same fixture org was run at both refs against a local stub API. Nothing reached a real org.
The fixture:
.mdassistant whose frontmatter has a system message the body must replace;.tstool and a YAML tool;promotion.yml.fix/sim-false-green(06a1492)push ev-dev --dry-run(new-file gate refusal)push ev-dev --dry-run --allow-new-files(full plan, every would-POST)loadResourcesJSON for every type (full parsed data, incl. the.mdsystem message)validate ev-devpromote --pipeline release --from ev-dev --to ev-prod(plan)3f3b609f…1d3b, 14,927 bytes3f3b609f…1d3b, 14,927 bytesdry-run-post-<Date.now()>) and the stub's port are normalised before hashing.--allow-new-filesis passed only because every fixture file is new by construction.Tests:
npm testgoes from 377 to 398 passing (21 new), andnpm run build(src + tests) is clean.Testing plan
tests/resource-parse.test.ts(temp-dir fixtures) covers:.mdbody replacing a frontmatter system message, and an empty body;.mdparsing being the same forparseResourceDataFromFileand the loader;.yml/.yaml/.tsand nested dirs;.bkpfiles skipped;.vapi-ignorecomments, blanks and!;*vs**vs?matching;orgResourcesReadreading one org and applying its ignore file, and the caller's override.tests/org-connection.test.tscovers:.envvalues;.env.<org>) and base URL precedence (configured, then.env.<org>);childRunpassing the org and key to a real child, and dropping an inheritedVAPI_BASE_URL;.vapi-ignorepush, promotion, audit and cleanup-safety suites pass unchanged.promote --apply(the movedconnectionLoad/childRunare covered by unit tests, but no live childpull/applywas run);Stacked on #58. Review with
git diff --color-moved=dimmed-zebra fix/sim-false-green...to see that most of the diff is moved lines.Refs TEST-141
🤖 Generated with Claude Code