Skip to content

forcedotcom/sf-skills / plugins/builder/agentforce-adlc/skills/agentforce-d360-analyze

agentforce-d360-analyze

Verified

Data Cloud 360° view of a single Agentforce session. TRIGGER when user asks to trace, inspect, summarize, or describe a specific Agentforce session by session id (Agent Session UUID `019d…` or MessagingSession id `0Mw…`). Also triggers on session discovery — find/list/search sessions by time, agent, channel, outcome, or conversation text — when the user has no session id yet. DO NOT TRIGGER for design-time architecture questions (use agentforce-architecture-analyze instead) or for runtime perf/latency/SLO questions that require platform telemetry beyond Data Cloud.

FileKindSize
README.mdmarkdown6.2 KB
SKILL.mdskill md13.2 KB
assets/dc/app_generation.sqlother1.9 KB
assets/dc/content_category.sqlother1.5 KB
assets/dc/content_quality.sqlother1.3 KB
assets/dc/discover_sessions.sqlother2.3 KB
assets/dc/feedback.sqlother1.5 KB
assets/dc/feedback_details.sqlother1.3 KB
assets/dc/gateway_records.sqlother1.6 KB
assets/dc/gateway_request_llm.sqlother1.6 KB
assets/dc/gateway_request_metadata.sqlother1.5 KB
assets/dc/gateway_request_tags.sqlother1.4 KB
assets/dc/gateway_requests.sqlother3.4 KB
assets/dc/gateway_responses.sqlother1.7 KB
assets/dc/generations.sqlother1.9 KB
assets/dc/interactions.sqlother2.0 KB
assets/dc/messages.sqlother2.1 KB
assets/dc/messaging_session.sqlother1.7 KB
assets/dc/moment_interactions.sqlother1.4 KB
assets/dc/moments.sqlother1.5 KB
assets/dc/participants.sqlother1.8 KB
assets/dc/sessions.sqlother3.0 KB
assets/dc/steps.sqlother2.6 KB
assets/dc/tag_associations.sqlother1.7 KB
assets/dc/tag_definition_associations.sqlother1.4 KB
assets/dc/tag_definitions.sqlother1.8 KB
assets/dc/tags.sqlother1.3 KB
assets/dc/telemetry_spans.sqlother2.1 KB
references/artifacts.mdmarkdown2.7 KB
references/dc_dmo_fields.mdmarkdown42.1 KB
references/dc_pipeline_contract.mdmarkdown26.3 KB
scripts/_shared/__init__.pyscript122 B
scripts/_shared/cli_override.pyscript3.3 KB
scripts/_shared/fs_guard.pyexecutablescript13.2 KB
scripts/_shared/paths.pyscript5.8 KB
scripts/_shared/runtime.pyscript2.0 KB
scripts/_shared/sql.pyscript548 B
scripts/assemble_dc.pyscript69.6 KB
scripts/config.pyscript1.8 KB
scripts/dc.pyscript13.8 KB
scripts/discover_sessions.pyscript21.1 KB
scripts/fetch_dc.pyscript45.1 KB
scripts/render_dc.pyscript69.7 KB
scripts/resolve_session.pyscript10.8 KB
scripts/storage.pyscript3.1 KB
scripts/tests/__init__.pyscript0 B
scripts/tests/_bootstrap.pyscript483 B
scripts/tests/fixtures/__init__.pyscript0 B
scripts/tests/fixtures/synthetic_session.pyscript14.6 KB
scripts/tests/test_assemble_dc_bootstrap_and_mode.pyscript4.2 KB
scripts/tests/test_assemble_dc_gateway_direct.pyscript8.3 KB
scripts/tests/test_assemble_dc_gateway_direct_integration.pyscript6.4 KB
scripts/tests/test_assemble_dc_helpers.pyscript10.0 KB
scripts/tests/test_assemble_dc_integration.pyscript9.3 KB
scripts/tests/test_dc_and_resolve_session.pyscript26.7 KB
scripts/tests/test_default_target_org.pyscript18.8 KB
scripts/tests/test_discover_sessions.pyscript19.0 KB
scripts/tests/test_discover_sessions_grep_ci.pyscript8.2 KB
scripts/tests/test_fetch_dc_helpers.pyscript10.6 KB
scripts/tests/test_fetch_dc_identity.pyscript22.0 KB
scripts/tests/test_fetch_dc_main.pyscript9.4 KB
scripts/tests/test_fetch_dc_waterfall.pyscript8.6 KB
scripts/tests/test_fetch_dc_waterfall_full.pyscript11.2 KB
scripts/tests/test_identity_coherence.pyscript13.8 KB
scripts/tests/test_render_dc_branches.pyscript9.9 KB
scripts/tests/test_render_dc_gateway_direct.pyscript5.1 KB
scripts/tests/test_render_dc_helpers.pyscript10.5 KB
scripts/tests/test_render_dc_integration.pyscript7.7 KB
scripts/tests/test_render_dc_planner_llm_calls.pyscript11.8 KB
scripts/tests/test_render_dc_show_prompts_gating.pyscript8.7 KB
scripts/tests/test_resolve_from_disk.pyscript4.1 KB
scripts/tests/test_resolve_session_main.pyscript5.2 KB
scripts/tests/test_runtime_override.pyscript4.2 KB
scripts/tests/test_session_shape.pyscript3.5 KB
scripts/tests/test_session_shape_dropped_by_stdm.pyscript3.5 KB
scripts/tests/test_skill_md_prefix_block.pyscript6.8 KB

scripts/tests/test_discover_sessions_grep_ci.py

View on GitHub
"""Regression guard for §16d — case-insensitive ``--grep`` default.

§16d flipped the default behaviour of ``--grep`` from case-sensitive
exact match to case-insensitive (``LOWER(...) LIKE LOWER(...)``).
Operators almost always type the quoted phrase in whatever case they
remember, not the case the agent rendered it in — the old default
silently dropped legitimate matches.

The compose_sql shape is already pinned in
``test_discover_sessions.py`` (LOWER wrap on default, bypass on opt-in,
escape semantics). What this file pins down is the
**argparse → filters dict → picker header** pipeline — the integration
seams where a refactor could:

  - flip the argparse default back to ``True`` (forgot ``default=False``)
  - drop the ``grep_case_sensitive`` key from the filters dict (header
    no longer warns the operator that the picker is in opt-in mode)
  - surface ``grep_case_sensitive`` even when ``--grep`` isn't set
    (false signal in the header for unrelated runs)
"""
from __future__ import annotations

import argparse
import unittest
from unittest import mock

from . import _bootstrap  # noqa: F401  — sys.path setup

import discover_sessions  # type: ignore


class GrepCaseSensitiveArgparseDefaultTests(unittest.TestCase):
    """The argparse flag must default to ``False`` so case-insensitive
    is the path of least resistance."""

    def _build_parser(self) -> argparse.ArgumentParser:
        # Re-export the parser the same way main() does — we don't have
        # a parser factory, so spy on the module-level ``argparse`` to
        # capture the parser before main() invokes parse_args().
        captured: dict[str, argparse.ArgumentParser] = {}
        real_parse_args = argparse.ArgumentParser.parse_args

        def capture(self, *a, **kw):  # type: ignore[no-redef]
            captured["parser"] = self
            # Stop main() before it calls anything network-y.
            raise SystemExit(0)

        with mock.patch.object(argparse.ArgumentParser, "parse_args", capture):
            with mock.patch.object(
                discover_sessions.sys, "argv",
                ["discover_sessions.py", "--org", "x"],
            ):
                with self.assertRaises(SystemExit):
                    discover_sessions.main()
        # Restore (the patch.object exit already did this, but be explicit
        # in case something held onto the bound method.)
        argparse.ArgumentParser.parse_args = real_parse_args
        return captured["parser"]

    def test_grep_case_sensitive_default_is_false(self):
        # parse_args without --grep-case-sensitive must return False.
        parser = self._build_parser()
        ns = parser.parse_args(["--org", "x"])
        self.assertFalse(ns.grep_case_sensitive,
                         "default flipped — case-insensitive was the §16d "
                         "decision; flipping default=False back to True "
                         "regresses to the pre-§16d behaviour")

    def test_grep_case_sensitive_opt_in_via_flag(self):
        # Pass the flag explicitly — must be True.
        parser = self._build_parser()
        ns = parser.parse_args(["--org", "x", "--grep-case-sensitive"])
        self.assertTrue(ns.grep_case_sensitive)


class FiltersDictSurfacesCaseSensitiveTests(unittest.TestCase):
    """The filters dict feeds render_picker's header. Without a marker,
    the operator can't tell whether their grep is in case-insensitive
    (default) or case-sensitive (opt-in) mode — a silent footgun when
    a query returns zero rows in opt-in mode by accident."""

    def _run_main_and_capture_filters(self, *extra_argv: str) -> dict:
        # Stub resolve_org + post so main() doesn't talk to DC, then
        # intercept render_picker to capture the filters dict main()
        # constructed.
        captured: dict[str, dict] = {}

        def fake_render(*, filters, **_kw):
            captured["filters"] = filters
            return "ok"

        argv = ["discover_sessions.py", "--org", "x", *extra_argv]
        with mock.patch.object(discover_sessions.sys, "argv", argv), \
             mock.patch.object(
                 discover_sessions, "resolve_org",
                 return_value=("https://x", "T"),
             ), \
             mock.patch.object(
                 discover_sessions, "post",
                 return_value=[{
                     "ssot__Id__c": "sid1",
                     "ssot__StartTimestamp__c": "2026-04-22T00:00:00Z",
                     "ssot__EndTimestamp__c": "2026-04-22T00:01:00Z",
                     "ssot__AiAgentChannelType__c": "Builder",
                     "ssot__AiAgentSessionEndType__c": "USER_ENDED",
                 }],
             ), \
             mock.patch.object(
                 discover_sessions, "render_picker",
                 side_effect=fake_render,
             ):
            discover_sessions.main()
        return captured["filters"]

    def test_filters_omit_case_sensitive_when_grep_unset(self):
        # No --grep at all: surfacing case-sensitive=yes in the header
        # would be a meaningless artifact (there's no grep to be
        # case-sensitive about). Contract: the value is None so
        # render_picker's `if v:` filter drops the bit.
        filters = self._run_main_and_capture_filters()
        self.assertIsNone(filters["grep_case_sensitive"])

    def test_filters_omit_case_sensitive_when_grep_set_but_default(self):
        # --grep set, --grep-case-sensitive NOT set: default mode is
        # case-insensitive. Don't surface the marker — the absence is
        # the default and surfacing "yes/no" on every grep would just
        # add noise to the picker header.
        filters = self._run_main_and_capture_filters("--grep", "refund")
        self.assertEqual(filters["grep"], "refund")
        self.assertIsNone(filters["grep_case_sensitive"])

    def test_filters_surface_case_sensitive_only_when_both_set(self):
        # The interesting case: operator opted in. The header MUST tell
        # them, otherwise a zero-row return looks identical to a
        # case-insensitive zero-row return.
        filters = self._run_main_and_capture_filters(
            "--grep", "Refund", "--grep-case-sensitive",
        )
        self.assertEqual(filters["grep"], "Refund")
        self.assertEqual(filters["grep_case_sensitive"], "yes")


class RenderPickerHeaderShowsCaseSensitiveTests(unittest.TestCase):
    """End-to-end: when filters dict surfaces ``grep_case_sensitive``,
    render_picker must include it in the header."""

    def _row(self) -> dict:
        return {
            "ssot__Id__c": "sid1",
            "ssot__StartTimestamp__c": "2026-04-22T10:00:00Z",
            "ssot__EndTimestamp__c": "2026-04-22T10:00:30Z",
            "ssot__AiAgentChannelType__c": "Builder",
            "ssot__AiAgentSessionEndType__c": "USER_ENDED",
        }

    def _tr(self) -> "discover_sessions.TimeRange":
        from datetime import datetime, timezone
        return discover_sessions.TimeRange(
            start_utc=datetime(2026, 4, 22, 0, 0, 0, tzinfo=timezone.utc),
            end_utc=datetime(2026, 4, 22, 23, 0, 0, tzinfo=timezone.utc),
            expr="test", tz_name="UTC",
        )

    def test_header_includes_case_sensitive_bit_when_set(self):
        out = discover_sessions.render_picker(
            rows=[self._row()], agent_by_sid={}, org="my-org",
            tr=self._tr(),
            filters={
                "agent": None, "channel": None, "outcome": None,
                "grep": "Refund", "grep_case_sensitive": "yes",
            },
            composed_sql="",
        )
        self.assertIn("grep=Refund", out)
        self.assertIn("grep_case_sensitive=yes", out)

    def test_header_omits_case_sensitive_bit_in_default_mode(self):
        # Default-mode grep (no opt-in): the bit must NOT appear.
        out = discover_sessions.render_picker(
            rows=[self._row()], agent_by_sid={}, org="my-org",
            tr=self._tr(),
            filters={
                "agent": None, "channel": None, "outcome": None,
                "grep": "refund", "grep_case_sensitive": None,
            },
            composed_sql="",
        )
        self.assertIn("grep=refund", out)
        self.assertNotIn("grep_case_sensitive", out)


if __name__ == "__main__":
    unittest.main()
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall