agentleFS
ElasticKnown publisherelastic/docs-builder/src/services/search/Elastic.Documentation.Search.Contract/AGENTS.md

docs-builder / Elastic.Documentation.Search.Contract

AGENTS.md25 starsChanged 19 days agoApache-2.0View on GitHub

The shared document/mapping/analysis schema consumed by two independent indexers: the docs build pipeline (Elastic.Markdown/Exporters/Elasticsearch/ElasticsearchMarkdownExporter.cs) and essc (src/tooling/essc/). Nothing here should assume which one is calling it — that's the whole point of the project existing separately instead of living inside either. One folder per document type/concern; each document type owns its own *MappingConfig.cs and composes Common/SharedMappingConfig.cs's shared field mappings. Folder layout is concern-based but the project deliberately exposes only two namespaces — root and .Mapping — not one per folder;…

We split this AGENTS.md into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    AOT-safe polymorphism, not reflection: All document types are declared as [JsonDerivedType(typeof(X), "discriminator")] directly on …

    line 31

≈ “Common” is an estimate: at least 1 in 5 of the 36,368 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Elastic.Documentation.Search.Contract

The shared document/mapping/analysis schema consumed by two independent indexers: the docs build pipeline (Elastic.Markdown/Exporters/Elasticsearch/ElasticsearchMarkdownExporter.cs) and essc (src/tooling/essc/). Nothing here should assume which one is calling it — that's the whole point of the project existing separately instead of living inside either.

Structure

Common/       Shared plumbing: ISearchDocument, the polymorphism wiring, mapping/analysis config
              shared across document types, content-tier and synonym types.
Docs/         DocumentationDocument — docs-builder's own indexed pages.
Site/         SiteDocument — elastic.co website content.
Labs/         LabsDocument — Labs content source.
Guide/        GuideDocument — Guide content source.
WebsiteSearch/ WebsiteSearchDocument — the unified cross-source search index.
Autocomplete/ Request/response types for autocomplete, not a document type.
Search/       ISearchService and query/aggregation request/response types.

One folder per document type/concern; each document type owns its own *MappingConfig.cs and composes Common/SharedMappingConfig.cs's shared field mappings.

Folder layout is concern-based but the project deliberately exposes only two namespaces — root and .Mapping — not one per folder; the .csproj suppresses IDE0130 (namespace-doesn't-match- folder) for exactly this reason. Don't "fix" that warning by adding folder-matching namespaces.

Rules

AOT-safe polymorphism, not reflection. All document types are declared as [JsonDerivedType(typeof(X), "discriminator")] directly on ISearchDocument (Common/ISearchDocument.cs) with string discriminators ("site", "labs", "guide", "website", "docs"), and Common/SearchDocumentPolymorphism.cs builds the equivalent config into JsonSerializerOptions for callers that need it dynamically. Adding a document type means adding both a [JsonDerivedType] attribute and registering it in whichever JsonSerializerContext serializes it — this project is IsAotCompatible, and reflection-based discovery isn't an option.

Analyzer/normalizer names must match across two files, by string, not by reference. Common/SharedMappingConfig.cs declares name constants (KeywordNormalizer = "keyword_normalizer", StartsWithAnalyzer, HierarchyAnalyzer, SynonymsAnalyzer, ...); Common/SharedAnalysisFactory.cs builds the actual Elasticsearch analyzer/normalizer definitions using raw string literals, not the constants. If you rename one side, you silently break the mapping↔analysis link with no compiler error — grep for the literal string on both sides before renaming anything here.

Schema/discriminator stability is a rule, not a preference. Both consumers reindex from these types; an incompatible change to a document type or a discriminator value breaks one indexer without necessarily breaking the other's build. Bump the contract version (see essc/docs-builder normalization history) rather than changing a shipped shape in place.

Where do I put X?

ChangeLocation
New document type for a new content sourceNew folder + *Document.cs + *MappingConfig.cs, register discriminator in Common/ISearchDocument.cs
Field shared by every document typeCommon/SharedMappingConfig.cs (mapping) — keep SharedAnalysisFactory.cs in sync by string
New analyzer/normalizerCommon/SharedAnalysisFactory.cs, name constant in SharedMappingConfig.cs
Search/autocomplete request or response shapeSearch/ or Autocomplete/
Content-tier / synonym logic shared across sourcesCommon/ContentTiers.cs / Common/IndexTimeSynonyms.cs

Related docs

docs/development/essc.md covers the operator/config side (credentials, sources, container image); this file is the code-facing contract rules that doc doesn't repeat.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.