-
Notifications
You must be signed in to change notification settings - Fork 81
fix(prompt-surface): let the generator own the A1 golden's hash baseline #292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alfonso-magic-context
merged 2 commits into
cortexkit:master
from
iceteaSA:fix/export-agent-surface-section3
Aug 10, 2026
+87
−18
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { readFileSync } from "node:fs"; | ||
| import { join } from "node:path"; | ||
|
|
||
| /** | ||
| * Shared accessors for the A1 prompt-surface golden. | ||
| * | ||
| * The golden (`prompt-surface-a1-golden.md`, generated by | ||
| * `scripts/export-agent-surface.ts`) is read by tests in BOTH packages, and its | ||
| * section headings are the contract between the generator and those readers. | ||
| * Keeping the path, the heading strings, and the offset guard here means a | ||
| * change to the golden's section format is a one-file edit rather than a hunt | ||
| * across packages. | ||
| * | ||
| * This module resolves the golden relative to ITSELF, so consumers never carry | ||
| * their own `../..` path arithmetic — that arithmetic differs per package and is | ||
| * exactly the kind of thing that rots silently when files move. | ||
| */ | ||
|
|
||
| export const A1_TOOL_SECTION_HEADING = "## 2. Tool surface"; | ||
| export const A1_HASH_BASELINE_HEADING = "## 3. System-prompt hash baseline"; | ||
|
|
||
| export function readA1GoldenDocument(): string { | ||
| return readFileSync(join(import.meta.dir, "prompt-surface-a1-golden.md"), "utf8"); | ||
| } | ||
|
|
||
| /** | ||
| * Locate a golden section heading, refusing to continue when it is absent. | ||
| * | ||
| * A bare `indexOf` returns -1 for a missing heading, and `slice(start, -1)` | ||
| * silently yields an empty (or truncated) section rather than failing: the | ||
| * golden then parses as ZERO tools and the consuming test passes by comparing | ||
| * empty to empty. Failing loudly here keeps a malformed golden from reading as a | ||
| * clean run. | ||
| */ | ||
| export function a1GoldenSectionOffset(document: string, heading: string): number { | ||
| const offset = document.indexOf(heading); | ||
| if (offset === -1) { | ||
| throw new Error(`A1 golden is missing the "${heading}" section heading`); | ||
| } | ||
| return offset; | ||
| } | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: The
A1_TOOL_SECTION_HEADINGconstant doesn't mirror the actual golden heading — the file declares## 2. Tool surface (description + parameters as serialized to the provider), while the constant only carries the## 2. Tool surfaceprefix. It works only becauseindexOfdoes a prefix/substring match, which contradicts the module's own stated contract (that these heading strings make a golden format change a one-file edit). If the golden ever gains a section whose heading starts with## 2. Tool surface, the offset guard would silently resolve to the wrong section. Suggest storing the exact on-disk heading so the constant truly reflects the contract it documents.Prompt for AI agents