Skip to content

fix(hy-check): model curated foreign method surface for context.Context (fixes #4248) - #4249

Merged
limitlessprojects merged 1 commit into
limitlessprojects:mainfrom
jpereyra243-byte:fix-foreign-context-method-surface
Nov 9, 2026
Merged

limitlessprojects merged 1 commit into
limitlessprojects:mainfrom
jpereyra243-byte:fix-foreign-context-method-surface

Conversation

@jpereyra243-byte

Copy link
Copy Markdown
Contributor

Summary

This PR models the curated foreign method surface for Go standard library context.Context (fixes #4248, Row 13 BUILDABLE).

Root Cause & Defect

Previously, foreign_method_surface in compiler/crates/hy-check/src/foreign.rs curated standard library types (such as sync.Mutex, http.ResponseWriter, http.RoundTripper, os.File, net.Addr), but omitted context.Context. Invocations of nonexistent / phantom methods on context.Context or *context.Context values (e.g. ctx.cancel(), ctx.unsupported_call()) passed hyb check with 0 diagnostics, causing downstream go build to fail with fatal errors (type context.Context has no field or method ...), violating GUARANTEES.md Row 13.

Changes

  1. Curated Method Surface: Added CONTEXT_CONTEXT with Go's canonical 4 interface methods: ["deadline", "done", "err", "value"].
  2. Type Mapping: Added "context.context" | "context.Context" => Some(CONTEXT_CONTEXT) and added "context" to is_curated_package_root.
  3. Regression Tests: Added comprehensive test suite compiler/crates/hy-check/tests/foreign_context_method_surface.rs verifying:
    • Phantom method invocations on context.context reject fail-closed with HYB-E1002.
    • Phantom method invocations on pointer receivers *context.context reject with HYB-E1002.
    • Phantom method invocations through struct fields reject with HYB-E1002.
    • Canonical Go context.Context methods (deadline, done, err, value) accept cleanly with 0 diagnostics.

Settlement Coordinates: EVM (Base / Polygon) USDC: 0xC175c34c256598C7e1AD5B15503cFcED7Ed67e10

@limitlessprojects
limitlessprojects merged commit 5c6eebb into limitlessprojects:main Nov 9, 2026
1 of 2 checks passed
@limitlessprojects

Copy link
Copy Markdown
Owner

Landed — merge 5c6eebb8, remote-asserted (full battery ALL-GREEN)

Thank you @jpereyra243-byte — second surface-modeling PR in the #4198/#4252 arc, and again the shape that lands clean.

Review notes for transparency:

Verification evidence (run on the merged tree):

Gate Result
Merge gate auto-merge clean (author based on current main 5a93dff0)
cargo test --workspace 3222 passed / 0 failed (+4 = your suite's test count exactly); 491 suites = 491 Running lines (1:1)
corpus harness 139/139, tripwire not fired (verdict-level 2/139, threshold ~25%)
differential loop FULL AGREEMENT — accept 47/47 + reject 92/92

Protocol followed: merge --no-ff with hand-written credit commit (verification evidence + CREDIT: @jpereyra243-byte), pushed, git ls-remote origin main == local HEAD asserted. fixes #4248 closes with this merge.

Bounty: per BOUNTY.md / discussion #295 rail — curated foreign method surface (context.Context), logged under this PR number.

CREDIT: @jpereyra243-byte

@jpereyra243-byte

Copy link
Copy Markdown
Contributor Author

Payout wallet (USDC on Base / Polygon): 0xC175c34c256598C7e1AD5B15503cFcED7Ed67e10

limitlessprojects pushed a commit that referenced this pull request Nov 9, 2026
…#4251)

Round-2 re-push (1363bf3) fixed the round-1 gate exactly as prescribed:
"bool_func" added to FLAG_FLAG_SET (go1.26.9 go doc flag.FlagSet.BoolFunc
exists; name is representable, not a keyword), accept-control extended
with _ = fs.bool_func("v", "verbose", nil). Probes on the merged tree:
fs.bool_func(...) -> OK (0 diagnostics, round-1 false-reject resolved);
fs.totally_fake_flag_method() -> HYB-E1002 (fail-closed intact).

In-merge conflict disclosure: the branch point predates #4249's landing
of the sibling context.Context surface; three disjoint hunks of
foreign.rs conflict at identical anchors. Resolved by scripted union
(scripts/union_4252.py, S160 procedure): both sides kept in every hunk —
CONTEXT_CONTEXT + FLAG_FLAG_SET consts, both dispatch arms, both
is_curated_package_root entries ("context" + "flag"). Presence
assertions green: both surfaces defined and dispatched exactly once,
balance asserted. Context suite (4 tests) and flag suite (3 tests) both
pass together on the union tree.

Verification evidence (S172 battery, main 5653900 + 1363bf3):
- merge gate: 3-hunk union splice, assertions above
- cargo test --workspace: 3225 passed / 0 failed (+3 = PR suite count)
- suites: 492 files == 492 running, 1:1
- corpus: 139/139, tripwire not fired (verdict-level 2/139, threshold ~25%)
- differential: FULL AGREEMENT — accept-side 47/47, reject-side 92/92

CREDIT: @jpereyra243-byte
limitlessprojects pushed a commit that referenced this pull request Nov 9, 2026
…nts (W-026, fixes #4200)

Implements Wildcard Track W-026 Milestone 1 (Issue #4200): hy.send_cap[T]/
hy.recv_cap[T] Tier-0 linear channel capabilities; affine transfer
(move-into-task-closure enforcement, HYB-E3001 use-after-move, HYB-E3002
reference capture across task boundaries); ChannelLivenessChecker —
forward CFG dataflow guaranteeing every linear send cap reaches Closed
(HYB-E4004) and every linear recv cap reaches Drained (HYB-E4005) before
nursery scope exit. hy registered in the curated import/root/member sets
(pipe, new_pipe, send_cap, recv_cap, channel).

In-merge conflict disclosure: one foreign.rs conflict, two hunks,
resolved via scripts/resolve_4221.py:
- foreign_named_type: union — adopted the PR's `match base` scrutinee
  (required to strip hy.send_cap[T] generic params), keeping both the
  PR's send_cap/recv_cap OwnHandle arms and the landed #4198 `error`
  ForeignOpaque arm.
- method-result table: HEAD side kept wholesale (PR side was a stale
  reformatted subset of the pre-#4198 table; adds no entries).
Presence assertions green: send_cap arm + error arm + landed surfaces
(#4249/#4252 consts+arms) + #4198 table intact.

Verification evidence (S173 battery, main e33e8dc + 0571ecb):
- merge gate: 2-hunk scripted resolution (above)
- cargo test --workspace: 3245 passed / 0 failed (+20 = PR suite count)
- suites: 493 files == 493 running, 1:1
- PR conformance matrix: channel_liveness_4200 20/20 on the union tree
- corpus: 139/139, tripwire not fired (verdict-level 2/139, threshold ~25%)
- differential: FULL AGREEMENT — accept-side 47/47, reject-side 92/92

CREDIT: @Sora1916
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[buildable] hy-check(foreign): foreign_method_surface omits curated context.Context method surface (HYB-E1002, Row 13)

2 participants