Skip to content

tdx-skills/segment: surface include/exclude composition as the answer to "nested segments" - #200

Open
xerial wants to merge 1 commit into
mainfrom
segment-references-discoverability
Open

tdx-skills/segment: surface include/exclude composition as the answer to "nested segments"#200
xerial wants to merge 1 commit into
mainfrom
segment-references-discoverability

Conversation

@xerial

@xerial xerial commented Jul 25, 2026

Copy link
Copy Markdown
Member

Why

A customer filed a product gap for "Nested Segment Creation" (tracked in HubSpot / #hs-product-gap-updates), and the tdx team was cc'd on the request. Tracing it back to the original thread, the triage there was "tdx has capability to create segment including referenced segment, but td-skills doesn't handle the referenced segment."

That last part isn't accurate — include/exclude references have been documented since #43 (2025-12-23), and the decomposition workaround for cross-attribute Or since #111 (2026-03-05). But the skill's description never mentioned references at all; it advertised only "nested condition group restrictions." Someone scanning the description sees what's forbidden, not the supported way to build a segment on top of another segment. Two people in that thread concluded "not supported."

What changed

  • description now names include/exclude composition, and reframes the nesting clause as "how to express nested AND/OR logic that the Console rejects" rather than a bare restriction.
  • Segment References section says up front that this is how you build a nested/composed segment.
  • Cross-attribute Or limitation gets the decomposition written out in YAML instead of a one-line "consider creating separate segments…", plus the push-order constraint (branches before the composition).
  • NESTED_CONDITION_GROUP row in Common Issues now points at references, not just In/flatten — that's the line an agent lands on after a validation failure.
  • test.yml gains three scenarios for the reference path: plain include nesting, the validate-passes/push-fails asymmetry on a missing reference, and the cross-attribute-Or decomposition. All three pre-existing scenarios covered only sg move name resolution.
  • tests/trigger-tests.yml gains two nested-segment prompts.

Scope — what this does not fix

I measured rather than assumed, and the results limit the claim:

Check Result
Skill selection for nested-segment prompts (old vs new description, 87 skills, haiku) segment both ways
"Can you build (country = US) OR (age > 30)?" against old body, 3 runs correct answer + type: include YAML 3/3
Same against new body, 3 runs correct answer + type: include YAML 3/3

So a model that actually loads this skill already answered correctly before this PR. This is a discoverability and test-coverage fix, not a behavior fix, and it does not by itself explain the downstream "not supported" answer that reached the customer. The likelier remaining suspect is whether this skill is in context at all on the Foundry Audience-agent / TAIS path — that's being followed up separately and is out of scope here.

The two new trigger tests pass before and after, so they're coverage, not regression guards for this change.

Testing

./tests/run-tests.sh needs yq, which I don't have installed, so I replicated the runner's logic (same extract-skills.sh output, same prompt template, same --model haiku) to produce the table above. YAML frontmatter and both test files parse. SKILL.md is 302 lines, within the 500-line guidance.

Worth a second opinion on the description rewrite specifically — it's now noticeably longer, and description length trades off against the resolver's precision across 87 skills.

🤖 Generated with Claude Code

…swer to "nested segments"

The description advertised "nested condition group restrictions" but never mentioned
`include`/`exclude` segment references — a capability documented since #43 (2025-12-23).
Anyone scanning the description sees only what is forbidden, not the supported way to
build a segment on top of another segment.

Concretely:

- description now names `include`/`exclude` composition and reframes the nesting clause
  as "how to express nested AND/OR logic that the Console rejects"
- the Segment References section states up front that this *is* nested/composed segments
- the cross-attribute-Or limitation gets the decomposition worked out in YAML instead of
  a one-line "consider creating separate segments", plus the push-order constraint
- the NESTED_CONDITION_GROUP row in Common Issues points at references, not just `In`
- test.yml gains three scenarios for the reference path: a plain `include` nesting, the
  validate-passes/push-fails asymmetry on a missing reference, and the cross-attribute-Or
  decomposition. Previously all three scenarios covered only `sg move` name resolution.

Measured, so the scope of this change is not oversold: with the old text, haiku already
answers the cross-attribute-Or question correctly and emits `type: include` YAML in 3/3
runs, and skill selection picks `segment` for nested-segment prompts both before and
after. So this is a discoverability and coverage fix, not a behavior fix — it does not
by itself explain a downstream "not supported" answer.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@xerial
xerial requested a review from a team as a code owner July 25, 2026 04:01
Copilot AI review requested due to automatic review settings July 25, 2026 04:01
@xerial
xerial requested review from a team as code owners July 25, 2026 04:01
@github-actions github-actions Bot added maintainer Maintainer-authored PR tdx:core-skills Touches core skills: tdx-skills, sql-skills, workflow-skills labels Jul 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves discoverability of “nested segments” support in the segment skill by explicitly framing include/exclude segment references as the supported composition mechanism, and adds test coverage for those reference-based workflows.

Changes:

  • Expand tdx-skills/segment/SKILL.md to highlight include/exclude references as the solution for composed/nested segments and document the cross-attribute Or decomposition workflow.
  • Add new scenarios to tdx-skills/segment/test.yml to cover reference-based composition and validate/push asymmetry.
  • Add nested-segment prompts to tests/trigger-tests.yml to improve trigger coverage.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/trigger-tests.yml Adds two prompts intended to trigger the segment skill for nested/composed segment requests.
tdx-skills/segment/test.yml Adds three new regression scenarios for include/exclude composition and reference-resolution behavior.
tdx-skills/segment/SKILL.md Updates frontmatter description and documentation sections to surface segment references as the “nested segment” approach and expands workaround guidance.
Comments suppressed due to low confidence (2)

tdx-skills/segment/test.yml:74

  • This scenario runs tdx sg push against /tmp/refs-missing-segment.yml, but that file is never created in setup, so the command will fail due to a missing file rather than exercising the intended “reference not found” behavior.
      - tdx sg push --dry-run -y /tmp/refs-missing-segment.yml

tdx-skills/segment/test.yml:91

  • The cross-attribute Or scenario references segments/us-visitors.yml, segments/over-30.yml, and segments/us-or-over-30.yml, but these files don’t exist in the repo and aren’t created in setup, so the scenario can’t run as written.
      - tdx sg push -y segments/us-visitors.yml
      - tdx sg push -y segments/over-30.yml
      - tdx sg validate segments/us-or-over-30.yml
      - tdx sg push --dry-run -y segments/us-or-over-30.yml

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +48 to +57
cat > /tmp/vip-recent.yml <<'YAML'
name: VIP Recent Buyers
rule:
type: And
conditions:
- type: include
segment: "VIP Customers"
- type: Behavior
# ...purchased in the last 30 days
YAML

@adher-code adher-code left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Governance review — PDM

The discoverability improvement here is genuinely useful — surfacing include/exclude as the answer to "nested segments" is the right call. Good scope, good test additions.

  1. Test scenario bug (flagged by Copilot) — the three new scenarios in test.yml reference type: Behavior syntax in the YAML examples, but this skill's own documentation says type: Behavior is invalid and must be rewritten as type: Value + TimeWithinPast. The test scenarios won't run as written. Please update them to use the documented valid syntax — and while rebasing, verify the NESTED_CONDITION_GROUP behavior description is consistent with what main now says (warning-only vs. hard rejection).
  2. SKILL.meta.yml — the existing validation entry (2026-07-07) covers the name-resolution guidance. A new entry should be added for this change, confirming that the include/exclude composition examples were validated against a live CDP environment.

The governance frontmatter is already complete from PR #196 — nothing missing there. Once the rebase, test fix, and meta entry are in, this is straightforward to approve.

As you Leo are working on this I thing the developer reviewer is you even if Ai wrote the code.

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

Labels

maintainer Maintainer-authored PR tdx:core-skills Touches core skills: tdx-skills, sql-skills, workflow-skills

3 participants