SERVER-98435 Allow marking modules as fully_marked so they stay that way even when new files are added (#42270)

GitOrigin-RevId: cb96c2d48b51302a5c30fe1ce0f7a23a5b2f9132
This commit is contained in:
Mathias Stearn 2025-10-08 20:45:17 +02:00 committed by MongoDB Bot
parent 6cb8c7403a
commit 504c4bc8d1
3 changed files with 28 additions and 3 deletions

View File

@ -47,16 +47,20 @@ with open(parent / "modules.yaml") as f:
def parseModules(): def parseModules():
raw_mods = yaml.load(f, Loader=Loader) raw_mods = yaml.load(f, Loader=Loader)
lines = [] lines = []
fully_marked = set[str]()
for mod, info in raw_mods.items(): for mod, info in raw_mods.items():
for glob in info["files"]: for glob in info["files"]:
lines.append(f"/{glob} @10gen/{mod}") lines.append(f"/{glob} @10gen/{mod}")
if info.get("meta", {}).get("fully_marked", False):
fully_marked.add(mod)
# If multiple rules match, later wins. So put rules with more # If multiple rules match, later wins. So put rules with more
# specificity later. For all of our current rules, longer means more # specificity later. For all of our current rules, longer means more
# specific. # specific.
lines.sort(key=lambda l: len(l.split()[0])) lines.sort(key=lambda l: len(l.split()[0]))
return "\n".join(lines) return "\n".join(lines), fully_marked
modules = CodeOwners(parseModules()) modules_text, fully_marked_modules = parseModules()
modules = CodeOwners(modules_text)
def normpath_for_file(f: Cursor | ClangFile | str | None) -> str | None: def normpath_for_file(f: Cursor | ClangFile | str | None) -> str | None:
@ -107,6 +111,10 @@ def mod_for_file(f: ClangFile | str | None) -> str | None:
return mod return mod
def is_module_fully_marked(mod: str | None) -> bool:
return mod in fully_marked_modules
def teams_for_file(f: ClangFile | str | None): def teams_for_file(f: ClangFile | str | None):
name = normpath_for_file(f) name = normpath_for_file(f)
if name is None: if name is None:

View File

@ -38,7 +38,7 @@ from cindex import (
RefQualifierKind, RefQualifierKind,
TranslationUnit, TranslationUnit,
) )
from mod_mapping import mod_for_file, normpath_for_file from mod_mapping import is_module_fully_marked, mod_for_file, normpath_for_file
def perr(*values): def perr(*values):
@ -868,6 +868,14 @@ def parseTU(args: list[str] | str):
complete_headers.add(normpath_for_file(include.include)) complete_headers.add(normpath_for_file(include.include))
continue continue
# Treat all headers from fully marked modules as complete. This makes newly-added
# headers in that module private by default, requiring explicit marking of the public
# API.
header_mod = mod_for_file(include.include)
if is_module_fully_marked(header_mod):
complete_headers.add(normpath_for_file(include.include))
continue
# Note: using bytes to avoid unicode handling overhead since the # Note: using bytes to avoid unicode handling overhead since the
# needles we are looking for are ascii-only. # needles we are looking for are ascii-only.
content = Path(include.include.name).read_bytes() content = Path(include.include.name).read_bytes()

View File

@ -15,6 +15,14 @@
# jira: # jira:
# Jira "Assigned Team" that should be used when filing tickets for the module. # Jira "Assigned Team" that should be used when filing tickets for the module.
# #
# fully_marked:
# If present and true, behaves as if all headers in the module have been fully
# marked, meaning that any unmarked APIs will be treated as private, regardless
# of whether they have included modules.h. This lets us lock-in the progress of
# marking that module so that it stays fully marked even as new files are added.
# Unlike other metadata, this is not inherited by submodules so that it is
# possible to have a fully_marked parent module before marking all submodules.
#
# If unsure about these, or if multiple teams are involved, please pick a good place # If unsure about these, or if multiple teams are involved, please pick a good place
# to send questions/tickets to initially, understanding that we can always send them # to send questions/tickets to initially, understanding that we can always send them
# somewhere else if needed. # somewhere else if needed.
@ -931,6 +939,7 @@ atlas_streams:
meta: meta:
slack: streams-engine slack: streams-engine
jira: Atlas Streams jira: Atlas Streams
fully_marked: true
files: files:
- src/mongo/db/modules/enterprise/src/streams - src/mongo/db/modules/enterprise/src/streams