Align multi-line section head on the grid

My approach makes two changes to your code:

  1. Do not place the headings on grid explicitly: remove the option grid=high. (Recommendation based on prior experience.)
  2. Stuff headings into a frame with the parameter location=top.

The code below remains remarkably robust. Even when dealing with headings that take three lines and more, things will remain on grid. There is, however, one property of your example that it does not account for: if the heading is the first element on a new page, the title will skip the first line. Personally, I prefer that to the heading extending upwards into the header.

% macros=mkvi
\setuplayout [grid=yes]
\definefont  [BigFont]  [Bold at 20pt] [24pt]

\unprotect

\newdimen\section_frame_width
\unexpanded\def\section_command#number#title{%
  \section_frame_width\hsize%% we need to calculate the remaining
  \setbox\scratchbox\hbox{#number\space}%% horizontal space
  \advance\section_frame_width by -\wd\scratchbox
  #number\space
  \framed[
    width=\section_frame_width,%% “local” or “fit” doesn’t work
    before=,
    location=top,
    frame=on,%% comment this for production
    align=right,]{#title}%
}

\setuphead   [section]  [
  style=\BigFont,
  after=,
  % grid=high,
  before={\blank[2*line]},
  command=\section_command,
]
\protect

\showgrid

\starttext

  \startsection [title=Lorem ipsum dolor]
    \input ward
  \stopsection

  \dorecurse{4}{%
    \startsection [title=Lorem ipsum dolor sit amet consectetur adipisicing elit]
      \input ward \stopsection %% two lines
    \startsection [title=Lorem ipsum dolor sit amet consectetur adipisicing elit
                         Lorem ipsum dolor sit amet consectetur adipisicing elit]
      \input ward \stopsection %% three
    \startsection [title=Lorem ipsum dolor sit amet consectetur adipisicing elit
                         Lorem ipsum dolor sit amet consectetur adipisicing elit
                         Lorem ipsum dolor sit amet consectetur adipisicing elit]
      \input ward \stopsection %% five
  }

\stoptext

first line of structure title on grid