Repository navigation
refactor(revenue): shrink src/revenue back under both token ceilings, behaviour unchanged (#2037) - #2039
Merged
objectstack-fleet[bot] merged 4 commits intoOct 9, 2026
Conversation
… behaviour unchanged (#2037) - contract_on_activation: drop the dead `endDate` local (left behind when the renewal task moved to the contract_renewal flow) and the stale "schedule renewal task" clause in its description - quote_generation: edge e4b is edge e4a's predicate negated whole, spliced from one `ADVANCE` fragment like `DISCOUNT`, instead of a hand-kept De Morgan copy - hooks: destructure `previous` with `input`; read patch-else-stored values with `[patch, stored].find(...)` (the idiom quote.hook already uses); one `num()` reader in the two line-item rollups Claude-Session: https://claude.ai/code/session_012zh91QzFgePbkmuHnugLN3 Co-authored-by: Claude <noreply@anthropic.com>
…thing (#2037) Claude-Session: https://claude.ai/code/session_012zh91QzFgePbkmuHnugLN3 Co-authored-by: Claude <noreply@anthropic.com>
…t still lowers (#2037) `const { previous: prev } = ctx` is refused by `os lint --strict` (hook-body/not-lowerable: "references the identifier previous") — the lowering reads the renamed property key as a free identifier. Back to the base's two-line read; the file is byte-identical to main again. Claude-Session: https://claude.ai/code/session_012zh91QzFgePbkmuHnugLN3 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012zh91QzFgePbkmuHnugLN3 Co-authored-by: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
This was referenced Oct 9, 2026
This was referenced Oct 9, 2026
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.
Fixes #2037
Clause-②: no
What was measured before the fix
mainata2f2a40ais red at the door this gate guards.node scripts/check-source-token-ratchet.mjs(pnpm hygiene:tokens, also a step of CI Build and Test) exits 1, reproduced on this branch before any edit:✗ src/revenue business semantics is ~16,051 tokens; the ratchet ceiling is ~16,000 (over by ~51)✗ src/revenue authored total is ~19,161 tokens; the ratchet ceiling is ~19,000 (over by ~161)PR #2034 (
quote-generation.flow.ts) and PR #2035 (quote.hook.ts) each fit alone and together crossed both lines. Where thesrc/revenuebudget goes, measured with the ratchet's ownauthoredText()counter (comment- and blank-stripped chars, ~tokens = chars / 4), the twelve largest files ona2f2a40a:objects/quote.hook.tsflows/contract-renewal.flow.tsobjects/quote.object.tsobjects/contract.object.tsflows/quote-generation.flow.tsobjects/contract.hook.tsflows/billing-handoff-contract-activated.flow.tsobjects/product.object.tsviews/contract.view.tsobjects/quote_line_item.object.tsviews/quote.view.tsobjects/quote_line_item.hook.tsThe fix: shrink, no ceiling moves
1,637 authored chars (~409 tokens) removed, all from duplicated or dead code in five hooks and one flow. No ceiling, no ratchet config, no test file and no user-facing sentence was touched.
src/revenuescopeobjects/contract.hook.tsobjects/quote_line_item.hook.tsobjects/product.hook.tsflows/quote-generation.flow.tsobjects/opportunity_line_item.hook.tsobjects/quote.hook.tsWhat was compressed, and why it changes nothing at runtime:
contract.hook.ts).contract_on_activationcomputed anendDateit never read. It was left behind when the renewal task moved to thecontract_renewalflow (the note at the end of that handler records the move). The same move made the hook's description, "On activation: stamp signed_date, promote account, schedule renewal task.", untrue. The description now drops that last clause. It is the only text change, and no test or docs page quotes it.quote-generation.flow.ts). Edgee4b's condition was written out as the negation of edgee4a's. Both edges now take one CEL fragment,ADVANCE:e4aisexpression(ADVANCE, 'cel')ande4bisexpression(`!(${ADVANCE})`, 'cel'). This is the same function-form splice the file already uses forDISCOUNT; thePtag JSON-quotes an interpolated string, so it cannot splice a fragment. The two branches now partition by construction. Before, they partitioned only because someone had negated the condition correctly by hand.previoustogether withinput. The patch-value-else-stored-value reads are written[patch, stored].find(...), the idiomquote_accepted_contract_draftalready uses:contract_validation(start date, end date, term),contract_on_activation(id, account) andproduct_catalog(list price, cost). The two line-item rollups share onenum()reader in place of six copies of the sametypeofternary.Why this is the minimal change: removing dead or duplicated code shortens nothing a user reads. Every refusal message, refusal code and stored value is byte-for-byte the same, so no test pin had to change. Shortening user-facing copy would have bought the same tokens, but only by re-pinning messages.
What pins it
src/revenuelines are now✓inpnpm hygiene:tokens(✓ source token ratchet clean), andtest/source-token-ratchet.test.tsis green.pnpm verifygreen on19db7fa4(the final commit), run through the shared verify lock. It ended withVERDICT command-exit 0, and the test step reportedTest Files 172 passed (172)andTests 3601 passed | 1 skipped (3602). The suite includesflow-quote.test.ts(both stage branches, including a deal awaiting approval),flow-variable-conditions.test.ts(condition totality),metadata-references.test.ts(every condition reaches CEL),refusal-envelope.test.ts,freeze-guard-reference-cleanup.test.ts, and the contract, product and line-item hook suites.e4a/e4b: the old conditions froma2f2a40aand the new ones from the shipped flow module were evaluated by the platform's ownExpressionEngine(@objectstack/formula17.7.0), in the scope shape ofAutomationEngine.celScope. The 53oppRecordstates were unbound, null, empty, and every combination of stage (8 values, absent, null) with approval status (absent, null, pending, approved, rejected). Result:EQUIVALENT: 53 cases x 2 edges, 0 diffs, 0 partition overlaps. A negative control that swaps the old pair reportsNOT EQUIVALENT: 106 diffs.Object.isover every patch/stored value pair (undefined, null, empty string, strings, 0, -0, NaN, numbers, booleans, an object, and an absent pre-image). Result:EQUIVALENT: 923 cases, 0 diffs.Acceptance notes
const { event, input, previous: prev } = ctxin_line-item-price-fill.ts) was refused bypnpm lint(os lint --strict) withhook 'quote_line_item_line_number' cannot be lowered to a metadata-only body: it references the identifier previous, which is not in scope inside the sandbox. The lowering reads a renamed destructuring key as a free identifier. That file is byte-identical tomainagain. The platform side goes to the seat in the dev report and is not filed from here..changeset/2037-revenue-token-shrink.md. This PR releases nothing a CRM user would notice.Generated by Claude Code